VitNX2_TextBox.OnPaint Method
Raises the Paint event.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics graph = e.Graphics;
if (borderRadius > 1)
{
var rectBorderSmooth = ClientRectangle;
var rectBorder = Rectangle.Inflate(rectBorderSmooth, -borderSize, -borderSize);
int smoothSize = borderSize > 0 ? borderSize : 1;
using (GraphicsPath pathBorderSmooth = GetFigurePath(rectBorderSmooth, borderRadius))
using (GraphicsPath pathBorder = GetFigurePath(rectBorder, borderRadius - borderSize))
using (Pen penBorderSmooth = new Pen(Parent.BackColor, smoothSize))
using (Pen penBorder = new Pen(borderColor, borderSize))
{
Region = new Region(pathBorderSmooth);
if (borderRadius > 15)
SetTextBoxRoundedRegion();
graph.SmoothingMode = SmoothingMode.AntiAlias;
penBorder.Alignment = PenAlignment.Center;
if (isFocused)
penBorder.Color = borderFocusColor;
if (underlinedStyle)
{
graph.DrawPath(penBorderSmooth, pathBorderSmooth);
graph.SmoothingMode = SmoothingMode.None;
graph.DrawLine(penBorder, 0, Height - 1, Width, Height - 1);
}
else
{
graph.DrawPath(penBorderSmooth, pathBorderSmooth);
graph.DrawPath(penBorder, pathBorder);
}
}
}
else
{
using (Pen penBorder = new Pen(borderColor, borderSize))
{
Region = new Region(ClientRectangle);
penBorder.Alignment = PenAlignment.Inset;
if (isFocused)
penBorder.Color = borderFocusColor;
if (underlinedStyle)
graph.DrawLine(penBorder, 0, Height - 1, Width, Height - 1);
else
graph.DrawRectangle(penBorder, 0, 0, Width - 0.5F, Height - 0.5F);
}
}
}
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+