public override Size GetPreferredSize(ViewLayoutContext context)
{
Size preferredSize = Size.Empty;
// Ensure the control has the correct parent
UpdateParent(context.Control);
if (_currentSize == GroupItemSize.Small)
preferredSize = base.GetPreferredSize(context);
else
{
// If there is a gallery associated then ask for its requested size
if (LastGallery != null)
{
if (ActualVisible(LastGallery))
{
preferredSize = LastGallery.GetPreferredSize(context.DisplayRectangle.Size);
// Add two pixels, one for the left and right edges that will be padded
preferredSize.Width += 2;
}
}
else
preferredSize.Width = NULL_CONTROL_WIDTH;
}
if (_currentSize == GroupItemSize.Large)
preferredSize.Height = _ribbon.CalculatedValues.GroupTripleHeight;
else
preferredSize.Height = _ribbon.CalculatedValues.GroupLineHeight;
return preferredSize;
}