From 1f700f7842496315d69a352422fc7394d90fa5a2 Mon Sep 17 00:00:00 2001 From: Camilo Alvarez Date: Mon, 21 Jan 2019 23:29:26 -0500 Subject: [PATCH] Fix for #1257 CreateGraphics was the function being disposed in the using, the form handle was still floating around. Suggestion to optimize the dpi function --- .../UI/GraphicsUtilities/GdiPlusGraphicsProvider.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mRemoteV1/UI/GraphicsUtilities/GdiPlusGraphicsProvider.cs b/mRemoteV1/UI/GraphicsUtilities/GdiPlusGraphicsProvider.cs index d6fdc4812..26fd63ce6 100644 --- a/mRemoteV1/UI/GraphicsUtilities/GdiPlusGraphicsProvider.cs +++ b/mRemoteV1/UI/GraphicsUtilities/GdiPlusGraphicsProvider.cs @@ -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); + } } } }