ComponentFactory.Krypton.Docking.KryptonDockingEdgeAutoHidden.FindMovementRect C# (CSharp) Method

FindMovementRect() private method

private FindMovementRect ( Rectangle moveRect ) : Rectangle
moveRect System.Drawing.Rectangle
return System.Drawing.Rectangle
        private Rectangle FindMovementRect(Rectangle moveRect)
        {
            // We never allow the entire client area to covered, so reduce by a fixed size
            Size innerSize = Control.ClientRectangle.Size;
            innerSize.Width -= CLIENT_MINIMUM;
            innerSize.Height -= CLIENT_MINIMUM;

            // Adjust for any showing auto hidden panels at the edges
            foreach (Control child in Control.Controls)
            {
                if (child.Visible && child is KryptonAutoHiddenPanel)
                {
                    switch (child.Dock)
                    {
                        case DockStyle.Left:
                        case DockStyle.Right:
                            innerSize.Width -= child.Width;
                            break;
                        case DockStyle.Top:
                        case DockStyle.Bottom:
                            innerSize.Height -= child.Height;
                            break;
                    }
                }
            }

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

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

            // Create movement rectangle based on the initial rectangle and the allowed range
            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;
        }