Skip to content

Commit

Permalink
Scale images in context menu, fixed #22
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-zhao committed Nov 15, 2018
1 parent 3c8d86a commit 294f006
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 146 deletions.
21 changes: 16 additions & 5 deletions SidWiz/HighDpiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,31 @@ private static void AdjustControlImagesDpiScale(IEnumerable controls, float dpiS
}
else if (control is ToolStrip toolStrip)
{
toolStrip.ImageScalingSize = ScaleSize(toolStrip.ImageScalingSize, dpiScale);
foreach (var item in toolStrip.Items.Cast<ToolStripItem>().Where(i => i.Image != null))
{
item.Image = ScaleImage(item.Image, dpiScale);
}
ScaleToolStrip(dpiScale, toolStrip);

toolStrip.AutoSize = true;
}

if (control.ContextMenuStrip != null)
{
ScaleToolStrip(dpiScale, control.ContextMenuStrip);
}


// Then recurse
AdjustControlImagesDpiScale(control.Controls, dpiScale);
}
}

private static void ScaleToolStrip(float dpiScale, ToolStrip toolStrip)
{
toolStrip.ImageScalingSize = ScaleSize(toolStrip.ImageScalingSize, dpiScale);
foreach (var item in toolStrip.Items.Cast<ToolStripItem>().Where(i => i.Image != null))
{
item.Image = ScaleImage(item.Image, dpiScale);
}
}

private static bool CloseToOne(float dpiScale)
{
return Math.Abs(dpiScale - 1) < 0.001;
Expand Down
18 changes: 9 additions & 9 deletions SidWiz/SidWizPlusGUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 294f006

Please sign in to comment.