CreateGraphics was the function being disposed in the using, the form handle was still floating around. Suggestion to optimize the dpi function
This commit is contained in:
Camilo Alvarez
2019-01-21 23:29:26 -05:00
parent 968471ec4a
commit 1f700f7842

View File

@@ -11,12 +11,16 @@ namespace mRemoteNG.UI.GraphicsUtilities
// Dpi of a 'normal' definition screen
private const int BaselineDpi = 96;
public SizeF GetResolutionScalingFactor()
{
using (var g = new Form().CreateGraphics())
{
return new SizeF(g.DpiX / BaselineDpi, g.DpiY / BaselineDpi);
}
//This method could be optimized, as it is called for every control / subcontrol
//and causes overhead for 100s in the options page
using (var f = new Form())
{
var g = f.CreateGraphics();
return new SizeF(g.DpiX / BaselineDpi, g.DpiY / BaselineDpi);
}
}
}
}