Inheritance: System.Windows.Forms.Form, IDockListContainer
        internal int Add(FloatWindow fw)
        {
            if (InnerList.Contains(fw))
                return InnerList.IndexOf(fw);

            return InnerList.Add(fw);
        }
        public static void LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent)
        {
            if (dockPanel.Contents.Count != 0)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPanel.LoadFromXml.AlreadyInitialized"));
            }

            EnumConverter      dockStateConverter     = new EnumConverter(typeof(DockState));
            EnumConverter      dockAlignmentConverter = new EnumConverter(typeof(DockAlignment));
            RectangleConverter rectConverter          = new RectangleConverter();

            XmlTextReader xmlIn = new XmlTextReader(stream);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            if (xmlIn.Name != "DockPanel")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }

            string formatVersion = xmlIn.GetAttribute("FormatVersion");

            if (formatVersion != ConfigFileVersion)
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidFormatVersion"));
            }
            DockPanelStruct dockPanelStruct = new DockPanelStruct();

            dockPanelStruct.DockLeftPortion         = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockRightPortion        = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockTopPortion          = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockBottomPortion       = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"));
            dockPanelStruct.IndexActivePane         = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"));

            // Load Contents
            MoveToNextElement(xmlIn);
            if (xmlIn.Name != "Contents")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            ContentStruct[] contents = new ContentStruct[countOfContents];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfContents; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Content" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                contents[i].PersistString   = xmlIn.GetAttribute("PersistString");
                contents[i].AutoHidePortion = Convert.ToDouble(xmlIn.GetAttribute("AutoHidePortion"), CultureInfo.InvariantCulture);
                contents[i].IsHidden        = Convert.ToBoolean(xmlIn.GetAttribute("IsHidden"));
                contents[i].IsFloat         = Convert.ToBoolean(xmlIn.GetAttribute("IsFloat"));
                MoveToNextElement(xmlIn);
            }

            // Load Panes
            if (xmlIn.Name != "Panes")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            PaneStruct[] panes = new PaneStruct[countOfPanes];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfPanes; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Pane" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                panes[i].DockState          = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                panes[i].IndexActiveContent = Convert.ToInt32(xmlIn.GetAttribute("ActiveContent"));
                panes[i].ZOrderIndex        = -1;

                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "Contents")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfPaneContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                panes[i].IndexContents = new int[countOfPaneContents];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfPaneContents; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Content" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }

                    panes[i].IndexContents[j] = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    MoveToNextElement(xmlIn);
                }
            }

            // Load DockWindows
            if (xmlIn.Name != "DockWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfDockWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            DockWindowStruct[] dockWindows = new DockWindowStruct[countOfDockWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfDockWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "DockWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                dockWindows[i].DockState   = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                dockWindows[i].ZOrderIndex = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                dockWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    dockWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    dockWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    dockWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    dockWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }

            // Load FloatWindows
            if (xmlIn.Name != "FloatWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfFloatWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            FloatWindowStruct[] floatWindows = new FloatWindowStruct[countOfFloatWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfFloatWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "FloatWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                floatWindows[i].Bounds         = (Rectangle)rectConverter.ConvertFromInvariantString(xmlIn.GetAttribute("Bounds"));
                floatWindows[i].AllowRedocking = Convert.ToBoolean(xmlIn.GetAttribute("AllowRedocking"));
                floatWindows[i].ZOrderIndex    = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                floatWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    floatWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    floatWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    floatWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    floatWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }
            xmlIn.Close();

            dockPanel.DockLeftPortion   = dockPanelStruct.DockLeftPortion;
            dockPanel.DockRightPortion  = dockPanelStruct.DockRightPortion;
            dockPanel.DockTopPortion    = dockPanelStruct.DockTopPortion;
            dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion;

            // Create Contents
            for (int i = 0; i < contents.Length; i++)
            {
                DockContent content = deserializeContent(contents[i].PersistString);
                if (content == null)
                {
                    content = new DummyContent();
                }
                content.DockPanel       = dockPanel;
                content.AutoHidePortion = contents[i].AutoHidePortion;
                content.IsHidden        = true;
                content.IsFloat         = contents[i].IsFloat;
            }

            // Create panes
            for (int i = 0; i < panes.Length; i++)
            {
                DockPane pane = null;
                for (int j = 0; j < panes[i].IndexContents.Length; j++)
                {
                    DockContent content = dockPanel.Contents[panes[i].IndexContents[j]];
                    if (j == 0)
                    {
                        pane = dockPanel.DockPaneFactory.CreateDockPane(content, panes[i].DockState, false);
                    }
                    else if (panes[i].DockState == DockState.Float)
                    {
                        content.FloatPane = pane;
                    }
                    else
                    {
                        content.PanelPane = pane;
                    }
                }
            }

            // Assign Panes to DockWindows
            for (int i = 0; i < dockWindows.Length; i++)
            {
                for (int j = 0; j < dockWindows[i].DockList.Length; j++)
                {
                    DockWindow    dw            = dockPanel.DockWindows[dockWindows[i].DockState];
                    int           indexPane     = dockWindows[i].DockList[j].IndexPane;
                    DockPane      pane          = dockPanel.Panes[indexPane];
                    int           indexPrevPane = dockWindows[i].DockList[j].IndexPrevPane;
                    DockPane      prevPane      = (indexPrevPane == -1) ? dw.DockList.GetDefaultPrevPane(pane) : dockPanel.Panes[indexPrevPane];
                    DockAlignment alignment     = dockWindows[i].DockList[j].Alignment;
                    double        proportion    = dockWindows[i].DockList[j].Proportion;
                    pane.AddToDockList(dw, prevPane, alignment, proportion);
                    if (panes[indexPane].DockState == dw.DockState)
                    {
                        panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex;
                    }
                }
            }

            // Create float windows
            for (int i = 0; i < floatWindows.Length; i++)
            {
                FloatWindow fw = null;
                for (int j = 0; j < floatWindows[i].DockList.Length; j++)
                {
                    int      indexPane = floatWindows[i].DockList[j].IndexPane;
                    DockPane pane      = dockPanel.Panes[indexPane];
                    if (j == 0)
                    {
                        fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds);
                    }
                    else
                    {
                        int           indexPrevPane = floatWindows[i].DockList[j].IndexPrevPane;
                        DockPane      prevPane      = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane];
                        DockAlignment alignment     = floatWindows[i].DockList[j].Alignment;
                        double        proportion    = floatWindows[i].DockList[j].Proportion;
                        pane.AddToDockList(fw, prevPane, alignment, proportion);
                        if (panes[indexPane].DockState == fw.DockState)
                        {
                            panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex;
                        }
                    }
                }
            }

            // sort DockContent by its Pane's ZOrder
            int[] sortedContents = null;
            if (contents.Length > 0)
            {
                sortedContents = new int[contents.Length];
                for (int i = 0; i < contents.Length; i++)
                {
                    sortedContents[i] = i;
                }

                int lastDocument = contents.Length;
                for (int i = 0; i < contents.Length - 1; i++)
                {
                    for (int j = i + 1; j < contents.Length; j++)
                    {
                        DockPane pane1        = dockPanel.Contents[sortedContents[i]].Pane;
                        int      ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex;
                        DockPane pane2        = dockPanel.Contents[sortedContents[j]].Pane;
                        int      ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex;
                        if (ZOrderIndex1 > ZOrderIndex2)
                        {
                            int temp = sortedContents[i];
                            sortedContents[i] = sortedContents[j];
                            sortedContents[j] = temp;
                        }
                    }
                }
            }

            // show non-document DockContent first to avoid screen flickers
            for (int i = 0; i < contents.Length; i++)
            {
                DockContent content = dockPanel.Contents[sortedContents[i]];
                if (content.Pane != null && content.Pane.DockState != DockState.Document)
                {
                    content.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            // after all non-document DockContent, show document DockContent
            for (int i = 0; i < contents.Length; i++)
            {
                DockContent content = dockPanel.Contents[sortedContents[i]];
                if (content.Pane != null && content.Pane.DockState == DockState.Document)
                {
                    content.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            for (int i = 0; i < panes.Length; i++)
            {
                dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 ? null : dockPanel.Contents[panes[i].IndexActiveContent];
            }

            if (dockPanelStruct.IndexActiveDocumentPane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate();
            }

            if (dockPanelStruct.IndexActivePane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate();
            }

            for (int i = dockPanel.Contents.Count - 1; i >= 0; i--)
            {
                if (dockPanel.Contents[i] is DummyContent)
                {
                    dockPanel.Contents[i].Close();
                }
            }
        }
 internal void Remove(FloatWindow fw)
 {
     InnerList.Remove(fw);
 }
 internal void BringWindowToFront(FloatWindow fw)
 {
     InnerList.Remove(fw);
     InnerList.Add(fw);
 }
 /// <include file='CodeDoc\FloatWindowCollection.xml' path='//CodeDoc/Class[@name="FloatWindowCollection"]/Method[@name="Contains(FloatWindow)"]/*'/>>
 public bool Contains(FloatWindow fw)
 {
     return InnerList.Contains(fw);
 }
 /// <include file='CodeDoc\FloatWindowCollection.xml' path='//CodeDoc/Class[@name="FloatWindowCollection"]/Method[@name="IndexOf(FloatWindow)"]/*'/>>
 public int IndexOf(FloatWindow fw)
 {
     return InnerList.IndexOf(fw);
 }
 internal void BringWindowToFront(FloatWindow fw)
 {
     InnerList.Remove(fw);
     InnerList.Add(fw);
 }
Exemple #8
0
 public DockPane CreateDockPane(DockContent content, FloatWindow floatWindow, bool show)
 {
     return(new DockPane(content, floatWindow, show));
 }
 /// <include file='CodeDoc\FloatWindowCollection.xml' path='//CodeDoc/Class[@name="FloatWindowCollection"]/Method[@name="IndexOf(FloatWindow)"]/*'/>>
 public int IndexOf(FloatWindow fw)
 {
     return(InnerList.IndexOf(fw));
 }
 internal void Remove(FloatWindow fw)
 {
     InnerList.Remove(fw);
 }
 /// <include file='CodeDoc\FloatWindowCollection.xml' path='//CodeDoc/Class[@name="FloatWindowCollection"]/Method[@name="Contains(FloatWindow)"]/*'/>>
 public bool Contains(FloatWindow fw)
 {
     return(InnerList.Contains(fw));
 }
Exemple #12
0
        internal void RemoveFloatWindow(FloatWindow floatWindow)
        {
            if (!FloatWindows.Contains(floatWindow))
                return;

            FloatWindows.Remove(floatWindow);
        }
Exemple #13
0
        internal void AddFloatWindow(FloatWindow floatWindow)
        {
            if (FloatWindows.Contains(floatWindow))
                return;

            FloatWindows.Add(floatWindow);
        }
Exemple #14
0
 /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Constructor[@name="(DockContent, FloatWindow, bool)"]/*'/>
 public DockPane(DockContent content, FloatWindow floatWindow, bool show)
 {
     InternalConstruct(content, DockState.Float, false, Rectangle.Empty, floatWindow.DockList.GetDefaultPrevPane(this), DockAlignment.Right, 0.5, show);
 }
Exemple #15
0
        public void BeginDragFloatWindow(FloatWindow floatWindow)
        {
            if (!InitDrag(floatWindow, DragSource.FloatWindow))
                return;

            FloatWindow_BeginDrag();
        }
 public DockPane CreateDockPane(DockContent content, FloatWindow floatWindow, bool show)
 {
     return new DockPane(content, floatWindow, show);
 }
Exemple #17
0
        private void FloatWindow_OnEndDrag(bool abort)
        {
            if (abort)
            {
                return;
            }

            FloatWindow floatWindow = (FloatWindow)DragControl;

            if (DropTarget.DropTo == null)
            {
                Rectangle rect = DragControl.Bounds;
                rect.X             = Control.MousePosition.X + m_mouseOffset.X;
                rect.Y             = Control.MousePosition.Y + m_mouseOffset.Y;
                DragControl.Bounds = rect;
            }
            else if (DropTarget.DropTo is DockPane)
            {
                DockPane paneTo = DropTarget.DropTo as DockPane;

                if (DropTarget.Dock == DockStyle.Fill)
                {
                    for (int i = floatWindow.DockList.Count - 1; i >= 0; i--)
                    {
                        DockPane pane = floatWindow.DockList[i];
                        for (int j = pane.Contents.Count - 1; j >= 0; j--)
                        {
                            DockContent c = pane.Contents[j];
                            c.Pane = paneTo;
                            if (DropTarget.ContentIndex != -1)
                            {
                                paneTo.SetContentIndex(c, DropTarget.ContentIndex);
                            }
                            c.Activate();
                        }
                    }
                }
                else
                {
                    DockAlignment alignment = DockAlignment.Left;
                    if (DropTarget.Dock == DockStyle.Left)
                    {
                        alignment = DockAlignment.Left;
                    }
                    else if (DropTarget.Dock == DockStyle.Right)
                    {
                        alignment = DockAlignment.Right;
                    }
                    else if (DropTarget.Dock == DockStyle.Top)
                    {
                        alignment = DockAlignment.Top;
                    }
                    else if (DropTarget.Dock == DockStyle.Bottom)
                    {
                        alignment = DockAlignment.Bottom;
                    }

                    MergeDockList(floatWindow.DisplayingList, paneTo.DockListContainer.DockList, paneTo, alignment, 0.5);
                }
            }
            else if (DropTarget.DropTo is DockPanel)
            {
                DockList dockListTo = null;

                if (DropTarget.Dock == DockStyle.Top)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockTop].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Bottom)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockBottom].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Left)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockLeft].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Right)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockRight].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Fill)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.Document].DockList;
                }

                DockPane prevPane = null;
                for (int i = dockListTo.Count - 1; i >= 0; i--)
                {
                    if (dockListTo[i] != floatWindow.DisplayingList[0])
                    {
                        prevPane = dockListTo[i];
                    }
                }
                MergeDockList(floatWindow.DisplayingList, dockListTo, prevPane, DockAlignment.Left, 0.5);
            }
        }