Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,19 @@ internal override LayoutOptions CommonLayout()
private void PaintCore(PaintEventArgs e)
{
Graphics graphics = e.GraphicsInternal;
ParentBackgroundRenderer.Paint(
Control,
graphics,
Control.ClientRectangle,
Control.BackColor);
if (!Control.UseVisualStyleBackColor && !Control.BackColor.HasTransparency())
{
using var backBrush = Control.BackColor.GetCachedSolidBrushScope();
graphics.FillRectangle(backBrush, Control.ClientRectangle);
}
else
{
ParentBackgroundRenderer.Paint(
Control,
graphics,
Control.ClientRectangle,
Control.BackColor);
}

LayoutData layout = Layout(e).Layout();
AdjustFocusRectangle(layout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ internal override LayoutOptions CommonLayout()
private void PaintCore(PaintEventArgs e)
{
Graphics graphics = e.GraphicsInternal;
ParentBackgroundRenderer.Paint(
Control,
graphics,
Control.ClientRectangle,
Control.BackColor);
if (!Control.UseVisualStyleBackColor && !Control.BackColor.HasTransparency())
{
using var backBrush = Control.BackColor.GetCachedSolidBrushScope();
graphics.FillRectangle(backBrush, Control.ClientRectangle);
}
else
{
ParentBackgroundRenderer.Paint(
Control,
graphics,
Control.ClientRectangle,
Control.BackColor);
}

LayoutData layout = Layout(e).Layout();
AdjustFocusRectangle(layout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ public void CheckBox_ModernGlyph_RendersAccentForCheckedStates(CheckState checkS
using CheckBox box = new()
{
BackColor = Color.Red,
UseVisualStyleBackColor = true,
CheckState = checkState,
Size = new Size(40, 24),
VisualStylesMode = VisualStylesMode.Net11
Expand All @@ -597,6 +598,31 @@ public void CheckBox_ModernGlyph_RendersAccentForCheckedStates(CheckState checkS
Assert.Equal(expectedAccent, CountPixels(bitmap, Color.Red) > 0);
}

[WinFormsFact]
public void CheckBox_ModernGlyph_UsesExplicitBackColorWhenVisualStyleBackgroundDisabled()
{
using Panel parent = new() { BackColor = Color.White };
using CheckBox box = new()
{
BackColor = Color.Aqua,
CheckState = CheckState.Unchecked,
Text = string.Empty,
Size = new Size(40, 24),
VisualStylesMode = VisualStylesMode.Net11
};

parent.Controls.Add(box);

using Bitmap bitmap = new(box.Width, box.Height);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, box.ClientRectangle);

box.CreateStandardAdapter().PaintUp(e, box.CheckState);

Color backgroundPixel = bitmap.GetPixel(box.Width - 2, box.Height / 2);
Assert.Equal(Color.Aqua.ToArgb(), backgroundPixel.ToArgb());
}

[WinFormsFact]
public void CheckBox_ModernGlyph_DefaultCheckedColorUsesWindowsAccent()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public void RadioButton_ModernGlyph_RendersAccentWhenChecked(bool isChecked, boo
using RadioButton control = new()
{
BackColor = Color.Red,
UseVisualStyleBackColor = true,
Checked = isChecked,
Size = new Size(40, 24),
VisualStylesMode = VisualStylesMode.Net11
Expand All @@ -237,6 +238,31 @@ public void RadioButton_ModernGlyph_RendersAccentWhenChecked(bool isChecked, boo
Assert.Equal(expectedAccent, CountPixels(bitmap, Color.Red) > 0);
}

[WinFormsFact]
public void RadioButton_ModernGlyph_UsesExplicitBackColorWhenVisualStyleBackgroundDisabled()
{
using Panel parent = new() { BackColor = Color.White };
using RadioButton control = new()
{
BackColor = Color.Aqua,
Checked = false,
Text = string.Empty,
Size = new Size(40, 24),
VisualStylesMode = VisualStylesMode.Net11
};

parent.Controls.Add(control);

using Bitmap bitmap = new(control.Width, control.Height);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

control.CreateStandardAdapter().PaintUp(e, CheckState.Unchecked);

Color backgroundPixel = bitmap.GetPixel(control.Width - 2, control.Height / 2);
Assert.Equal(Color.Aqua.ToArgb(), backgroundPixel.ToArgb());
}

[WinFormsFact]
public void RadioButton_ModernGlyph_DefaultCheckedColorUsesWindowsAccent()
{
Expand Down
Loading