ToolStrip high DPI support

This commit is contained in:
Jaex 2016-10-03 16:10:30 +03:00
parent c5a1426853
commit 4e66c387b2

View file

@ -77,6 +77,19 @@ private void CreateMenu()
tsMain.SuspendLayout();
// https://www.medo64.com/2014/01/scaling-toolstrip-with-dpi/
using (Graphics g = menuForm.CreateGraphics())
{
double scale = Math.Max(g.DpiX, g.DpiY) / 96.0;
double newScale = ((int)Math.Floor(scale * 100) / 25 * 25) / 100.0;
if (newScale > 1)
{
int newWidth = (int)(tsMain.ImageScalingSize.Width * newScale);
int newHeight = (int)(tsMain.ImageScalingSize.Height * newScale);
tsMain.ImageScalingSize = new Size(newWidth, newHeight);
}
}
menuForm.Controls.Add(tsMain);
ToolStripLabel tslDragLeft = new ToolStripLabel()