ComponentFactory.Krypton.Ribbon.ViewDrawRibbonQATBorder.GetPreferredSize C# (CSharp) Method

GetPreferredSize() public method

Discover the preferred size of the element.
public GetPreferredSize ( ViewLayoutContext context ) : Size
context ComponentFactory.Krypton.Toolkit.ViewLayoutContext Layout context.
return System.Drawing.Size
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            // Get size of the contained items
            Size preferredSize = base.GetPreferredSize(context);

            // Add on the border padding
            preferredSize = CommonHelper.ApplyPadding(Orientation.Horizontal, preferredSize, BarPadding);
            preferredSize.Height = Math.Max(preferredSize.Height, BarHeight);

            // If we are inside the custom chrome area
            if (OwnerForm != null)
            {
                // Calculate the maximum width allowed
                int maxWidth = ((OwnerForm.Width - 100) / 3) * 2;

                // Adjust so the width is a multiple of a button size
                int buttons = (maxWidth - BarPadding.Horizontal) / QAT_BUTTON_WIDTH;
                maxWidth = (buttons * QAT_BUTTON_WIDTH) + BarPadding.Horizontal;

                preferredSize.Width = Math.Min(maxWidth, preferredSize.Width);
            }

            return preferredSize;
        }