Esempio n. 1
0
        private void RefreshChanges(bool performLayout)
        {
            if (IsDisposed)
            {
                return;
            }

            CaptionControl.RefreshChanges();
            TabStripControl.RefreshChanges();
            if (DockState == DockState.Float && FloatWindow != null)
            {
                FloatWindow.RefreshChanges();
            }
            if (DockHelper.IsDockStateAutoHide(DockState) && DockPanel != null)
            {
                DockPanel.RefreshAutoHideStrip();
                DockPanel.PerformLayout();
            }

            if (performLayout)
            {
                PerformLayout();
            }
        }
        private Rectangle GetLogicalTabStripRectangle(DockState dockState, bool transformed)
        {
            if (!DockHelper.IsDockStateAutoHide(dockState))
            {
                return(Rectangle.Empty);
            }

            int leftPanes   = GetPanes(DockState.DockLeftAutoHide).Count;
            int rightPanes  = GetPanes(DockState.DockRightAutoHide).Count;
            int topPanes    = GetPanes(DockState.DockTopAutoHide).Count;
            int bottomPanes = GetPanes(DockState.DockBottomAutoHide).Count;

            int x, y, width, height;

            height = MeasureHeight();
            if (dockState == DockState.DockLeftAutoHide && leftPanes > 0)
            {
                x     = 0;
                y     = (topPanes == 0) ? 0 : height;
                width = Height - (topPanes == 0 ? 0 : height) - (bottomPanes == 0 ? 0 :height);
            }
            else if (dockState == DockState.DockRightAutoHide && rightPanes > 0)
            {
                x = Width - height;
                if (leftPanes != 0 && x < height)
                {
                    x = height;
                }
                y     = (topPanes == 0) ? 0 : height;
                width = Height - (topPanes == 0 ? 0 : height) - (bottomPanes == 0 ? 0 :height);
            }
            else if (dockState == DockState.DockTopAutoHide && topPanes > 0)
            {
                x     = leftPanes == 0 ? 0 : height;
                y     = 0;
                width = Width - (leftPanes == 0 ? 0 : height) - (rightPanes == 0 ? 0 : height);
            }
            else if (dockState == DockState.DockBottomAutoHide && bottomPanes > 0)
            {
                x = leftPanes == 0 ? 0 : height;
                y = Height - height;
                if (topPanes != 0 && y < height)
                {
                    y = height;
                }
                width = Width - (leftPanes == 0 ? 0 : height) - (rightPanes == 0 ? 0 : height);
            }
            else
            {
                return(Rectangle.Empty);
            }

            if (!transformed)
            {
                return(new Rectangle(x, y, width, height));
            }
            else
            {
                return(GetTransformedRectangle(dockState, new Rectangle(x, y, width, height)));
            }
        }
Esempio n. 3
0
        private void RefreshStateChange(INestedPanesContainer oldContainer, DockState oldDockState)
        {
            lock (this)
            {
                if (IsRefreshStateChangeSuspended)
                {
                    return;
                }

                SuspendRefreshStateChange();
            }

            DockPanel.SuspendLayout(true);

            IDockContent contentFocused = GetFocusedContent();

            if (contentFocused != null)
            {
                DockPanel.SaveFocus();
            }
            SetParent();

            if (ActiveContent != null)
            {
                ActiveContent.DockHandler.SetDockState(ActiveContent.DockHandler.IsHidden, DockState, ActiveContent.DockHandler.Pane);
            }
            foreach (IDockContent content in Contents)
            {
                if (content.DockHandler.Pane == this)
                {
                    content.DockHandler.SetDockState(content.DockHandler.IsHidden, DockState, content.DockHandler.Pane);
                }
            }

            if (oldContainer != null)
            {
                Control oldContainerControl = (Control)oldContainer;
                if (oldContainer.DockState == oldDockState && !oldContainerControl.IsDisposed)
                {
                    oldContainerControl.PerformLayout();
                }
            }
            if (DockHelper.IsDockStateAutoHide(oldDockState))
            {
                DockPanel.RefreshActiveAutoHideContent();
            }

            if (NestedPanesContainer.DockState == DockState)
            {
                ((Control)NestedPanesContainer).PerformLayout();
            }
            if (DockHelper.IsDockStateAutoHide(DockState))
            {
                DockPanel.RefreshActiveAutoHideContent();
            }

            if (DockHelper.IsDockStateAutoHide(oldDockState) ||
                DockHelper.IsDockStateAutoHide(DockState))
            {
                DockPanel.RefreshAutoHideStrip();
                DockPanel.PerformLayout();
            }

            ResumeRefreshStateChange();

            if (contentFocused != null)
            {
                contentFocused.DockHandler.Activate();
            }

            DockPanel.ResumeLayout(true, true);

            if (oldDockState != DockState)
            {
                OnDockStateChanged(EventArgs.Empty);
            }
        }
        internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
        {
            if (IsSuspendSetDockState)
            {
                return;
            }

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

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

            DockPanel dockPanel = DockPanel;

            if (dockPanel != null)
            {
                dockPanel.SuspendLayout(true);
            }

            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);
                    }
                }
            }

            if (Form.ContainsFocus)
            {
                if (DockState == DockState.Hidden || DockState == DockState.Unknown)
                {
                    if (!Win32Helper.IsRunningOnMono)
                    {
                        DockPanel.ContentFocusManager.GiveUpFocus(Content);
                    }
                }
            }

            SetPaneAndVisible(Pane);

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

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

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

                ResetAutoHidePortion(oldDockState, DockState);
                OnDockStateChanged(EventArgs.Empty);
            }

            ResumeSetDockState();

            if (dockPanel != null)
            {
                dockPanel.ResumeLayout(true, true);
            }
        }
Esempio n. 5
0
        internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
        {
            if (IsSuspendSetDockState)
            {
                return;
            }

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

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

            DockPanel dockPanel = DockPanel;

            if (dockPanel != null)
            {
                dockPanel.SuspendLayout(true);
            }

            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);
                    }
                }
            }

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

            SetPaneAndVisible(Pane);

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

            if (Pane != null && DockState == Pane.DockState)
            {
                if ((Pane != oldPane) ||
                    (Pane == oldPane && oldDockState != oldPane.DockState))
                {
                    /*
                     * Without this an early refresh can be triggered while the dimensions of the form
                     * aren't calculated completely because the form could be still hidden although
                     * isHidden says FALSE.
                     */
                    //if (Pane.DockWindow == null || Pane.DockWindow.Visible || Pane.DockState == DockState.Document)
                    RefreshDockPane(Pane);
                }
            }

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

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

            if (dockPanel != null)
            {
                dockPanel.ResumeLayout(true, true);
            }
        }
 private void AutoHide_Click(object sender, EventArgs e)
 {
     DockPane.DockState = DockHelper.ToggleAutoHideState(DockPane.DockState);
 }
            private void TestDrop()
            {
                Outline.FlagTestDrop = false;

                Indicator.FullPanelEdge = ((Control.ModifierKeys & Keys.Shift) != 0);

                DockHelper.CursorPoint cursorPointInfo = DockHelper.CursorPointInformation(DockPanel, DragSource);

                if ((Control.ModifierKeys & Keys.Control) == 0)
                {
                    if (Indicator.Visible == false)
                    {
                        // show indicator when the cursor comes into the dock panel area
                        if (cursorPointInfo.DockPanel != null)
                        {
                            Indicator.Show(false);
                        }
                    }

                    Indicator.TestDrop(cursorPointInfo);

                    if (!Outline.FlagTestDrop)
                    {
                        if (cursorPointInfo.Pane != null && DragSource.IsDockStateValid(cursorPointInfo.Pane.DockState))
                        {
                            cursorPointInfo.Pane.TestDrop(cursorPointInfo, Outline);
                        }
                    }

                    if (!Outline.FlagTestDrop && DragSource.IsDockStateValid(DockState.Float))
                    {
                        if (cursorPointInfo.FloatWindow != null)
                        {
                            cursorPointInfo.FloatWindow.TestDrop(cursorPointInfo, Outline);
                        }
                    }
                }
                else
                {
                    Indicator.DockPane = cursorPointInfo.Pane;
                }

                if (!Outline.FlagTestDrop)
                {
                    Rectangle rect = FloatOutlineBounds;
                    rect.Offset(Control.MousePosition.X - StartMousePosition.X, Control.MousePosition.Y - StartMousePosition.Y);

                    // do not show the outline when a user is moving a floating window
                    if (!(DragSource is FloatWindow) && DragSource.IsDockStateValid(DockState.Float))
                    {
                        Outline.Show(rect, true);
                    }
                    else
                    {
                        Cursor.Current = Cursors.No;
                        Outline.Show(rect, false);
                    }
                }

                if (!Outline.FlagTestDrop)
                {
                }
                else
                {
                    Cursor.Current = DragControl.Cursor;
                }
            }
Esempio n. 8
0
        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))
                {
                    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);
            }
        }