ComponentFactory.Krypton.Toolkit.ViewComposite.GetPreferredSize C# (CSharp) Method

GetPreferredSize() public method

Discover the preferred size of the element.
public GetPreferredSize ( ViewLayoutContext context ) : Size
context ViewLayoutContext Layout context.
return System.Drawing.Size
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // As a composite we have no preferred size ourself
            Size preferredSize = Size.Empty;

            foreach (ViewBase child in this)
            {
                // Only investigate visible children
                if (child.Visible)
                {
                    // Ask child for it's own preferred size
                    Size childPreferred = child.GetPreferredSize(context);

                    // As a composite we need to be big enough to encompass the largest child
                    if (childPreferred.Width > preferredSize.Width)
                        preferredSize.Width = childPreferred.Width;

                    if (childPreferred.Height > preferredSize.Height)
                        preferredSize.Height = childPreferred.Height;
                }
            }

            return preferredSize;
        }