///// <summary> ///// Restore from xml a document pane ///// </summary> ///// <param name="childElement"></param> ///// <param name="mainExistingDocumentPane"></param> ///// <param name="existingDocumentPanel"></param> ///// <param name="dockableContents"></param> //void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel, DockableContent[] dockableContents) //{ // mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel); // if (mainExistingDocumentPane != null) // { // existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel(); // } // else // { // existingDocumentPanel = null; // } // if (existingDocumentPanel != null) // { // if (existingDocumentPanel.Parent is ResizingPanel) // { // ((ResizingPanel)existingDocumentPanel.Parent).RemoveChild(existingDocumentPanel); // } // else if (existingDocumentPanel.Parent is DockingManager) // { // ((DockingManager)existingDocumentPanel.Parent).Content = null; // } // } // else if (mainExistingDocumentPane != null) // { // if (mainExistingDocumentPane.Parent is ResizingPanel) // { // ((ResizingPanel)mainExistingDocumentPane.Parent).RemoveChild(mainExistingDocumentPane); // } // else if (mainExistingDocumentPane.Parent is DockingManager) // { // ((DockingManager)mainExistingDocumentPane.Parent).Content = null; // } // } // foreach (XmlElement contentElement in childElement.ChildNodes) // { // if (contentElement.HasAttribute("Name")) // { // DockableContent foundContent = null; // string contentName = contentElement.GetAttribute("Name"); // foreach (DockableContent content in dockableContents) // { // if (content.Name == contentName) // { // foundContent = content; // break; // } // } // if (foundContent == null && // DeserializationCallback != null) // { // DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); // DeserializationCallback(this, e); // foundContent = e.Content as DockableContent; // } // if (foundContent != null) // { // DetachContentFromDockingManager(foundContent); // mainExistingDocumentPane.Items.Add(foundContent); // foundContent.SetStateToDocument(); // //call custom layout persistence method // foundContent.RestoreLayout(contentElement); // } // } // } //} DocumentPane RestoreDocumentPaneLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments) { var documentPane = new DocumentPane(); if (mainElement.HasAttribute("ResizeWidth")) ResizingPanel.SetResizeWidth(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth"))); if (mainElement.HasAttribute("ResizeHeight")) ResizingPanel.SetResizeHeight(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight"))); if (mainElement.HasAttribute("EffectiveSize")) ResizingPanel.SetEffectiveSize(documentPane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize"))); foreach (XmlElement contentElement in mainElement.ChildNodes) { if (contentElement.Name == "DockableContent" && contentElement.HasAttribute("Name")) { DockableContent foundContent = null; string contentName = contentElement.GetAttribute("Name"); foundContent = actualContents.FirstOrDefault(c => c.Name == contentName); if (foundContent == null && DeserializationCallback != null) { DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); DeserializationCallback(this, e); foundContent = e.Content as DockableContent; } if (foundContent != null) { DetachContentFromDockingManager(foundContent); documentPane.Items.Add(foundContent); foundContent.SetStateToDocument(); //call custom layout persistence method foundContent.RestoreLayout(contentElement); } } else if (contentElement.Name == "DocumentContent" && contentElement.HasAttribute("Name")) { DocumentContent foundDocument = null; string contentName = contentElement.GetAttribute("Name"); foundDocument = actualDocuments.FirstOrDefault(c => c.Name == contentName); if (foundDocument == null && DeserializationCallback != null) { DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); DeserializationCallback(this, e); foundDocument = e.Content as DocumentContent; } if (foundDocument != null) { foundDocument.DetachFromContainerPane(); documentPane.Items.Add(foundDocument); } } } if (mainElement.HasAttribute("SelectedIndex")) documentPane.SelectedIndex = XmlConvert.ToInt32(mainElement.GetAttribute("SelectedIndex")); return documentPane; }
DockablePane RestoreDockablePaneLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments) { DockablePane pane = new DockablePane(); if (mainElement.HasAttribute("Anchor")) pane.Anchor = (AnchorStyle)Enum.Parse(typeof(AnchorStyle), mainElement.GetAttribute("Anchor")); if (mainElement.HasAttribute("ResizeWidth")) ResizingPanel.SetResizeWidth(pane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth"))); if (mainElement.HasAttribute("ResizeHeight")) ResizingPanel.SetResizeHeight(pane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight"))); if (mainElement.HasAttribute("EffectiveSize")) ResizingPanel.SetEffectiveSize(pane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize"))); if (mainElement.HasAttribute("ID")) pane.ID = new Guid(mainElement.GetAttribute("ID")); bool toggleAutoHide = false; if (mainElement.HasAttribute("IsAutoHidden")) toggleAutoHide = XmlConvert.ToBoolean(mainElement.GetAttribute("IsAutoHidden")); foreach (XmlElement contentElement in mainElement.ChildNodes) { if (contentElement.HasAttribute("Name")) { DockableContent foundContent = null; string contentName = contentElement.GetAttribute("Name"); foundContent = actualContents.FirstOrDefault(c => c.Name == contentName); if (foundContent == null && DeserializationCallback != null) { DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); DeserializationCallback(this, e); foundContent = e.Content as DockableContent; } if (foundContent != null) { DetachContentFromDockingManager(foundContent); pane.Items.Add(foundContent); foundContent.SetStateToDock(); //call custom layout persistence method foundContent.RestoreLayout(contentElement); } } } if (toggleAutoHide && pane.Items.Count > 0) ToggleAutoHide(pane); if (mainElement.HasAttribute("SelectedIndex")) pane.SelectedIndex = XmlConvert.ToInt32(mainElement.GetAttribute("SelectedIndex")); return pane; }