ComponentFactory.Krypton.Ribbon.ViewLayoutRibbonGalleryButtons.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)
        {
            Size preferredSize = Size.Empty;

            // Height is the total height of all children, but width is just the widest found
            foreach (ViewBase child in this)
            {
                // Ask child for it's own preferred size
                Size childPreferred = child.GetPreferredSize(context);

                // Always add on the height of the child
                preferredSize.Height += childPreferred.Width;

                // Find the widest of the children
                preferredSize.Width = Math.Max(preferredSize.Width, childPreferred.Width);
            }

            return preferredSize;
        }