Exemplo n.º 1
0
        static public void Deserialize(DockingManagerControl manager, StreamReader reader)
        {
            manager.SuspendLayout();

            XmlSerializer serializer = new XmlSerializer(typeof(DockingManagerControlData));

            DockingManagerControlData dockingManagerControlData =
                serializer.Deserialize(reader) as DockingManagerControlData;

            CreatePanels(manager, dockingManagerControlData);

            IEnumerator dataEnumerator = dockingManagerControlData.DockingControls.GetEnumerator();
            IEnumerator <IDockingControl> controlEnumerator = manager.DockingControls.GetEnumerator();

            DeserializeControls(dataEnumerator, controlEnumerator);

            DeseriailizeDockingControlData(manager.Panels[DockingType.Left], dockingManagerControlData.LeftDockingContainerControlData);
            DeseriailizeDockingControlData(manager.Panels[DockingType.Right], dockingManagerControlData.RightDockingContainerControlData);
            DeseriailizeDockingControlData(manager.Panels[DockingType.Top], dockingManagerControlData.TopDockingContainerControlData);
            DeseriailizeDockingControlData(manager.Panels[DockingType.Bottom], dockingManagerControlData.BottomDockingContainerControlData);

            ClearEmptyPanels(manager.Panels[DockingType.Left]);
            ClearEmptyPanels(manager.Panels[DockingType.Right]);
            ClearEmptyPanels(manager.Panels[DockingType.Top]);
            ClearEmptyPanels(manager.Panels[DockingType.Bottom]);

            SetDockedDimensions(dataEnumerator, controlEnumerator);

            manager.ResumeLayout(true);
        }
Exemplo n.º 2
0
        static private void CreatePanels(DockingManagerControl manager, DockingManagerControlData dockingManagerControlData)
        {
            Dictionary <DockingType, int> mapDockingTypeToCount = new Dictionary <DockingType, int>();

            foreach (DockingControlData data in dockingManagerControlData.DockingControls)
            {
                if (data.DockingType != DockingType.Floating)
                {
                    if (mapDockingTypeToCount.ContainsKey(data.DockingType))
                    {
                        mapDockingTypeToCount[data.DockingType] =
                            Math.Max(mapDockingTypeToCount[data.DockingType], data.PanelIndex);
                    }
                    else
                    {
                        mapDockingTypeToCount.Add(data.DockingType, data.PanelIndex);
                    }
                }
            }

            foreach (DockingType dockingType in mapDockingTypeToCount.Keys)
            {
                int panels = mapDockingTypeToCount[dockingType];

                for (int index = 0; index <= panels; index += 1)
                {
                    IDockingPanelCollection panel = manager.Panels[dockingType];

                    if (panel.Count < (index + 1))
                    {
                        panel.InsertPanel(index);
                    }
                }
            }
        }
Exemplo n.º 3
0
        static public void Serialize(DockingManagerControl manager, StreamWriter stream)
        {
            DockingManagerControlData data = new DockingManagerControlData(manager);

            XmlSerializer serializer = new XmlSerializer(typeof(DockingManagerControlData));

            serializer.Serialize(stream, data);
        }