| 1 | protected override void OnWindowRestored(Window window, XElement element) |
| 2 | { |
| 3 | Print("OnWindowRestored for " + window.GetHashCode()); |
| 4 | |
| 5 | // locate the worksapces "SampleAddOn" elemenet which was created and saved earlier using the OnWindowSaved() method |
| 6 | XElement sampleAddOnElement = element.Element("SampleAddOn"); |
| 7 | |
| 8 | // do not do anything if that element does not exist |
| 9 | if (sampleAddOnElement == null) |
| 10 | return; |
| 11 | |
| 12 | // loop through all the contents of the "SampleAddOn" element |
| 13 | foreach (XElement content in sampleAddOnElement.Elements()) |
| 14 | { |
| 15 | // find the "ButtonState" content, restore it's value and set that as our tracked buttonState |
| 16 | if (content.Name == "ButtonState") |
| 17 | { |
| 18 | bool buttonState = false; |
| 19 | bool.TryParse(content.Value, out buttonState); |
| 20 | continue; |
| 21 | } |
| 22 | //Parse additional elements here |
| 23 | } |
| 24 | |
| 25 | //Don't forget to call the base OnWindowRestored method after you're done. |
| 26 | base.OnWindowRestored(window, element); |