ComponentFactory.Krypton.Ribbon.ViewLayoutRibbonGalleryItems.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)
        {
            Debug.Assert(context != null);

            // Ensure that the correct number of children are created
            SyncChildren();

            Size preferredSize = Size.Empty;

            // Find size of the first item, if there is one
            if (Count > 0)
            {
                // Ask child for it's own preferred size
                preferredSize = this[0].GetPreferredSize(context);

                // Find preferred size from the preferred item size
                preferredSize.Width *= _gallery.PreferredItemSize.Width;
                preferredSize.Height *= _gallery.PreferredItemSize.Height;
            }

            // Add on the requests padding
            preferredSize.Width += _gallery.Padding.Horizontal;
            preferredSize.Height += _gallery.Padding.Vertical;

            return preferredSize;
        }