ComponentFactory.Krypton.Ribbon.ViewLayoutRibbonGalleryButtons.Layout C# (CSharp) Method

Layout() public method

Perform a layout of the elements.
public Layout ( ViewLayoutContext context ) : void
context ComponentFactory.Krypton.Toolkit.ViewLayoutContext Layout context.
return void
        public override void Layout(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // Validate incoming reference
            if (context == null) throw new ArgumentNullException("context");

            // We take on all the available display area
            ClientRectangle = context.DisplayRectangle;

            // Layout children from top to bottom with equal height and the total width
            int yOffset = 0;
            int childHeight = (ClientHeight / Count) + 1;
            foreach (ViewBase child in this)
            {
                // If this is the last child in collection...
                if (child == this[Count - 1])
                {
                    //...then give it all the remainder space
                    childHeight = ClientHeight - yOffset;
                }

                // Position the child
                context.DisplayRectangle = new Rectangle(ClientLocation.X, yOffset, ClientWidth, childHeight);
                child.Layout(context);

                // Move down to next position
                yOffset += (childHeight - 1);
            }

            // Put back the original display value now we have finished
            context.DisplayRectangle = ClientRectangle;
        }