Skip to content

Commit

Permalink
remove ugly top, left border of menu on Windows 10
Browse files Browse the repository at this point in the history
  • Loading branch information
d2phap committed May 19, 2022
1 parent 7ec72ff commit 1e08728
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Source/Components/ImageGlass.UI/Renderers/ModernMenuRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,45 @@ protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs
base.OnRenderMenuItemBackground(e);
}


protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) {
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

if (Helpers.IsOS(WindowsOS.Win10)) {
// override default ugly border by a solid color
using var penDefault = new Pen(theme.MenuBackgroundColor);
e.Graphics.DrawRectangle(penDefault,
0,
0,
e.AffectedBounds.Width,
e.AffectedBounds.Height);
}
else {
base.OnRenderToolStripBorder(e);
}

using var pen = new Pen(theme.MenuBackgroundColor);

if (theme.MenuBackgroundColor.GetBrightness() > 0.5) // light background
{
pen.Color = Color.FromArgb(35, 0, 0, 0);
}
else // dark background
{
pen.Color = Color.FromArgb(35, 255, 255, 255);
}

var menuBorderRadius = Helpers.IsOS(WindowsOS.Win11) ? 8 : 0;
using var path = Theme.GetRoundRectanglePath(new() {
X = 0,
Y = 0,
Width = e.AffectedBounds.Width - 1,
Height = e.AffectedBounds.Height - 1,
}, menuBorderRadius);

e.Graphics.DrawPath(pen, path);
}

}

public class ModernColors: ProfessionalColorTable {
Expand Down

0 comments on commit 1e08728

Please sign in to comment.