Esempio n. 1
0
        private Rectangle GetContainerDragDrawRectangle(DockControlContainer container, Point pointInScreen)
        {
            Point     pointInControl     = container.PointToClient(pointInScreen);
            Rectangle clientRectangle    = container.ClientRectangle;
            Rectangle rectangleToDraw    = Rectangle.Empty;
            Rectangle containerRectangle = container.RectangleToScreen(container.ClientRectangle);

            switch (container.Dock)
            {
            case DockStyle.Top:
            case DockStyle.Bottom:
                if (pointInControl.Y > clientRectangle.Y && pointInControl.Y < clientRectangle.Y + DockingBarSize)
                {
                    rectangleToDraw        = containerRectangle;
                    rectangleToDraw.Height = DockingBarSize;
                }
                else if (pointInControl.Y < clientRectangle.Bottom && pointInControl.Y > clientRectangle.Bottom - DockingBarSize)
                {
                    rectangleToDraw        = containerRectangle;
                    rectangleToDraw.Y      = containerRectangle.Bottom - DockingBarSize;
                    rectangleToDraw.Height = DockingBarSize;
                }

                break;

            case DockStyle.Left:
            case DockStyle.Right:
                if (pointInControl.X > clientRectangle.X && pointInControl.X < clientRectangle.X + DockingBarSize)
                {
                    rectangleToDraw       = containerRectangle;
                    rectangleToDraw.Width = DockingBarSize;
                }
                else if (pointInControl.X < clientRectangle.Right && pointInControl.X > clientRectangle.Right - DockingBarSize)
                {
                    rectangleToDraw       = containerRectangle;
                    rectangleToDraw.X     = containerRectangle.Right - DockingBarSize;
                    rectangleToDraw.Width = DockingBarSize;
                }

                break;

            default:
                break;
            }

            return(rectangleToDraw);
        }
Esempio n. 2
0
        private void _toolStripCaption_CaptionDrag(object sender, MouseEventArgs e)
        {
            Point pointInScreen            = this.PointToScreen(e.Location);
            DockControlContainer container = _manager.GetContainerAtPoint(_manager.PointToClient(pointInScreen));

            if (container == null)
            {
                Rectangle dragRectangle = DockControlHelpers.GetDropXorDragRect(_manager, pointInScreen, DockingBarSize);

                if (!dragRectangle.IsEmpty)
                {
                    _dragger.SetRectangle(_manager.RectangleToScreen(dragRectangle));
                    return;
                }
            }
            else
            {
                Rectangle rectangleToDraw = GetContainerDragDrawRectangle(container, pointInScreen);

                if (!rectangleToDraw.IsEmpty)
                {
                    _dragger.SetRectangle(rectangleToDraw);
                    return;
                }

                if (container.Tabbed)
                {
                    _dragger.SetRectangle(container.RectangleToScreen(container.ClientRectangle));
                    return;
                }
                else
                {
                    DockingControl control = container.GetDockingControlAtPoint(container.PointToClient(pointInScreen));

                    if (control != null)
                    {
                        Point pointInControl = control.PointToClient(pointInScreen);
                        rectangleToDraw = GetContolDragDrawRectangle(container, control, pointInControl);
                        _dragger.SetRectangle(control.RectangleToScreen(rectangleToDraw));
                        return;
                    }
                }
            }

            _dragger.MoveTo(e.Location);
        }
Esempio n. 3
0
        private Rectangle GetContolDragDrawRectangle(DockControlContainer container, DockingControl control, Point pointInControl)
        {
            Rectangle rectangleToDraw = Rectangle.Empty;

            Rectangle containerRectangle = control.RectangleToClient(container.RectangleToScreen(container.ClientRectangle));
            Rectangle clientRectangle    = control.ClientRectangle;

            int index = container.DockedControlList.IndexOf(control);

            DockingControl controlBefore = GetControlBefore(container, index);
            DockingControl controlAfter  = GetControlAfter(container, index);

            Rectangle bounds       = control.Bounds;
            Rectangle beforeBounds = (controlBefore == null) ? Rectangle.Empty : controlBefore.Bounds;
            Rectangle afterBounds  = (controlAfter == null) ? Rectangle.Empty : controlAfter.Bounds;

            switch (container.Dock)
            {
            case DockStyle.Left:
            case DockStyle.Right:
                if (container.Tabbed)
                {
                    rectangleToDraw = clientRectangle;
                }
                else if (pointInControl.Y < clientRectangle.Y + (clientRectangle.Height / 2))
                {
                    if (controlBefore == null)
                    {
                        rectangleToDraw         = clientRectangle;
                        rectangleToDraw.Height /= 2;
                    }
                    else
                    {
                        rectangleToDraw = new Rectangle(
                            beforeBounds.Left, beforeBounds.Top + (beforeBounds.Height / 2),
                            beforeBounds.Right, (bounds.Top + (bounds.Height / 2)) - (beforeBounds.Top + (beforeBounds.Height / 2)));

                        rectangleToDraw = control.RectangleToClient(container.RectangleToScreen(rectangleToDraw));
                    }
                }
                else
                {
                    if (controlAfter == null)
                    {
                        rectangleToDraw         = clientRectangle;
                        rectangleToDraw.Y       = clientRectangle.Bottom - (clientRectangle.Height / 2);
                        rectangleToDraw.Height /= 2;
                    }
                    else
                    {
                        rectangleToDraw = new Rectangle(
                            bounds.Left, bounds.Top + (bounds.Height / 2),
                            bounds.Right, (afterBounds.Top + (afterBounds.Height / 2)) - (bounds.Top + (bounds.Height / 2)));

                        rectangleToDraw = control.RectangleToClient(container.RectangleToScreen(rectangleToDraw));
                    }
                }

                break;

            case DockStyle.Bottom:
            case DockStyle.Top:
                if (container.Tabbed)
                {
                    rectangleToDraw = clientRectangle;
                }
                else if (pointInControl.X < clientRectangle.X + (clientRectangle.Width / 2))
                {
                    if (controlBefore == null)
                    {
                        rectangleToDraw        = clientRectangle;
                        rectangleToDraw.Width /= 2;
                    }
                    else
                    {
                        rectangleToDraw = new Rectangle(
                            beforeBounds.Left + (beforeBounds.Width / 2), beforeBounds.Top,
                            (bounds.Left + (bounds.Width / 2)) - (beforeBounds.Left + (beforeBounds.Width / 2)), beforeBounds.Height);

                        rectangleToDraw = control.RectangleToClient(container.RectangleToScreen(rectangleToDraw));
                    }
                }
                else
                {
                    if (controlAfter == null)
                    {
                        rectangleToDraw        = clientRectangle;
                        rectangleToDraw.X      = clientRectangle.Right - (clientRectangle.Width / 2);
                        rectangleToDraw.Width /= 2;
                    }
                    else
                    {
                        rectangleToDraw = new Rectangle(
                            bounds.Left + (bounds.Width / 2), bounds.Top,
                            (afterBounds.Left + (afterBounds.Width / 2)) - (bounds.Left + (bounds.Width / 2)), bounds.Height);

                        rectangleToDraw = control.RectangleToClient(container.RectangleToScreen(rectangleToDraw));
                    }
                }

                break;

            default:
                break;
            }

            return(rectangleToDraw);
        }