VitNX2_Button.OnPaint Method

Raises the OnPaint event.
protected override void OnPaint( 
PaintEventArgs pevent 
)
This language is not supported or no code example is available.

Parameters

pevent
PaintEventArgs

A PaintEventArgs that contains the event data.

protected override void OnPaint(PaintEventArgs pevent)
 {
     base.OnPaint(pevent);
     Rectangle rectSurface = ClientRectangle;
     Rectangle rectBorder = Rectangle.Inflate(rectSurface, -borderSize, -borderSize);
     int smoothSize = 2;
     if (borderSize > 0)
         smoothSize = borderSize;
     if (borderRadius > 2)
     {
         using (GraphicsPath pathSurface = GetFigurePath(rectSurface, borderRadius))
         using (GraphicsPath pathBorder = GetFigurePath(rectBorder, borderRadius - borderSize))
         using (Pen penSurface = new Pen(Parent.BackColor, smoothSize))
         using (Pen penBorder = new Pen(borderColor, borderSize))
         {
             pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
             Region = new Region(pathSurface);
             pevent.Graphics.DrawPath(penSurface, pathSurface);
             if (borderSize >= 1)
                 pevent.Graphics.DrawPath(penBorder, pathBorder);
         }
     }
     else
     {
         pevent.Graphics.SmoothingMode = SmoothingMode.None;
         Region = new Region(rectSurface);
         if (borderSize >= 1)
         {
             using (Pen penBorder = new Pen(borderColor, borderSize))
             {
                 penBorder.Alignment = PenAlignment.Inset;
                 pevent.Graphics.DrawRectangle(penBorder, 0, 0, Width - 1, Height - 1);
             }
         }
     }
 }
					
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