VitNX_SectionPanel.OnPaint Method

Raises the Paint event.
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.

protected override void OnPaint(PaintEventArgs e)
 {
     var g = e.Graphics;
     var rect = ClientRectangle;
 
     // Fill body
     using (var b = new SolidBrush(Colors.GreyBackground))
     {
         g.FillRectangle(b, rect);
     }
 
     // Draw header
     var bgColor = ContainsFocus ? Colors.BlueBackground : Colors.HeaderBackground;
     var VitNXColor = ContainsFocus ? Colors.VitNXBlueBorder : Colors.VitNXBorder;
     var lightColor = ContainsFocus ? Colors.LightBlueBorder : Colors.LightBorder;
 
     using (var b = new SolidBrush(bgColor))
     {
         var bgRect = new Rectangle(0, 0, rect.Width, 25);
         g.FillRectangle(b, bgRect);
     }
 
     using (var p = new Pen(VitNXColor))
     {
         g.DrawLine(p, rect.Left, 0, rect.Right, 0);
         g.DrawLine(p, rect.Left, 25 - 1, rect.Right, 25 - 1);
     }
 
     using (var p = new Pen(lightColor))
     {
         g.DrawLine(p, rect.Left, 1, rect.Right, 1);
     }
 
     var xOffset = 3;
 
     using (var b = new SolidBrush(Colors.LightText))
     {
         var textRect = new Rectangle(xOffset, 0, rect.Width - 4 - xOffset, 25);
 
         var format = new StringFormat
         {
             Alignment = StringAlignment.Near,
             LineAlignment = StringAlignment.Center,
             FormatFlags = StringFormatFlags.NoWrap,
             Trimming = StringTrimming.EllipsisCharacter
         };
 
         g.DrawString(SectionHeader, Font, b, textRect, format);
     }
 
     // Draw border
     using (var p = new Pen(Colors.VitNXBorder, 1))
     {
         var modRect = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
 
         g.DrawRectangle(p, modRect);
     }
 }
					
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