Inheritance: System.Windows.Forms.UserControl, IDockDragSource
Esempio n. 1
0
        public void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex)
        {
            if (dockStyle == DockStyle.Fill)
            {
                for (int i = this.NestedPanes.Count - 1; i >= 0; i--)
                {
                    DockPane paneFrom = this.NestedPanes[i];
                    for (int j = paneFrom.Contents.Count - 1; j >= 0; j--)
                    {
                        IDockContent c = paneFrom.Contents[j];
                        c.DockHandler.Pane = pane;
                        if (contentIndex != -1)
                            pane.SetContentIndex(c, contentIndex);
                        c.DockHandler.Activate();
                    }
                }
            }
            else
            {
                var alignment = DockAlignment.Left;
                if (dockStyle == DockStyle.Left)
                    alignment = DockAlignment.Left;
                else if (dockStyle == DockStyle.Right)
                    alignment = DockAlignment.Right;
                else if (dockStyle == DockStyle.Top)
                    alignment = DockAlignment.Top;
                else if (dockStyle == DockStyle.Bottom)
                    alignment = DockAlignment.Bottom;

                MergeNestedPanes(this.VisibleNestedPanes, pane.NestedPanesContainer.NestedPanes, pane, alignment, 0.5);
            }
        }
        protected internal DockPaneCaptionBase(DockPane pane)
        {
            this._mDockPane = pane;

            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.ResizeRedraw |
                ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.Selectable, false);
        }
        public VS2005DockPaneCaption(DockPane pane)
            : base(pane)
        {
            SuspendLayout();

            this.m_components = new Container();
            this.m_toolTip = new ToolTip(this.Components);

            ResumeLayout();
        }
        public VS2005DockPaneStrip(DockPane pane)
            : base(pane)
        {
            SetStyle(ControlStyles.ResizeRedraw |
                ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.OptimizedDoubleBuffer, true);

            SuspendLayout();

            this.m_components = new Container();
            this.m_toolTip = new ToolTip(this.Components);
            this.m_selectMenu = new ContextMenuStrip(this.Components);

            ResumeLayout();
        }
Esempio n. 5
0
 public void Show(DockPane pane, DockStyle dock)
 {
     this.SaveOldValues();
     this.SetValues(Rectangle.Empty, pane, dock, -1);
     this.TestChange();
 }
Esempio n. 6
0
 protected internal DockPane(IDockContent content, DockPane previousPane, DockAlignment alignment, double proportion, bool show)
 {
     if (previousPane == null)
         throw (new ArgumentNullException("previousPane"));
     this.InternalConstruct(content, previousPane.DockState, false, Rectangle.Empty, previousPane, alignment, proportion, show);
 }
Esempio n. 7
0
        public DockPane DockTo(INestedPanesContainer container, DockPane previousPane, DockAlignment alignment, double proportion)
        {
            if (container == null)
                throw new InvalidOperationException(Strings.DockPane_DockTo_NullContainer);

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

            IDockContent firstContent = this.GetFirstContent(container.DockState);
            if (firstContent == null)
                return null;

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

            pane.DockTo(container, previousPane, alignment, proportion);
            this.SetVisibleContentsToPane(pane);
            this.DockPanel.DummyContent.DockPanel = null;

            return pane;
        }
Esempio n. 8
0
 private void SetVisibleContentsToPane(DockPane pane)
 {
     this.SetVisibleContentsToPane(pane, this.ActiveContent);
 }
Esempio n. 9
0
        private void InternalAddToDockList(INestedPanesContainer container, DockPane prevPane, DockAlignment alignment, double proportion)
        {
            if ((container.DockState == DockState.Float) != this.IsFloat)
                throw new InvalidOperationException(Strings.DockPane_DockTo_InvalidContainer);

            int count = container.NestedPanes.Count;
            if (container.NestedPanes.Contains(this))
                count--;
            if (prevPane == null && count > 0)
                throw new InvalidOperationException(Strings.DockPane_DockTo_NullPrevPane);

            if (prevPane != null && !container.NestedPanes.Contains(prevPane))
                throw new InvalidOperationException(Strings.DockPane_DockTo_NoPrevPane);

            if (prevPane == this)
                throw new InvalidOperationException(Strings.DockPane_DockTo_SelfPrevPane);

            INestedPanesContainer oldContainer = this.NestedPanesContainer;
            DockState oldDockState = this.DockState;
            container.NestedPanes.Add(this);
            this.NestedDockingStatus.SetStatus(container.NestedPanes, prevPane, alignment, proportion);

            if (DockHelper.IsDockWindowState(this.DockState))
                this.m_dockState = container.DockState;

            this.RefreshStateChange(oldContainer, oldDockState);
        }
 private static void RefreshDockPane(DockPane pane)
 {
     pane.RefreshChanges();
     pane.ValidateActiveContent();
 }
Esempio n. 11
0
        private void InternalConstruct(DockPanel dockPanel, DockPane pane, bool boundsSpecified, Rectangle bounds)
        {
            if (dockPanel == null)
                throw (new ArgumentNullException(Strings.FloatWindow_Constructor_NullDockPanel));

            this.m_nestedPanes = new NestedPaneCollection(this);

            FormBorderStyle = FormBorderStyle.SizableToolWindow;
            ShowInTaskbar = false;
            if (dockPanel.RightToLeft != RightToLeft)
                RightToLeft = dockPanel.RightToLeft;
            if (RightToLeftLayout != dockPanel.RightToLeftLayout)
                RightToLeftLayout = dockPanel.RightToLeftLayout;

            SuspendLayout();

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

            if (pane != null)
                pane.FloatWindow = this;

            this.m_dockPanel = dockPanel;
            Owner = this.DockPanel.FindForm();

            Size = bounds.Size;
            // Suspend child controls from resizing every pixel
            ResizeBegin += (s, e) => SuspendLayout();
            ResizeEnd += (s, e) => ResumeLayout(true);

            this.DockPanel.AddFloatWindow(this);

            ResumeLayout();
        }
Esempio n. 12
0
        private static void MergeNestedPanes(VisibleNestedPaneCollection nestedPanesFrom, NestedPaneCollection nestedPanesTo, DockPane prevPane, DockAlignment alignment, double proportion)
        {
            if (nestedPanesFrom.Count == 0)
                return;

            int count = nestedPanesFrom.Count;
            var panes = new DockPane[count];
            var prevPanes = new DockPane[count];
            var alignments = new DockAlignment[count];
            var proportions = new double[count];

            for (int i = 0; i < count; i++)
            {
                panes[i] = nestedPanesFrom[i];
                prevPanes[i] = nestedPanesFrom[i].NestedDockingStatus.PreviousPane;
                alignments[i] = nestedPanesFrom[i].NestedDockingStatus.Alignment;
                proportions[i] = nestedPanesFrom[i].NestedDockingStatus.Proportion;
            }

            DockPane pane = panes[0].DockTo(nestedPanesTo.Container, prevPane, alignment, proportion);
            panes[0].DockState = nestedPanesTo.DockState;

            for (int i = 1; i < count; i++)
            {
                for (int j = i; j < count; j++)
                {
                    if (prevPanes[j] == panes[i - 1])
                        prevPanes[j] = pane;
                }
                pane = panes[i].DockTo(nestedPanesTo.Container, prevPanes[i], alignments[i], proportions[i]);
                panes[i].DockState = nestedPanesTo.DockState;
            }
        }
Esempio n. 13
0
 protected internal FloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds)
 {
     this.InternalConstruct(dockPanel, pane, true, bounds);
 }
Esempio n. 14
0
 protected internal FloatWindow(DockPanel dockPanel, DockPane pane)
 {
     this.InternalConstruct(dockPanel, pane, false, Rectangle.Empty);
 }
Esempio n. 15
0
 public void Show(DockPane previousPane, DockAlignment alignment, double proportion)
 {
     this.DockHandler.Show(previousPane, alignment, proportion);
 }
        internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
        {
            if (this.IsSuspendSetDockState)
                return;

            if (this.DockPanel == null && visibleState != DockState.Unknown)
                throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_NullPanel);

            if (visibleState == DockState.Hidden || (visibleState != DockState.Unknown && !this.IsDockStateValid(visibleState)))
                throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_InvalidState);

            DockPanel dockPanel = this.DockPanel;
            if (dockPanel != null)
                dockPanel.SuspendLayout(true);

            this.SuspendSetDockState();

            DockState oldDockState = this.DockState;

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

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

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

            if (this.Form.ContainsFocus)
                if (this.DockState == DockState.Hidden || this.DockState == DockState.Unknown)
                    this.DockPanel.ContentFocusManager.GiveUpFocus(this.Content);

            this.SetPaneAndVisible(this.Pane);

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

            if (this.Pane != null && this.DockState == this.Pane.DockState)
            {
                if ((this.Pane != oldPane) ||
                    (this.Pane == oldPane && oldDockState != oldPane.DockState))
                    // Avoid early refresh of hidden AutoHide panes
                    if ((this.Pane.DockWindow == null || this.Pane.DockWindow.Visible || this.Pane.IsHidden) && !this.Pane.IsAutoHide)
                        RefreshDockPane(this.Pane);
            }

            if (oldDockState != this.DockState)
            {
                if (this.DockState == DockState.Hidden || this.DockState == DockState.Unknown ||
                    DockHelper.IsDockStateAutoHide(this.DockState))
                    this.DockPanel.ContentFocusManager.RemoveFromList(this.Content);
                else
                    this.DockPanel.ContentFocusManager.AddToList(this.Content);

                this.OnDockStateChanged(EventArgs.Empty);
            }
            this.ResumeSetDockState();

            if (dockPanel != null)
                dockPanel.ResumeLayout(true, true);
        }
 internal void SetPaneAndVisible(DockPane pane)
 {
     this.SetPane(pane);
     this.SetVisible();
 }
 private void RemoveFromPane(DockPane pane)
 {
     pane.RemoveContent(this.Content);
     this.SetPane(null);
     if (pane.Contents.Count == 0)
         pane.Dispose();
 }
            private void SetActivePane()
            {
                DockPane value = (this.ActiveContent == null ? null : this.ActiveContent.DockHandler.Pane);

                if (value == this.m_activePane)
                    return;

                this.m_activePane = value;
            }
 private void ResumeSetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
 {
     this.ResumeSetDockState();
     this.SetDockState(isHidden, visibleState, oldPane);
 }
Esempio n. 21
0
        private void InternalConstruct(IDockContent 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(Strings.DockPane_SetDockState_InvalidState);

            if (content == null)
                throw new ArgumentNullException(Strings.DockPane_Constructor_NullContent);

            if (content.DockHandler.DockPanel == null)
                throw new ArgumentException(Strings.DockPane_Constructor_NullDockPanel);

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

            this.m_isFloat = (dockState == DockState.Float);

            this.m_contents = new DockContentCollection();
            this.m_displayingContents = new DockContentCollection(this);
            this.m_dockPanel = content.DockHandler.DockPanel;
            this.m_dockPanel.AddPane(this);

            this.m_splitter = new SplitterControl(this);

            this.m_nestedDockingStatus = new NestedDockingStatus(this);

            this.m_captionControl = this.DockPanel.DockPaneCaptionFactory.CreateDockPaneCaption(this);
            this.m_tabStripControl = this.DockPanel.DockPaneStripFactory.CreateDockPaneStrip(this);
            Controls.AddRange(new Control[] { this.m_captionControl, this.m_tabStripControl });

            this.DockPanel.SuspendLayout(true);
            if (flagBounds)
                this.FloatWindow = this.DockPanel.FloatWindowFactory.CreateFloatWindow(this.DockPanel, this, floatWindowBounds);
            else if (prevPane != null)
                this.DockTo(prevPane.NestedPanesContainer, prevPane, alignment, proportion);

            this.SetDockState(dockState);
            if (show)
            {
                content.DockHandler.Pane = this;
                if (this.IsFloat)
                {
                    Size size = (content as DockContent).DefaultFloatSize;
                    int x = (Screen.PrimaryScreen.Bounds.Width - size.Width) / 2;
                    int y = (Screen.PrimaryScreen.Bounds.Height - size.Height) / 2;
                    this.FloatWindow.Bounds = new Rectangle(new Point(x, y), size);
                }
            }
            else if (this.IsFloat)
                content.DockHandler.FloatPane = this;
            else
                content.DockHandler.PanelPane = this;

            ResumeLayout();
            this.DockPanel.ResumeLayout(true, true);
        }
 private void SetPane(DockPane pane)
 {
     if (pane != null && pane.DockState == DockState.Document && this.DockPanel.DocumentStyle == DocumentStyle.DockingMdi)
     {
         if (this.Form.Parent is DockPane)
             this.SetParent(null);
         if (this.Form.MdiParent != this.DockPanel.ParentForm)
         {
             this.FlagClipWindow = true;
             this.Form.MdiParent = this.DockPanel.ParentForm;
         }
     }
     else
     {
         this.FlagClipWindow = true;
         if (this.Form.MdiParent != null)
             this.Form.MdiParent = null;
         if (this.Form.TopLevel)
             this.Form.TopLevel = false;
         this.SetParent(pane);
     }
 }
Esempio n. 23
0
        private void SetVisibleContentsToPane(DockPane pane, IDockContent activeContent)
        {
            for (int i = 0; i < this.DisplayingContents.Count; i++)
            {
                IDockContent content = this.DisplayingContents[i];
                if (content.DockHandler.IsDockStateValid(pane.DockState))
                {
                    content.DockHandler.Pane = pane;
                    i--;
                }
            }

            if (activeContent.DockHandler.Pane == pane)
                pane.ActiveContent = activeContent;
        }
        public void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex)
        {
            if (dockStyle == DockStyle.Fill)
            {
                bool samePane = (this.Pane == pane);
                if (!samePane)
                    this.Pane = pane;

                if (contentIndex == -1 || !samePane)
                    pane.SetContentIndex(this.Content, contentIndex);
                else
                {
                    DockContentCollection contents = pane.Contents;
                    int oldIndex = contents.IndexOf(this.Content);
                    int newIndex = contentIndex;
                    if (oldIndex < newIndex)
                    {
                        newIndex += 1;
                        if (newIndex > contents.Count - 1)
                            newIndex = -1;
                    }
                    pane.SetContentIndex(this.Content, newIndex);
                }
            }
            else
            {
                DockPane paneFrom = this.DockPanel.DockPaneFactory.CreateDockPane(this.Content, pane.DockState, true);
                INestedPanesContainer container = pane.NestedPanesContainer;
                if (dockStyle == DockStyle.Left)
                    paneFrom.DockTo(container, pane, DockAlignment.Left, 0.5);
                else if (dockStyle == DockStyle.Right)
                    paneFrom.DockTo(container, pane, DockAlignment.Right, 0.5);
                else if (dockStyle == DockStyle.Top)
                    paneFrom.DockTo(container, pane, DockAlignment.Top, 0.5);
                else if (dockStyle == DockStyle.Bottom)
                    paneFrom.DockTo(container, pane, DockAlignment.Bottom, 0.5);

                paneFrom.DockState = pane.DockState;
            }
        }
Esempio n. 25
0
        public void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex)
        {
            if (dockStyle == DockStyle.Fill)
            {
                IDockContent activeContent = this.ActiveContent;
                for (int i = this.Contents.Count - 1; i >= 0; i--)
                {
                    IDockContent c = this.Contents[i];
                    if (c.DockHandler.DockState == this.DockState)
                    {
                        c.DockHandler.Pane = pane;
                        if (contentIndex != -1)
                            pane.SetContentIndex(c, contentIndex);
                    }
                }
                pane.ActiveContent = activeContent;
            }
            else
            {
                if (dockStyle == DockStyle.Left)
                    this.DockTo(pane.NestedPanesContainer, pane, DockAlignment.Left, 0.5);
                else if (dockStyle == DockStyle.Right)
                    this.DockTo(pane.NestedPanesContainer, pane, DockAlignment.Right, 0.5);
                else if (dockStyle == DockStyle.Top)
                    this.DockTo(pane.NestedPanesContainer, pane, DockAlignment.Top, 0.5);
                else if (dockStyle == DockStyle.Bottom)
                    this.DockTo(pane.NestedPanesContainer, pane, DockAlignment.Bottom, 0.5);

                this.DockState = pane.DockState;
            }
        }
        bool IDockDragSource.CanDockTo(DockPane pane)
        {
            if (!this.IsDockStateValid(pane.DockState))
                return false;

            if (this.Pane == pane && pane.DisplayingContents.Count == 1)
                return false;

            return true;
        }
Esempio n. 27
0
        bool IDockDragSource.CanDockTo(DockPane pane)
        {
            if (!this.IsDockStateValid(pane.DockState))
                return false;

            if (pane == this)
                return false;

            return true;
        }
        public void Show(DockPane pane, IDockContent beforeContent)
        {
            if (pane == null)
                throw (new ArgumentNullException(Strings.DockContentHandler_Show_NullPane));

            if (beforeContent != null && pane.Contents.IndexOf(beforeContent) == -1)
                throw (new ArgumentException(Strings.DockContentHandler_Show_InvalidBeforeContent));

            pane.DockPanel.SuspendLayout(true);

            this.DockPanel = pane.DockPanel;
            this.Pane = pane;
            pane.SetContentIndex(this.Content, pane.Contents.IndexOf(beforeContent));
            this.Show();

            pane.DockPanel.ResumeLayout(true, true);
        }
Esempio n. 29
0
 public void Show(DockPane pane, int contentIndex)
 {
     this.SaveOldValues();
     this.SetValues(Rectangle.Empty, pane, DockStyle.Fill, contentIndex);
     this.TestChange();
 }
        public void Show(DockPane previousPane, DockAlignment alignment, double proportion)
        {
            if (previousPane == null)
                throw (new ArgumentException(Strings.DockContentHandler_Show_InvalidPrevPane));

            if (DockHelper.IsDockStateAutoHide(previousPane.DockState))
                throw (new ArgumentException(Strings.DockContentHandler_Show_InvalidPrevPane));

            previousPane.DockPanel.SuspendLayout(true);

            this.DockPanel = previousPane.DockPanel;
            this.DockPanel.DockPaneFactory.CreateDockPane(this.Content, previousPane, alignment, proportion, true);
            this.Show();

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