logo
VitNX3 Documentation

# VitNX_ToolWindow.OnPaint Method

Namespace: VitNX.UI.ControlsV1.Docking
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)
     {
         var g = e.Graphics;
         using (var b = new SolidBrush(Colors.GreyBackground))
             g.FillRectangle(b, ClientRectangle);
         var isActive = IsActive();
         var bgColor = isActive ? Colors.BlueBackground : Colors.HeaderBackground;
         var VitNXColor = isActive ? Colors.VitNXBlueBorder : Colors.VitNXBorder;
         var lightColor = isActive ? Colors.LightBlueBorder : Colors.LightBorder;
         using (var b = new SolidBrush(bgColor))
         {
             var bgRect = new Rectangle(0, 0, ClientRectangle.Width, Constsants.ToolWindowHeaderSize);
             g.FillRectangle(b, bgRect);
         }
         using (var p = new Pen(VitNXColor))
         {
             g.DrawLine(p, ClientRectangle.Left,
                 0,
                 ClientRectangle.Right, 0);
             g.DrawLine(p, ClientRectangle.Left,
                 Constsants.ToolWindowHeaderSize - 1,
                 ClientRectangle.Right,
                 Constsants.ToolWindowHeaderSize - 1);
         }
         using (var p = new Pen(lightColor))
             g.DrawLine(p, ClientRectangle.Left, 1, ClientRectangle.Right, 1);
         var xOffset = 2;
         if (Icon != null)
         {
             g.DrawImageUnscaled(Icon,
                 ClientRectangle.Left + 5,
                 ClientRectangle.Top + (Constsants.ToolWindowHeaderSize / 2) - (Icon.Height / 2) + 1);
             xOffset = Icon.Width + 8;
         }
         using (var b = new SolidBrush(Colors.LightText))
         {
             var textRect = new Rectangle(xOffset,
                 0,
                 ClientRectangle.Width - 4 - xOffset,
                 Constsants.ToolWindowHeaderSize);
             var format = new StringFormat
             {
                 Alignment = StringAlignment.Near,
                 LineAlignment = StringAlignment.Center,
                 FormatFlags = StringFormatFlags.NoWrap,
                 Trimming = StringTrimming.EllipsisCharacter
             };
             g.DrawString(DockText,
                 Font,
                 b,
                 textRect,
                 format);
         }
         var img = _closeButtonHot ? DockIcons.tw_close_selected : DockIcons.tw_close;
         if (isActive)
             img = _closeButtonHot ? DockIcons.tw_active_close_selected : DockIcons.tw_active_close;
         g.DrawImageUnscaled(img,
             _closeButtonRect.Left,
             _closeButtonRect.Top);
     }

    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
VitNX_ToolWindow Class
VitNX.UI.ControlsV1.Docking Namespace