VitNX_RadioButton.OnPaint Method

Raises the OnPaint event.
protected override void OnPaint( 
PaintEventArgs e 
)
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.RadioButtonSize;
 
     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);
     }
 
     g.SmoothingMode = SmoothingMode.HighQuality;
 
     using (var p = new Pen(borderColor))
     {
         var boxRect = new Rectangle(0, (rect.Height / 2) - (size / 2), size, size);
         g.DrawEllipse(p, boxRect);
     }
 
     if (Checked)
     {
         using (var b = new SolidBrush(fillColor))
         {
             Rectangle boxRect = new Rectangle(3, (rect.Height / 2) - ((size - 7) / 2) - 1, size - 6, size - 6);
             g.FillEllipse(b, boxRect);
         }
     }
 
     g.SmoothingMode = SmoothingMode.Default;
 
     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+

In this article

Definition