File tree 2 files changed +12
-10
lines changed
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips
2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -3636,6 +3636,7 @@ protected override void OnPaintBackground(PaintEventArgs e)
3636
3636
3637
3637
Graphics g = e . GraphicsInternal ;
3638
3638
GraphicsState graphicsState = g . Save ( ) ;
3639
+
3639
3640
try
3640
3641
{
3641
3642
using ( Region ? transparentRegion = Renderer . GetTransparentRegion ( this ) )
@@ -3647,6 +3648,12 @@ protected override void OnPaintBackground(PaintEventArgs e)
3647
3648
}
3648
3649
}
3649
3650
3651
+ if ( Renderer . RendererOverride is ToolStripRenderer renderer )
3652
+ {
3653
+ renderer . DrawToolStripBackground ( new ToolStripRenderEventArgs ( g , this ) ) ;
3654
+ return ;
3655
+ }
3656
+
3650
3657
Renderer . DrawToolStripBackground ( new ToolStripRenderEventArgs ( g , this ) ) ;
3651
3658
}
3652
3659
finally
Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ internal ToolStripSystemDarkModeRenderer(bool isDefault) : base(isDefault)
39
39
/// <returns>A color suitable for dark mode.</returns>
40
40
private static Color GetDarkModeColor ( Color color )
41
41
{
42
- // Map common system colors to their dark mode equivalents
42
+ // Map system colors to some slightly different colors we would get
43
+ // form the actual system colors in dark mode, since the visual style
44
+ // renderer in light mode would also not "hit" (for contrast and styling
45
+ // reasons) the exact same palette settings as the system colors.
43
46
if ( color == SystemColors . Control )
44
47
return Color . FromArgb ( 45 , 45 , 45 ) ;
45
48
if ( color == SystemColors . ControlLight )
@@ -107,15 +110,7 @@ private static Pen GetDarkModePen(Color color)
107
110
/// <param name="toolStrip">The ToolStrip to check.</param>
108
111
/// <returns>true if the background should be painted; otherwise, false.</returns>
109
112
private static bool ShouldPaintBackground ( ToolStrip toolStrip )
110
- {
111
- if ( toolStrip is null )
112
- return true ;
113
-
114
- if ( toolStrip . BackgroundImage is not null )
115
- return false ;
116
-
117
- return true ;
118
- }
113
+ => toolStrip is null || toolStrip . BackgroundImage is null ;
119
114
120
115
/// <summary>
121
116
/// Fills the background with the specified color.
You can’t perform that action at this time.
0 commit comments