예제 #1
0
        internal void SetDockState()
        {
            DockState value;

            if (CountOfVisibleContents == 0)
            {
                value = DockState.Unknown;
            }
            else if (IsHidden)
            {
                value = DockState.Hidden;
            }
            else
            {
                value = VisibleState;
            }

            if (m_dockState == value)
            {
                return;
            }

            if (DockManager.ActiveAutoHideContent == ActiveContent &&
                !DockHelper.IsDockStateAutoHide(value))
            {
                bool oldAnimateAutoHide = DockManager.AnimateAutoHide;
                DockManager.AnimateAutoHide       = false;
                DockManager.ActiveAutoHideContent = null;
                DockManager.AnimateAutoHide       = oldAnimateAutoHide;
            }

            DockState oldDockState = m_dockState;

            m_dockState = value;

            if (DockManager.ActiveDocumentWindow == this && value != DockState.Document)
            {
                DockManager.SetActiveDocumentWindow(DockManager.GetContentWindow(DockState.Document));
            }

            if (DockState == DockState.Float)
            {
                if (FloatWindow == null)
                {
                    m_floatWindow = new FloatWindow(DockManager, this);
                }
            }
            else if (DockState == DockState.Document)
            {
                if (TabWindowDocument == null)
                {
                    m_tabWindowDocument = new DocumentWindow(this);
                }
            }
            else if (DockState != DockState.Hidden && DockState != DockState.Unknown)
            {
                if (TabWindowDock == null)
                {
                    m_tabWindowDock = new DockWindow(this);
                }
                TabWindowDock.IsAutoHide = DockHelper.IsDockStateAutoHide(DockState);
            }

            // Temporarily make DockManager invisible to avoid screen flicks
            bool dockManagerVisible = DockManager.Visible;

            DockManager.Hide();
            SetParent(null);

            if (oldDockState == DockState.Float)
            {
                FloatWindow.RefreshContentWindows();
            }
            else
            {
                DockManager.RefreshContentWindows(oldDockState);
            }

            if (DockState == DockState.Float)
            {
                FloatWindow.RefreshContentWindows();
            }
            else
            {
                DockManager.RefreshContentWindows(DockState);
            }

            DockManager.Visible = dockManagerVisible;
            Refresh();

            foreach (Content c in Contents)
            {
                c.SetDockState();
            }

            if (DockHelper.IsValidRestoreState(DockState))
            {
                RestoreState = DockState;
            }

            OnDockStateChanged(EventArgs.Empty);
        }
예제 #2
0
 public bool IsDockStateValid(DockState dockState)
 {
     return(DockHelper.IsDockStateValid(dockState, AllowedStates));
 }
예제 #3
0
        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)));
            }
        }
예제 #4
0
파일: DockPane.cs 프로젝트: perryiv/cadkit
        private void RefreshStateChange(IDockListContainer oldContainer, DockState oldDockState)
        {
            lock (this)
            {
                if (IsRefreshStateChangeSuspended)
                {
                    return;
                }

                SuspendRefreshStateChange();
            }

            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)
            {
                if (oldContainer.DockState == oldDockState && !oldContainer.IsDisposed)
                {
                    ((Control)oldContainer).PerformLayout();
                }
            }
            if (DockHelper.IsDockStateAutoHide(oldDockState))
            {
                DockPanel.AutoHideWindow.RefreshActiveContent();
            }

            if (DockListContainer.DockState == DockState)
            {
                ((Control)DockListContainer).PerformLayout();
            }
            if (DockHelper.IsDockStateAutoHide(DockState))
            {
                DockPanel.AutoHideWindow.RefreshActiveContent();
            }

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

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

            ResumeRefreshStateChange();
        }
예제 #5
0
 /// <include file='CodeDoc\DockContent.xml' path='//CodeDoc/Class[@name="DockContent"]/Method[@name="IsDockStateValid(DockState)"]/*'/>
 public bool IsDockStateValid(DockState dockState)
 {
     return(DockHelper.IsDockStateValid(dockState, DockableAreas));
 }
예제 #6
0
파일: TabWindow.cs 프로젝트: angel2230/ZZZ
        internal virtual void TestDrop(DragHandler dragHandler, Point pt)
        {
            if (DockState == DockState.Document)
            {
                DockManager.TestDrop(dragHandler, pt);
            }

            if (dragHandler.DropTarget.DropTo != null)
            {
                return;
            }

            if (DockHelper.IsDockStateAutoHide(DockState))
            {
                return;
            }

            if (!dragHandler.IsDockStateValid(DockState))
            {
                return;
            }

            if (dragHandler.DragSource == DragHandler.DragSources.FloatWindow &&
                ContentWindow.FloatWindow == dragHandler.DragControl)
            {
                return;
            }

            if (dragHandler.DragSource == DragHandler.DragSources.ContentWindow &&
                dragHandler.DragControl == this)
            {
                return;
            }

            if (dragHandler.DragSource == DragHandler.DragSources.Content &&
                dragHandler.DragControl == this &&
                DockState == DockState.Document &&
                CountOfVisibleContents == 1)
            {
                return;
            }

            Point     ptClient      = PointToClient(pt);
            Rectangle rectTabWindow = TabWindowRectangle;
            int       dragSize      = MeasureContentWindow.DragSize;

            if (ptClient.Y - rectTabWindow.Top >= 0 && ptClient.Y - rectTabWindow.Top < dragSize)
            {
                dragHandler.DropTarget.SetDropTarget(this, DockStyle.Top);
            }
            else if (rectTabWindow.Bottom - ptClient.Y >= 0 && rectTabWindow.Bottom - ptClient.Y < dragSize)
            {
                dragHandler.DropTarget.SetDropTarget(this, DockStyle.Bottom);
            }
            else if (rectTabWindow.Right - ptClient.X >= 0 && rectTabWindow.Right - ptClient.X < dragSize)
            {
                dragHandler.DropTarget.SetDropTarget(this, DockStyle.Right);
            }
            else if (ptClient.X - rectTabWindow.Left >= 0 && ptClient.X - rectTabWindow.Left < dragSize)
            {
                dragHandler.DropTarget.SetDropTarget(this, DockStyle.Left);
            }
            else
            {
                if (rectTabWindow.Height <= GetTabStripRectangle().Height)
                {
                    return;
                }

                HitTestResult hitTestResult = GetHitTest(pt);
                if (hitTestResult.HitArea == HitTestArea.Caption)
                {
                    dragHandler.DropTarget.SetDropTarget(this, -1);
                }
                else if (hitTestResult.HitArea == HitTestArea.TabStrip && hitTestResult.Index != -1)
                {
                    dragHandler.DropTarget.SetDropTarget(this, hitTestResult.Index);
                }
                else if (DockState == DockState.Float && !HasCaption &&
                         ((ptClient.Y - rectTabWindow.Top >= dragSize && ptClient.Y - rectTabWindow.Top < 2 * dragSize) ||
                          (rectTabWindow.Bottom - ptClient.Y >= dragSize && rectTabWindow.Bottom - ptClient.Y < 2 * dragSize) ||
                          (rectTabWindow.Right - ptClient.X >= dragSize && rectTabWindow.Right - ptClient.X < 2 * dragSize) ||
                          (ptClient.X - rectTabWindow.Left >= dragSize && ptClient.X - rectTabWindow.Left < 2 * dragSize)))
                {
                    dragHandler.DropTarget.SetDropTarget(this, -1);
                }
                else
                {
                    return;
                }
            }

            if (dragHandler.DropTarget.SameAsOldValue)
            {
                return;
            }

            dragHandler.DragFrame = GetTestDropDragFrame(dragHandler.DropTarget.Dock, dragHandler.DropTarget.ContentIndex);
        }
예제 #7
0
파일: TabWindow.cs 프로젝트: angel2230/ZZZ
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == (int)Win32.Msgs.WM_NCCALCSIZE)
            {
                Win32.RECT rect = (Win32.RECT)m.GetLParam(typeof(Win32.RECT));
                m_sizeFrame = new Size(rect.right - rect.left, rect.bottom - rect.top);
                base.WndProc(ref m);
                rect.left   += BorderWidth;
                rect.right  -= BorderWidth;
                rect.top    += BorderWidth;
                rect.bottom -= BorderWidth;
                Marshal.StructureToPtr(rect, m.LParam, true);
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCPAINT)
            {
                if (BorderWidth <= 0)
                {
                    return;
                }

                IntPtr    hDC       = User32.GetWindowDC(m.HWnd);
                Graphics  g         = Graphics.FromHdc(hDC);
                Rectangle rectFrame = new Rectangle(0, 0, m_sizeFrame.Width, m_sizeFrame.Height);
                using (Region regionBorder = new Region(rectFrame))
                {
                    regionBorder.Xor(Rectangle.Inflate(rectFrame, -BorderWidth, -BorderWidth));
                    g.FillRegion(SystemBrushes.ControlDark, regionBorder);
                }
                User32.ReleaseDC(m.HWnd, hDC);
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_MOUSEACTIVATE)
            {
                if (!ContentWindow.FlagMouseActivate)
                {
                    ContentWindow.FlagMouseActivate = true;
                    base.WndProc(ref m);
                    ContentWindow.FlagMouseActivate = false;
                    ContentWindow.Activate();
                }
                else
                {
                    base.WndProc(ref m);
                }
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK)
            {
                base.WndProc(ref m);

                HitTestResult hitTestResult = GetHitTest();
                if (hitTestResult.HitArea != HitTestArea.Caption)
                {
                    return;
                }

                if (DockHelper.IsDockStateAutoHide(DockState))
                {
                    DockManager.ActiveAutoHideContent = null;
                    return;
                }

                if (DockHelper.IsDockStateDocked(DockState) && ContentWindow.IsDockStateValid(DockState.Float))
                {
                    ContentWindow.VisibleState = DockState.Float;
                }
                else if (DockState == DockState.Float && ContentWindow.RestoreState != DockState.Unknown &&
                         ContentWindow.IsDockStateValid(ContentWindow.RestoreState))
                {
                    ContentWindow.VisibleState = ContentWindow.RestoreState;
                }

                return;
            }

            base.WndProc(ref m);
            return;
        }