Skip to content

Fix DarkMode (a) StatusStrip background renderer A11Y Regression. #13360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
10 changes: 10 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,16 @@ using Pen focusPen = new(focusColor) // Use 'using' with type name and omit type

- **Don't XML-comment local functions**, as this is not supported. Instead, be more verbose in a comment if the local function's purpose is not immediately obvious.

- **Use `<inheritdoc/>` for inherited members** to avoid duplication and ensure consistency in documentation.
```csharp
/// <inheritdoc/>
public override void OnClick(EventArgs e)
{
base.OnClick(e);
// Additional logic here
}
```

### 1.9 File Structure and Formatting

- **Use file-scoped namespaces**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public override DockStyle Dock
set => base.LayoutStyle = value;
}

// we do some custom stuff with padding to accomodate size grip.
// we do some custom stuff with padding to accommodate size grip.
// changing this is not supported at DT
[Browsable(false)]
public new Padding Padding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ public ToolStripRenderMode RenderMode
return ToolStripRenderMode.ManagerRenderMode;
}

if (_renderer is not null && !_renderer.IsAutoGenerated)
if (_renderer is not null && !_renderer.IsSystemDefaultAlternative)
{
return ToolStripRenderMode.Custom;
}
Expand Down Expand Up @@ -3250,7 +3250,7 @@ protected override void OnLayout(LayoutEventArgs e)
{
LayoutRequired = false;

// we need to do this to prevent autosizing to happen while we're reparenting.
// we need to do this to prevent auto-sizing to happen while we're reparenting.
ToolStripOverflow? overflow = GetOverflow();
if (overflow is not null)
{
Expand Down Expand Up @@ -3636,6 +3636,7 @@ protected override void OnPaintBackground(PaintEventArgs e)

Graphics g = e.GraphicsInternal;
GraphicsState graphicsState = g.Save();

try
{
using (Region? transparentRegion = Renderer.GetTransparentRegion(this))
Expand All @@ -3647,6 +3648,12 @@ protected override void OnPaintBackground(PaintEventArgs e)
}
}

if (Renderer.RendererOverride is ToolStripRenderer renderer)
{
renderer.DrawToolStripBackground(new ToolStripRenderEventArgs(g, this));
return;
}

Renderer.DrawToolStripBackground(new ToolStripRenderEventArgs(g, this));
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public static ToolStripManagerRenderMode RenderMode
{
Type currentType = CurrentRendererType;

if (t_defaultRenderer is not null && !t_defaultRenderer.IsAutoGenerated)
if (t_defaultRenderer is not null && !t_defaultRenderer.IsSystemDefaultAlternative)
{
return ToolStripManagerRenderMode.Custom;
}
Expand Down Expand Up @@ -546,24 +546,12 @@ public static bool VisualStylesEnabled

internal static ToolStripRenderer CreateRenderer(ToolStripManagerRenderMode renderMode)
{
switch (renderMode)
return renderMode switch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can turn this into => now.

{
case ToolStripManagerRenderMode.System:
return new ToolStripSystemRenderer(isDefault: true);
case ToolStripManagerRenderMode.Professional:
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
if (Application.IsDarkModeEnabled)
{
return new ToolStripProfessionalRenderer(new DarkProfessionalColors());
}
#pragma warning restore WFO5001

return new ToolStripProfessionalRenderer(isDefault: true);

case ToolStripManagerRenderMode.Custom:
default:
return new ToolStripSystemRenderer(isDefault: true);
}
ToolStripManagerRenderMode.System => new ToolStripSystemRenderer(isDefault: true),
ToolStripManagerRenderMode.Professional => new ToolStripProfessionalRenderer(isDefault: true),
_ => new ToolStripSystemRenderer(isDefault: true),
};
}

internal static ToolStripRenderer CreateRenderer(ToolStripRenderMode renderMode)
Expand Down
Loading