Пример #1
0
        /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Method[@name="SetDockState(DockState)"]/*'/>
        public DockPane SetDockState(DockState value)
        {
            if (value == DockState.Unknown || value == DockState.Hidden)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPane.SetDockState.InvalidState"));
            }

            if ((value == DockState.Float) == this.IsFloat)
            {
                InternalSetDockState(value);
                return(this);
            }

            if (DisplayingContents.Count == 0)
            {
                return(null);
            }

            IDockableWindow firstContent = null;

            for (int i = 0; i < DisplayingContents.Count; i++)
            {
                IDockableWindow content = DisplayingContents[i];
                if (content.DockHandler.IsDockStateValid(value))
                {
                    firstContent = content;
                    break;
                }
            }
            if (firstContent == null)
            {
                return(null);
            }

            firstContent.DockHandler.DockState = value;
            DockPane pane = firstContent.DockHandler.Pane;

            DockPanel.SuspendLayout(true);
            for (int i = 0; i < DisplayingContents.Count; i++)
            {
                IDockableWindow content = DisplayingContents[i];
                if (content.DockHandler.IsDockStateValid(value))
                {
                    content.DockHandler.Pane = pane;
                }
            }
            DockPanel.ResumeLayout(true, true);
            return(pane);
        }
Пример #2
0
        /// <include file='CodeDoc\DockContentHandler.xml' path='//CodeDoc/Class[@name="DockContentHandler"]/Method[@name="Show(DockPanel)"]/*'/>
        public void Show(DockContainer dockPanel)
        {
            if (dockPanel == null)
            {
                throw(new ArgumentNullException(ResourceHelper.GetString("IDockContent.Show.NullDockPanel")));
            }

            if (DockState == DockState.Unknown)
            {
                Show(dockPanel, DefaultShowState);
            }
            else
            {
                Activate();
            }
        }
Пример #3
0
        /// <include file='CodeDoc\DockContentHandler.xml' path='//CodeDoc/Class[@name="DockContentHandler"]/Method[@name="Show(DockPane, DockAlignment, double)"]/*'/>
        public void Show(DockPane prevPane, DockAlignment alignment, double proportion)
        {
            if (prevPane == null)
            {
                throw(new ArgumentException(ResourceHelper.GetString("IDockContent.Show.InvalidPrevPane")));
            }

            if (DockHelper.IsDockStateAutoHide(prevPane.DockState))
            {
                throw(new ArgumentException(ResourceHelper.GetString("IDockContent.Show.InvalidPrevPane")));
            }

            DockPanel = prevPane.DockPanel;
            DockPanel.DockPaneFactory.CreateDockPane(Content, prevPane, alignment, proportion, true);
            Show();
        }
Пример #4
0
        /// <include file='CodeDoc\DockContentHandler.xml' path='//CodeDoc/Class[@name="DockContentHandler"]/Method[@name="Show(DockPane, IDockContent)"]/*'/>
        public void Show(DockPane pane, IDockableWindow beforeContent)
        {
            if (pane == null)
            {
                throw(new ArgumentNullException(ResourceHelper.GetString("IDockContent.Show.NullPane")));
            }

            if (beforeContent != null && pane.Contents.IndexOf(beforeContent) == -1)
            {
                throw(new ArgumentException(ResourceHelper.GetString("IDockContent.Show.InvalidBeforeContent")));
            }

            DockPanel = pane.DockPanel;
            Pane      = pane;
            pane.SetContentIndex(Content, pane.Contents.IndexOf(beforeContent));
            Show();
        }
Пример #5
0
        /// <include file='CodeDoc\DockContentHandler.xml' path='//CodeDoc/Class[@name="DockContentHandler"]/Method[@name="Show(DockPanel, DockState)"]/*'/>
        public void Show(DockContainer dockPanel, DockState dockState)
        {
            if (dockPanel == null)
            {
                throw(new ArgumentNullException(ResourceHelper.GetString("IDockContent.Show.NullDockPanel")));
            }

            if (dockState == DockState.Unknown || dockState == DockState.Hidden)
            {
                throw(new ArgumentException(ResourceHelper.GetString("IDockContent.Show.InvalidDockState")));
            }

            DockPanel = dockPanel;

            if (dockState == DockState.Float && FloatPane == null)
            {
                Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, true);
            }
            else if (PanelPane == null)
            {
                DockPane paneExisting = null;
                foreach (DockPane pane in DockPanel.Panes)
                {
                    if (pane.DockState == dockState)
                    {
                        paneExisting = pane;
                        break;
                    }
                }

                if (paneExisting == null)
                {
                    Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true);
                }
                else
                {
                    Pane = paneExisting;
                }
            }

            DockState = dockState;
            Activate();
        }
Пример #6
0
        /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Method[@name="SetContentIndex(IDockContent, int)"]/*'/>
        public void SetContentIndex(IDockableWindow content, int index)
        {
            int oldIndex = Contents.IndexOf(content);

            if (oldIndex == -1)
            {
                throw (new ArgumentException(ResourceHelper.GetString("DockPane.SetContentIndex.InvalidContent")));
            }

            if (index < 0 || index > Contents.Count - 1)
            {
                if (index != -1)
                {
                    throw (new ArgumentOutOfRangeException(ResourceHelper.GetString("DockPane.SetContentIndex.InvalidIndex")));
                }
            }

            if (oldIndex == index)
            {
                return;
            }
            if (oldIndex == Contents.Count - 1 && index == -1)
            {
                return;
            }

            Contents.Remove(content);
            if (index == -1)
            {
                Contents.Add(content);
            }
            else if (oldIndex < index)
            {
                Contents.AddAt(content, index - 1);
            }
            else
            {
                Contents.AddAt(content, index);
            }

            RefreshChanges();
        }
Пример #7
0
        /// <include file='CodeDoc\DockContentHandler.xml' path='//CodeDoc/Class[@name="DockContentHandler"]/Method[@name="Show(DockPanel, Rectangle)"]/*'/>
        public void Show(DockContainer dockPanel, Rectangle floatWindowBounds)
        {
            if (dockPanel == null)
            {
                throw(new ArgumentNullException(ResourceHelper.GetString("IDockContent.Show.NullDockPanel")));
            }

            DockPanel = dockPanel;
            if (FloatPane == null)
            {
                IsHidden  = true;                       // to reduce the screen flicker
                FloatPane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, false);
                FloatPane.FloatWindow.StartPosition = FormStartPosition.Manual;
            }

            FloatPane.FloatWindow.Bounds = floatWindowBounds;

            Show(dockPanel, DockState.Float);
            Activate();
        }
Пример #8
0
        /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Method[@name="AddToDockList"]/*'/>
        /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Method[@name="AddToDockList(IDockListContainer)"]/*'/>
        public DockPane AddToDockList(IDockListContainer container)
        {
            if (container == null)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPane.AddToDockList.NullContainer"));
            }

            DockAlignment alignment;

            if (container.DockState == DockState.DockLeft || container.DockState == DockState.DockRight)
            {
                alignment = DockAlignment.Bottom;
            }
            else
            {
                alignment = DockAlignment.Right;
            }

            return(AddToDockList(container, container.DockList.GetDefaultPrevPane(this), alignment, 0.5));
        }
Пример #9
0
        private void InternalAddToDockList(IDockListContainer container, DockPane prevPane, DockAlignment alignment, double proportion)
        {
            if ((container.DockState == DockState.Float) != IsFloat)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPane.AddToDockList.InvalidContainer"));
            }

            int count = container.DockList.Count;

            if (container.DockList.Contains(this))
            {
                count--;
            }
            if (prevPane == null && count > 0)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPane.AddToDockList.NullPrevPane"));
            }

            if (prevPane != null && !container.DockList.Contains(prevPane))
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPane.AddToDockList.NoPrevPane"));
            }

            if (prevPane == this)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPane.AddToDockList.SelfPrevPane"));
            }

            IDockListContainer oldContainer = DockListContainer;
            DockState          oldDockState = DockState;

            container.DockList.Add(this);
            NestedDockingStatus.SetStatus(container.DockList, prevPane, alignment, proportion);

            if (DockHelper.IsDockWindowState(DockState))
            {
                _dockState = container.DockState;
            }

            RefreshStateChange(oldContainer, oldDockState);
        }
Пример #10
0
        private void InternalConstruct(DockContainer dockPanel, DockPane pane, bool boundsSpecified, Rectangle bounds)
        {
            if (dockPanel == null)
            {
                throw (new ArgumentNullException(ResourceHelper.GetString("FloatWindow.Constructor.NullDockPanel")));
            }

            _dockList = new DockList(this);

            FormBorderStyle = FormBorderStyle.SizableToolWindow;
            ShowInTaskbar   = false;

            SuspendLayout();
            if (boundsSpecified)
            {
                Bounds        = bounds;
                StartPosition = FormStartPosition.Manual;
            }
            else
            {
                StartPosition = FormStartPosition.WindowsDefaultLocation;
            }

            if (Environment.Version.Major == 1)
            {
                _dummyControl        = new DummyControl();
                _dummyControl.Bounds = Rectangle.Empty;
                Controls.Add(_dummyControl);
            }

            _dockPanel = dockPanel;
            Owner      = DockPanel.FindForm();
            DockPanel.AddFloatWindow(this);
            if (pane != null)
            {
                pane.FloatWindow = this;
            }

            ResumeLayout();
        }
Пример #11
0
        /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Method[@name="AddToDockList(IDockListContainer, DockPane, DockAlignment, double)"]/*'/>
        public DockPane AddToDockList(IDockListContainer container, DockPane prevPane, DockAlignment alignment, double proportion)
        {
            if (container == null)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPane.AddToDockList.NullContainer"));
            }

            if (container.IsFloat == this.IsFloat)
            {
                InternalAddToDockList(container, prevPane, alignment, proportion);
                return(this);
            }

            IDockableWindow firstContent = GetFirstContent(container.DockState);

            if (firstContent == null)
            {
                return(null);
            }

            DockPane pane;

            DockPanel.DummyContent.DockPanel = DockPanel;
            if (container.IsFloat)
            {
                pane = DockPanel.DockPaneFactory.CreateDockPane(DockPanel.DummyContent, (FloatWindow)container, true);
            }
            else
            {
                pane = DockPanel.DockPaneFactory.CreateDockPane(DockPanel.DummyContent, container.DockState, true);
            }

            pane.AddToDockList(container, prevPane, alignment, proportion);
            SetVisibleContentsToPane(pane);
            DockPanel.DummyContent.DockPanel = null;

            return(pane);
        }
Пример #12
0
        public static void LoadFromXml(DockContainer dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream)
        {
            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();

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

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

            if (!IsFormatVersionValid(formatVersion))
            {
                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 = dockPanel.DockWindows.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);
                }
            }

            if (closeStream)
            {
                xmlIn.Close();
            }

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

            // Set DockWindow ZOrders
            int prevMaxDockWindowZOrder = int.MaxValue;

            for (int i = 0; i < dockWindows.Length; i++)
            {
                int maxDockWindowZOrder = -1;
                int index = -1;
                for (int j = 0; j < dockWindows.Length; j++)
                {
                    if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder)
                    {
                        maxDockWindowZOrder = dockWindows[j].ZOrderIndex;
                        index = j;
                    }
                }

                dockPanel.DockWindows[dockWindows[index].DockState].BringToFront();
                prevMaxDockWindowZOrder = maxDockWindowZOrder;
            }

            // Create Contents
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = deserializeContent(contents[i].PersistString);
                if (content == null)
                {
                    content = new DummyContent();
                }
                content.DockHandler.DockPanel       = dockPanel;
                content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion;
                content.DockHandler.IsHidden        = true;
                content.DockHandler.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++)
                {
                    IDockableWindow 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.DockHandler.FloatPane = pane;
                    }
                    else
                    {
                        content.DockHandler.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 IDockContent 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]].DockHandler.Pane;
                        int      ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex;
                        DockPane pane2        = dockPanel.Contents[sortedContents[j]].DockHandler.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 IDockContent first to avoid screen flickers
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document)
                {
                    content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            // after all non-document IDockContent, show document IDockContent
            for (int i = 0; i < contents.Length; i++)
            {
                IDockableWindow content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document)
                {
                    content.DockHandler.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].DockHandler.Form.Close();
                }
            }
        }
Пример #13
0
        internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
        {
            if (IsSuspendSetDockState)
            {
                return;
            }

            if (DockPanel == null && visibleState != DockState.Unknown)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("IDockContent.SetDockState.NullPanel"));
            }

            if (visibleState == DockState.Hidden || (visibleState != DockState.Unknown && !IsDockStateValid(visibleState)))
            {
                throw new InvalidOperationException(ResourceHelper.GetString("IDockContent.SetDockState.InvalidState"));
            }

            SuspendSetDockState();

            DockState oldDockState = DockState;

            if (m_isHidden != isHidden || oldDockState == DockState.Unknown)
            {
                m_isHidden = isHidden;
            }
            m_visibleState = visibleState;
            m_dockState    = isHidden ? DockState.Hidden : visibleState;

            if (visibleState == DockState.Unknown)
            {
                Pane = null;
            }
            else
            {
                m_isFloat = (m_visibleState == DockState.Float);

                if (Pane == null)
                {
                    Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true);
                }
                else if (Pane.DockState != visibleState)
                {
                    if (Pane.Contents.Count == 1)
                    {
                        Pane.SetDockState(visibleState);
                    }
                    else
                    {
                        Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true);
                    }
                }
            }

            SetPane(Pane);
            SetVisible();

            if (oldPane != null && !oldPane.IsDisposed && oldDockState == oldPane.DockState)
            {
                RefreshDockPane(oldPane);
            }

            if (Pane != null && DockState == Pane.DockState)
            {
                if ((Pane != oldPane) ||
                    (Pane == oldPane && oldDockState != oldPane.DockState))
                {
                    RefreshDockPane(Pane);
                }
            }

            if (oldDockState != DockState)
            {
                OnDockStateChanged(EventArgs.Empty);
            }

            ResumeSetDockState();
        }
Пример #14
0
 protected override string GetLocalizedString(string key)
 {
     return(ResourceHelper.GetString(key));
 }
Пример #15
0
        private void InternalConstruct(IDockableWindow content, DockState dockState, bool flagBounds, Rectangle floatWindowBounds, DockPane prevPane, DockAlignment alignment, double proportion, bool show)
        {
            if (dockState == DockState.Hidden || dockState == DockState.Unknown)
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPane.DockState.InvalidState"));
            }

            if (content == null)
            {
                throw new ArgumentNullException(ResourceHelper.GetString("DockPane.Constructor.NullContent"));
            }

            if (content.DockHandler.DockPanel == null)
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPane.Constructor.NullDockPanel"));
            }


            SuspendLayout();
            SetStyle(ControlStyles.Selectable, false);

            _isFloat = (dockState == DockState.Float);

            _contents           = new DockContentCollection();
            _displayingContents = new DockContentCollection(this);
            _tabs      = new DockPaneTabCollection(this);
            _dockPanel = content.DockHandler.DockPanel;
            _dockPanel.AddPane(this);

            _splitter = new DockPaneSplitter(this);

            _nestedDockingStatus = new NestedDockingStatus(this);

            _autoHidePane    = DockPanel.AutoHidePaneFactory.CreateAutoHidePane(this);
            _captionControl  = DockPanel.DockPaneCaptionFactory.CreateDockPaneCaption(this);
            _tabStripControl = DockPanel.DockPaneStripFactory.CreateDockPaneStrip(this);
            Controls.AddRange(new Control[] { _captionControl, _tabStripControl });

            DockPanel.SuspendLayout(true);
            if (flagBounds)
            {
                FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this, floatWindowBounds);
            }
            else if (prevPane != null)
            {
                AddToDockList(prevPane.DockListContainer, prevPane, alignment, proportion);
            }

            SetDockState(dockState);
            if (show)
            {
                content.DockHandler.Pane = this;
            }
            else if (this.IsFloat)
            {
                content.DockHandler.FloatPane = this;
            }
            else
            {
                content.DockHandler.PanelPane = this;
            }

            ResumeLayout();
            DockPanel.ResumeLayout(true, true);
        }