InnerRectangle() public static method

Find the inner space that occupied by the edge docking controls.
public static InnerRectangle ( Control c ) : Rectangle
c System.Windows.Forms.Control Reference to control.
return System.Drawing.Rectangle
コード例 #1
0
        private void EnforceInnerMinimum()
        {
            // Find the available inner rectangle of our containing control
            Rectangle innerRect = DockingHelper.InnerRectangle(Control);

            // Do we need to adjust the left/right edge controls?
            if (innerRect.Width < InnerMinimum.Width)
            {
                EnforceInnerMinimum(InnerMinimum.Width - innerRect.Width, Orientation.Horizontal);
            }

            // Do we need to adjust the top/bottom edge controls?
            if (innerRect.Height < InnerMinimum.Height)
            {
                EnforceInnerMinimum(InnerMinimum.Height - innerRect.Height, Orientation.Vertical);
            }
        }
コード例 #2
0
        private Rectangle FindMovementRect(KryptonDockingDockspace dockspaceElement, Rectangle moveRect)
        {
            // Find the available inner rectangle of our containing control
            Rectangle innerRect = DockingHelper.InnerRectangle(Control);

            // How much can we reduce the width/height of the dockspace to reach the minimum
            Size dockspaceMinimum = dockspaceElement.DockspaceControl.MinimumSize;
            int  reduceWidth      = Math.Max(dockspaceElement.DockspaceControl.Width - dockspaceMinimum.Width, 0);
            int  reduceHeight     = Math.Max(dockspaceElement.DockspaceControl.Height - dockspaceMinimum.Height, 0);

            // Get the minimum size requested for the inner area of the control
            Size innerMinimum = Size.Empty;

            if (GetParentType(typeof(KryptonDockingControl)) is KryptonDockingControl dockingControl)
            {
                innerMinimum = dockingControl.InnerMinimum;
            }

            // How much can we expand the width/height of the dockspace to reach the inner minimum
            int expandWidth  = Math.Max(innerRect.Width - innerMinimum.Width, 0);
            int expandHeight = Math.Max(innerRect.Height - innerMinimum.Height, 0);

            // Limit check we are not growing bigger than the maximum allowed
            Size dockspaceMaximum = dockspaceElement.DockspaceControl.MaximumSize;

            if (dockspaceMaximum.Width > 0)
            {
                expandWidth = Math.Min(expandWidth, dockspaceMaximum.Width);
            }

            if (dockspaceMaximum.Height > 0)
            {
                expandHeight = Math.Min(expandHeight, dockspaceMaximum.Height);
            }

            // Allow movement rectangle to extend inwards according to inner rectangle and outwards according to dockspace size
            Rectangle retRect = Rectangle.Empty;

            switch (Edge)
            {
            case DockingEdge.Left:
                retRect = new Rectangle(moveRect.X - reduceWidth, moveRect.Y, moveRect.Width + reduceWidth + expandWidth, moveRect.Height);
                break;

            case DockingEdge.Right:
                retRect = new Rectangle(moveRect.X - expandWidth, moveRect.Y, moveRect.Width + reduceWidth + expandWidth, moveRect.Height);
                break;

            case DockingEdge.Top:
                retRect = new Rectangle(moveRect.X, moveRect.Y - reduceHeight, moveRect.Width, moveRect.Height + reduceHeight + expandHeight);
                break;

            case DockingEdge.Bottom:
                retRect = new Rectangle(moveRect.X, moveRect.Y - expandHeight, moveRect.Width, moveRect.Height + reduceHeight + expandHeight);
                break;
            }

            // We do not allow negative width/height
            retRect.Width  = Math.Max(retRect.Width, 0);
            retRect.Height = Math.Max(retRect.Height, 0);

            return(retRect);
        }