public override void Layout(ViewLayoutContext context)
{
// Cache the provided size of our area
Rectangle clientRect = context.DisplayRectangle;
// If we are in the ribbon caption area line
if (OwnerForm == null)
{
// Limit the width, so we do not flow over right edge of caption area
int maxWidth = _ribbon.Width - clientRect.X;
clientRect.Width = Math.Min(clientRect.Width, maxWidth);
}
// Update with modified value
context.DisplayRectangle = clientRect;
// Let base class layout all contents
base.Layout(context);
// Only if border is visible do we need to find the latest overflow value
// otherwise it must be a customization image because there are no buttons
if (_border.Visible)
_extraButton.Overflow = _borderContents.Overflow;
else
_extraButton.Overflow = false;
}