Skip to content

Commit 8e9ff57

Browse files
Fix the StatusStripSizingGrip.
1 parent 504b21a commit 8e9ff57

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripRenderer.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,4 +1044,26 @@ private static Bitmap CreateDisabledImage(Image normalImage, ImageAttributes? im
10441044

10451045
return disabledBitmap;
10461046
}
1047+
1048+
private protected static int GetCornerOffset(ToolStrip toolStrip)
1049+
{
1050+
// If we're on Windows 11, offset slightly to avoid hitting rounded corners,
1051+
// _if_ we are at all dealing with rounded corners.
1052+
int cornerOffset = 3;
1053+
1054+
if (Environment.OSVersion.Version >= new Version(10, 0, 22000)
1055+
&& toolStrip.FindForm() is Form f)
1056+
{
1057+
#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.
1058+
cornerOffset = f.FormCornerPreference switch
1059+
{
1060+
FormCornerPreference.Round => 8,
1061+
FormCornerPreference.RoundSmall => 5,
1062+
_ => 3
1063+
};
1064+
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
1065+
}
1066+
1067+
return cornerOffset;
1068+
}
10471069
}

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripSystemDarkModeRenderer.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,14 @@ protected override void OnRenderStatusStripSizingGrip(ToolStripRenderEventArgs e
718718
Rectangle bounds = e.AffectedBounds;
719719
Graphics g = e.Graphics;
720720

721-
// Draw a dark mode sizing grip
722-
Color darkColor = GetDarkModeColor(SystemColors.ControlDark);
723-
Color lightColor = GetDarkModeColor(SystemColors.ControlLight);
721+
// Use better contrast for dark mode
722+
Color shadowColor = GetDarkModeColor(SystemColors.ButtonShadow);
723+
Color highlightColor = GetDarkModeColor(SystemColors.ButtonHighlight);
724+
725+
int cornerOffset = GetCornerOffset(e.ToolStrip);
724726

725-
// Start at the bottom-right corner and move up and left
726-
int x = bounds.Right - 3;
727-
int y = bounds.Bottom - 3;
727+
int x = bounds.Right - cornerOffset;
728+
int y = bounds.Bottom - cornerOffset;
728729

729730
for (int i = 0; i < 3; i++)
730731
{
@@ -733,8 +734,8 @@ protected override void OnRenderStatusStripSizingGrip(ToolStripRenderEventArgs e
733734

734735
for (int j = 0; j <= i; j++)
735736
{
736-
g.FillRectangle(new SolidBrush(darkColor), tempX, tempY, 2, 2);
737-
g.FillRectangle(new SolidBrush(lightColor), tempX - 1, tempY - 1, 1, 1);
737+
g.FillRectangle(new SolidBrush(shadowColor), tempX, tempY, 2, 2);
738+
g.FillRectangle(new SolidBrush(highlightColor), tempX - 1, tempY - 1, 1, 1);
738739

739740
tempX -= 4;
740741
tempY += 4;

0 commit comments

Comments
 (0)