protected override void OnPaint(PaintEventArgs e)
{
if (AllowPainting)
{
// draw the background
DrawBackground(e);
// draw the image
if (!ViewSize.IsEmpty)
{
DrawImageBorder(e.Graphics);
}
if (VirtualMode)
{
OnVirtualDraw(e);
}
else if (Image != null)
{
DrawImage(e.Graphics);
}
// draw the grid
if (ShowPixelGrid && !VirtualMode)
{
DrawPixelGrid(e.Graphics);
}
// draw the selection
if (SelectionRegion != Rectangle.Empty)
{
DrawSelection(e);
}
// text
if (!string.IsNullOrEmpty(Text) && TextDisplayMode != ImageBoxGridDisplayMode.None)
{
DrawText(e);
}
// scrollbar corners
if (HorizontalScroll.Visible && VerticalScroll.Visible)
{
int x;
int y;
int w;
int h;
Size clientSize;
clientSize = ClientSize;
w = _vScrollBar.Width;
h = _hScrollBar.Height;
x = clientSize.Width - w;
y = clientSize.Height - h;
e.Graphics.FillRectangle(SystemBrushes.Control, x, y, w, h);
}
base.OnPaint(e);
}
}