ComponentFactory.Krypton.Docking.KryptonAutoHiddenPanel.GetPreferredSize C# (CSharp) Method

GetPreferredSize() public method

Retrieves the size of a rectangular area into which a control can be fitted.
public GetPreferredSize ( Size proposedSize ) : Size
proposedSize System.Drawing.Size
return System.Drawing.Size
        public override Size GetPreferredSize(Size proposedSize)
        {
            int width = 0;
            int height = 0;
            foreach (KryptonAutoHiddenGroup group in Controls)
            {
                // Only interested in the group if it has some visible pages
                if (group.Pages.VisibleCount > 0)
                {
                    // Find the exact size the child would like to be sized
                    Size groupSize = group.GetPreferredSize(proposedSize);

                    switch (Dock)
                    {
                        case DockStyle.Left:
                        case DockStyle.Right:
                            // We are as wide as the widest child and as tall as heights added together
                            width = Math.Max(width, groupSize.Width);
                            height += groupSize.Height;
                            break;
                        case DockStyle.Top:
                        case DockStyle.Bottom:
                            // We are as tall as the tallest child and as wide as widths added together
                            width += groupSize.Width;
                            height = Math.Max(height, groupSize.Height);
                            break;
                        case DockStyle.None:
                            // We are big enough to show the largest child
                            width = Math.Max(width, groupSize.Width);
                            height = Math.Max(height, groupSize.Height);
                            break;
                    }
                }
            }

            // Add on any padding values but only if we have something to display
            if (width > 0)  width += Padding.Horizontal;
            if (height > 0) height += Padding.Vertical;

            return new Size(width, height);
        }