Skip to content
Open
Changes from all commits
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 @@ -197,7 +197,15 @@ private class ControlPlaceholder : Control
{
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.

{
BackColor = SystemColors.ControlDark;
}
else
{
BackColor = SystemColors.Control;
}

TabStop = false;
SetStyle(ControlStyles.Selectable, false);
}
Expand All @@ -206,6 +214,10 @@ protected override void OnPaint(PaintEventArgs e)
{
Rectangle rc = ClientRectangle;
ControlPaint.DrawButton(e.Graphics, rc, ButtonState.Normal);
if (Application.IsDarkModeEnabled)
{
e.Graphics.Clear(BackColor);
}
}
}

Expand Down