public override void Layout(ViewLayoutContext context)
{
// Take on all the provided area
ClientRectangle = context.DisplayRectangle;
// Get the size of the radio button when it is drawn
Rectangle radioButtonRect = new Rectangle(Point.Empty, _drawRadioButton.GetPreferredSize(context));
// Decide on correct position within our rectangle
if (_large)
{
// Place horizontal centered at the bottom of area
radioButtonRect.X = ClientLocation.X + (ClientWidth - radioButtonRect.Width) / 2;
radioButtonRect.Y = ClientRectangle.Bottom - radioButtonRect.Height;
}
else
{
// Place vertically centered at the right of area
radioButtonRect.X = ClientRectangle.Right - radioButtonRect.Width;
radioButtonRect.Y = ClientLocation.Y + (ClientHeight - radioButtonRect.Height) / 2;
}
// Layout the radio button draw element
context.DisplayRectangle = radioButtonRect;
_drawRadioButton.Layout(context);
context.DisplayRectangle = ClientRectangle;
}