Skip to content

Fix Issue 14005: [DarkMode] the Pane in the Anchor Editor should adapt to the dark mode#14715

Open
SimonZhao888 wants to merge 3 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_14005
Open

Fix Issue 14005: [DarkMode] the Pane in the Anchor Editor should adapt to the dark mode#14715
SimonZhao888 wants to merge 3 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_14005

Conversation

@SimonZhao888

@SimonZhao888 SimonZhao888 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Fixes #14005

Proposed changes

Updated the center placeholder (ControlPlaceholder) visual rendering in AnchorEditor.AnchorUI for dark mode.

  • In dark mode:
    • Set center placeholder background to SystemColors.ControlDark.
    • Replaced the previous button-style painting with explicit dark fill + border drawing (FillRectangle + DrawRectangle) to avoid the bright/white center block.
  • In non-dark mode:
    • Kept existing rendering behavior (ControlPaint.DrawButton(..., ButtonState.Normal)) unchanged.

Customer Impact

  • Updated the visual rendering of the central placeholder (ControlPlaceholder) in AnchorEditor.AnchorUI to ensure compatibility with dark mode.

Regression?

  • No

Risk

  • Mini

Screenshots

Before

image

After

Dark Mode
image

Normal
image

Test methodology

  • Manually

Test environment(s)

  • 11.0.0-preview.6.26317
Microsoft Reviewers: Open in CodeFlow

@SimonZhao888 SimonZhao888 requested a review from a team as a code owner July 8, 2026 03:23
@SimonZhao888 SimonZhao888 changed the title [DarkMode] the Pane in the Anchor Editor should adapt to the dark mode Fix Issue 14005: [DarkMode] the Pane in the Anchor Editor should adapt to the dark mode Jul 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the AnchorEditor drop-down UI so the center placeholder renders appropriately under WinForms dark mode, avoiding the overly bright/white center block reported in #14005.

Changes:

  • Set the center placeholder (ControlPlaceholder) background to SystemColors.ControlDark when Application.IsDarkModeEnabled.
  • In dark mode, replace ControlPaint.DrawButton(...) with explicit fill + border drawing; keep the existing button-style rendering for non-dark mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public ControlPlaceholder()
{
BackColor = SystemColors.Control;
if (Application.IsDarkModeEnabled)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor: the dark-mode decision is duplicated here (for BackColor) and again in OnPaint. Since BackColor is captured only at construction while OnPaint re-evaluates Application.IsDarkModeEnabled on every paint, the two could diverge if the process color mode changes after this control is created. Consider centralizing the decision, or relying solely on OnPaint.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ControlPaint.DrawButton(e.Graphics, rc, ButtonState.Normal); draws a button but does not fill it with color; therefore, we need to fill it when in dark mode.


if (Application.IsDarkModeEnabled)
{
e.Graphics.FillRectangle(SystemBrushes.ControlDark, rc);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

BackColor is already set to SystemColors.ControlDark in the constructor, so the default OnPaintBackground fills the client area with that same color before OnPaint runs. This explicit FillRectangle repaints the identical color and appears redundant — the dark branch really only needs the DrawRectangle border. Consider dropping the fill.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In reality, it does not perform automatic filling; we still need to fill it in manually.

if (Application.IsDarkModeEnabled)
{
e.Graphics.FillRectangle(SystemBrushes.ControlDark, rc);
e.Graphics.DrawRectangle(SystemPens.WindowFrame, rc.X, rc.Y, rc.Width - 1, rc.Height - 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the dark palette SystemColors.WindowFrame is typically near-black, so a border drawn with it over a ControlDark fill against the surrounding dark container may have very low contrast. Could you confirm from the dark-mode screenshot that this border is actually visible? If it isn't, a lighter system color (e.g. SystemColors.ControlLight or ActiveBorder) would read better and stay consistent with the 3D button edge shown in light mode.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Adding a border is not recommended, as borders are typically used to indicate states like selection or clicking, whereas a ControlPlaceholder cannot be selected.

Simon Zhao (BEYONDSOFT CONSULTING INC) added 2 commits July 10, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DarkMode] the Pane in the Anchor Editor should adapt to the dark mode

3 participants