Esempio n. 1
0
        private Rectangle GetWindowSplitterDragRectangle()
        {
            DockState state;
            DockPanel dockPanel;

            DockWindow     dockWindow     = DragControl as DockWindow;
            AutoHideWindow autoHideWindow = DragControl as AutoHideWindow;

            if (dockWindow != null)
            {
                state     = dockWindow.DockState;
                dockPanel = dockWindow.DockPanel;
            }
            else if (autoHideWindow != null)
            {
                state     = autoHideWindow.DockState;
                dockPanel = autoHideWindow.DockPanel;
            }
            else
            {
                return(Rectangle.Empty);
            }

            Rectangle rectLimit = dockPanel.DockArea;
            bool      bVerticalSplitter;

            if (state == DockState.DockLeft || state == DockState.DockRight || state == DockState.DockLeftAutoHide || state == DockState.DockRightAutoHide)
            {
                rectLimit.X      += MeasurePane.MinSize;
                rectLimit.Width  -= 2 * MeasurePane.MinSize;
                rectLimit.Y       = DragControl.Location.Y;
                rectLimit.Height  = DragControl.Height;
                bVerticalSplitter = true;
            }
            else
            {
                rectLimit.Y      += MeasurePane.MinSize;
                rectLimit.Height -= 2 * MeasurePane.MinSize;
                rectLimit.X       = DragControl.Location.X;
                rectLimit.Width   = DragControl.Width;
                bVerticalSplitter = false;
            }

            rectLimit.Location = dockPanel.PointToScreen(rectLimit.Location);

            return(GetSplitterDragRectangle(rectLimit, bVerticalSplitter));
        }
Esempio n. 2
0
        private void DockWindowSplitter_OnEndDrag(bool abort)
        {
            if (abort)
            {
                return;
            }

            DockWindow dockWindow = DragControl as DockWindow;

            if (dockWindow == null)
            {
                return;
            }
            DockPanel dockPanel = dockWindow.DockPanel;
            DockState state     = dockWindow.DockState;

            Point     pt           = m_splitterLocation;
            Rectangle rect         = GetWindowSplitterDragRectangle();
            Rectangle rectDockArea = dockPanel.DockArea;

            if (state == DockState.DockLeft && rectDockArea.Width > 0)
            {
                dockPanel.DockLeftPortion += ((double)rect.X - (double)pt.X) / (double)rectDockArea.Width;
            }
            else if (state == DockState.DockRight && rectDockArea.Width > 0)
            {
                dockPanel.DockRightPortion += ((double)pt.X - (double)rect.X) / (double)rectDockArea.Width;
            }
            else if (state == DockState.DockBottom && rectDockArea.Height > 0)
            {
                dockPanel.DockBottomPortion += ((double)pt.Y - (double)rect.Y) / (double)rectDockArea.Height;
            }
            else if (state == DockState.DockTop && rectDockArea.Height > 0)
            {
                dockPanel.DockTopPortion += ((double)rect.Y - (double)pt.Y) / (double)rectDockArea.Height;
            }
        }