private bool Load(XmlDocument xmlDocument)
        {
            if (xmlDocument.ChildNodes.Count == 0)
            {
                return(false);
            }

            List <UserControl> documentViews = LoadViewsFromTemplates(DocumentTemplates, DocumentsSource);
            List <UserControl> toolViews     = LoadViewsFromTemplates(ToolTemplates, ToolsSource);

            List <UserControl> views = new List <UserControl>();
            Dictionary <string, UserControl> viewsMap = new Dictionary <string, UserControl>();

            foreach (var item in documentViews)
            {
                viewsMap.Add(ILayoutFactory.MakeDocumentKey(item.Name, ((item.DataContext) as IViewModel).URL), item);
            }

            foreach (var item in toolViews)
            {
                viewsMap.Add(item.Name, item);
            }

            // Now load the views into the dock manager => one or more views might not be visible!

            Serialisation.LayoutReader.LoadNode(this, viewsMap, this, this, xmlDocument.DocumentElement, true);

            // Remove any view without a view model

            ValidateToolPanes();
            ValidateDocumentPanes();
            IFloatingPaneManager.CancelSelection();

            return(true);
        }
        private static void LoadDocuments(ILayoutFactory iLayoutFactory, Dictionary <string, UserControl> viewsMap, XmlElement xmlDocumentPaneGroup, IViewContainer iViewContainer)
        {
            foreach (var xmlChild in xmlDocumentPaneGroup.ChildNodes)
            {
                if (xmlChild is XmlElement)
                {
                    if ((xmlChild as XmlElement).Name == "Document")
                    {
                        XmlElement xmlToolElement = xmlChild as XmlElement;

                        string contentId = GetStringAttribute(xmlToolElement, "ContentId");
                        string url       = GetStringAttribute(xmlToolElement, "Url");
                        string key       = iLayoutFactory.MakeDocumentKey(contentId, url);

                        if (viewsMap.ContainsKey(key))
                        {
                            iViewContainer.AddUserControl(viewsMap[key]);
                            viewsMap.Remove(contentId);
                        }
                    }
                }
            }
        }