public override void DrawCheckBox(RenderContext context,
Rectangle displayRect,
IPalette palette,
bool enabled,
CheckState checkState,
bool tracking,
bool pressed)
{
Debug.Assert(context != null);
Debug.Assert(palette != null);
// Validate parameter references
if (context == null) throw new ArgumentNullException("context");
if (palette == null) throw new ArgumentNullException("palette");
// Grab an image appropriate to the state
Image drawImage = palette.GetCheckBoxImage(enabled, checkState, tracking, pressed);
// If no image from the palette then get a system check box
if (drawImage == null)
{
// Convert incoming parameters to check box state
CheckBoxState state = DiscoverCheckBoxState(enabled, checkState, tracking, pressed);
// Request the glyph be drawn at the top left of the display rectangle
CheckBoxRenderer.DrawCheckBox(context.Graphics, displayRect.Location, state);
}
else
{
// Find the offset to center the image
int xOffset = (displayRect.Width - drawImage.Width) / 2;
int yOffset = (displayRect.Height - drawImage.Height) / 2;
// Draw the image centered
context.Graphics.DrawImage(drawImage,
displayRect.X + xOffset, displayRect.Y + yOffset,
drawImage.Width, drawImage.Height);
}
}