Redraw full control rectangle on custom controls:

This fixes graphics issues with custom controls; CButton CComboBox and CGroupBox.
This commit is contained in:
2021-12-01 07:15:47 +01:00
parent a3e4ca9ea1
commit 7ceabb226b
3 changed files with 11 additions and 9 deletions

View File

@@ -75,30 +75,31 @@ namespace VAR.Toolbox.Controls
protected override void OnPaint(PaintEventArgs pevent)
{
Rectangle rectangle = new Rectangle(0, 0, Width, Height);
if (Enabled)
{
if (_mouseIsDown)
{
pevent.Graphics.FillRectangle(_backColorDownBrush, pevent.ClipRectangle);
pevent.Graphics.FillRectangle(_backColorDownBrush, rectangle);
}
else
{
if (_mouseIsOver)
{
pevent.Graphics.FillRectangle(_backColorOverBrush, pevent.ClipRectangle);
pevent.Graphics.FillRectangle(_backColorOverBrush, rectangle);
}
else
{
pevent.Graphics.FillRectangle(_backColorBrush, pevent.ClipRectangle);
pevent.Graphics.FillRectangle(_backColorBrush, rectangle);
}
}
}
else
{
pevent.Graphics.FillRectangle(_backColorBrush, pevent.ClipRectangle);
pevent.Graphics.FillRectangle(_backColorBrush, rectangle);
}
pevent.Graphics.DrawString(Text, Font, Enabled ? _foreColorBrush : _foreColorDisableBrush, pevent.ClipRectangle, _stringFormat);
pevent.Graphics.DrawString(Text, Font, Enabled ? _foreColorBrush : _foreColorDisableBrush, rectangle, _stringFormat);
}
}

View File

@@ -15,7 +15,8 @@ namespace VAR.Toolbox.Controls
protected override void OnPaint(PaintEventArgs pevent)
{
pevent.Graphics.FillRectangle(Brushes.CadetBlue, pevent.ClipRectangle);
Rectangle rectangle = new Rectangle(0, 0, Width, Height);
pevent.Graphics.FillRectangle(Brushes.CadetBlue, rectangle);
}
}
}

View File

@@ -37,12 +37,12 @@ namespace VAR.Toolbox.Controls
Size tSize = TextRenderer.MeasureText(Text, Font);
Rectangle borderRect = e.ClipRectangle;
Rectangle borderRect = new Rectangle(0, 0, Width, Height);
borderRect.Y = (borderRect.Y + (tSize.Height / 2));
borderRect.Height = (borderRect.Height - (tSize.Height / 2));
ControlPaint.DrawBorder(e.Graphics, borderRect, this._borderColor, ButtonBorderStyle.Solid);
ControlPaint.DrawBorder(e.Graphics, borderRect, _borderColor, ButtonBorderStyle.Solid);
Rectangle textRect = e.ClipRectangle;
Rectangle textRect = new Rectangle(0, 0, Width, Height);
textRect.X = (textRect.X + 6);
textRect.Width = tSize.Width;
textRect.Height = tSize.Height;