logo
VitNX3 Documentation

# VitNX2_CheckBox.OnPaint Method

Namespace: VitNX2.UI.ControlsV2
Assembly: VitNX3 (in VitNX3.dll)
Raises the Paint event.
VB
C#
F#
C++
JScript
Copy

    protected override void OnPaint(
       PaintEventArgs e
    )

    This language is not supported or no code example is available.

#### Parameters

e
  PaintEventArgs

A PaintEventArgs that contains the event data.

Source code
VB
C#
F#
C++
JScript
Copy

    protected override void OnPaint(PaintEventArgs e)
     {
         UpdateColors();
         Bitmap bitmap = new Bitmap(Width, Height);
         Graphics graphics = Graphics.FromImage(bitmap);
         W = Width - 1;
         H = Height - 1;
         Rectangle rect = new Rectangle(0, 2,
             Height - 5,
             Height - 5);
         Graphics graphics2 = graphics;
         graphics2.SmoothingMode = SmoothingMode.HighQuality;
         graphics2.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
         graphics2.Clear(BackColor);
         _Options o = O;
         if (o != _Options.Style1)
         {
             if (o == _Options.Style2)
             {
                 graphics2.FillRectangle(new SolidBrush(_BaseColor), rect);
                 MouseState state = State;
                 if (state != MouseState.Over)
                 {
                     if (state == MouseState.Down)
                     {
                         graphics2.DrawRectangle(new Pen(_BorderColor), rect);
                         graphics2.FillRectangle(new SolidBrush(Color.FromArgb(118, 213, 170)), rect);
                     }
                 }
                 else
                 {
                     graphics2.DrawRectangle(new Pen(_BorderColor), rect);
                     graphics2.FillRectangle(new SolidBrush(Color.FromArgb(118, 213, 170)), rect);
                 }
                 if (Checked)
                 {
                     graphics2.DrawString("ü",
          new Font("Wingdings", 18f),
          new SolidBrush(_BorderColor),
          new Rectangle(5, 7, H - 9, H - 9),
          Helpers.CenterSF);
                 }
                 if (!Enabled)
                 {
                     graphics2.FillRectangle(new SolidBrush(Color.FromArgb(54, 58, 61)),
                         rect);
                     graphics2.DrawString(Text, Font,
                         new SolidBrush(Color.FromArgb(47, 110, 165)),
                         new Rectangle(20, 2, W, H),
                         Helpers.NearSF);
                 }
                 graphics2.DrawString(Text, Font,
                     new SolidBrush(_TextColor),
                     new Rectangle(20, 2, W, H),
                     Helpers.NearSF);
             }
         }
         else
         {
             graphics2.FillRectangle(new SolidBrush(_BaseColor), rect);
             MouseState state = State;
             if (state != MouseState.Over)
             {
                 if (state == MouseState.Down)
                     graphics2.DrawRectangle(new Pen(_BorderColor), rect);
             }
             else
                 graphics2.DrawRectangle(new Pen(_BorderColor), rect);
             if (Checked)
             {
                 graphics2.DrawString("ü",
      new Font("Wingdings", 18f),
      new SolidBrush(_BorderColor),
      new Rectangle(5, 7, H - 9, H - 9),
      Helpers.CenterSF);
             }
             if (!Enabled)
             {
                 graphics2.FillRectangle(new SolidBrush(Color.FromArgb(54, 58, 61)), rect);
                 graphics2.DrawString(Text,
                     Font,
                     new SolidBrush(Color.FromArgb(140, 142, 143)),
                     new Rectangle(20, 2, W, H),
                     Helpers.NearSF);
             }
             graphics2.DrawString(Text, Font,
                 new SolidBrush(_TextColor),
                 new Rectangle(20, 2, W, H),
                 Helpers.NearSF);
         }
         OnPaint(e);
         graphics.Dispose();
         e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
         e.Graphics.DrawImageUnscaled(bitmap, 0, 0);
         bitmap.Dispose();
     }

    This language is not supported or no code example is available.

Applies to

#### .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+
See Also
VitNX2_CheckBox Class
VitNX2.UI.ControlsV2 Namespace