VitNX_CheckBox.OnPaint Method
Raises the OnPaint event.
This language is not supported or no code example is available.
Parameters
-
e
-
PaintEventArgs
protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
var rect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
var size = Constsants.CheckBoxSize;
var textColor = Colors.LightText;
var borderColor = Colors.LightText;
var fillColor = Colors.LightestBackground;
if (Enabled)
{
if (Focused)
{
borderColor = Colors.BlueHighlight;
fillColor = Colors.BlueSelection;
}
if (_controlState == VitNX_ControlState.Hover)
{
borderColor = Colors.BlueHighlight;
fillColor = Colors.BlueSelection;
}
else if (_controlState == VitNX_ControlState.Pressed)
{
borderColor = Colors.GreyHighlight;
fillColor = Colors.GreySelection;
}
}
else
{
textColor = Colors.DisabledText;
borderColor = Colors.GreyHighlight;
fillColor = Colors.GreySelection;
}
using (var b = new SolidBrush(Colors.GreyBackground))
{
g.FillRectangle(b, rect);
}
using (var p = new Pen(borderColor))
{
var boxRect = new Rectangle(0, (rect.Height / 2) - (size / 2), size, size);
g.DrawRectangle(p, boxRect);
}
if (Checked)
{
using (var b = new SolidBrush(fillColor))
{
Rectangle boxRect = new Rectangle(2, (rect.Height / 2) - ((size - 4) / 2), size - 3, size - 3);
g.FillRectangle(b, boxRect);
}
}
using (var b = new SolidBrush(textColor))
{
var stringFormat = new StringFormat
{
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Near
};
var modRect = new Rectangle(size + 4, 0, rect.Width - size, rect.Height);
g.DrawString(Text, Font, b, modRect, stringFormat);
}
}
This language is not supported or no code example is available.
.NET Framework
Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Core
Supported in: 5.0+, 6.0+