Support display scaling in height of FormHandshake
authorDean
Wed, 02 Nov 2016 18:48:28 +0100
changeset 1407 a2b0c1e29f3e
parent 1405 cd14f9d6cb61
child 1408 fcab46ae95b1
Support display scaling in height of FormHandshake
UI/FormHandshake.cs
--- a/UI/FormHandshake.cs	Mon Oct 31 17:30:03 2016 +0100
+++ b/UI/FormHandshake.cs	Wed Nov 02 18:48:28 2016 +0100
@@ -1,4 +1,5 @@
-´╗┐using System.Windows;
+´╗┐using System.Drawing;
+using System.Windows;
 using System.Windows.Forms;
 
 namespace pEp.UI
@@ -8,6 +9,9 @@
     /// </summary>
     internal partial class FormHandshake : Form
     {
+        private double scaleX = 1;
+        private double scaleY = 1;
+
         /**************************************************************
          * 
          * Constructors
@@ -21,6 +25,10 @@
         {
             this.InitializeComponent();
 
+            Graphics g = this.CreateGraphics();
+            this.scaleX = g.DpiX / 96;
+            this.scaleY = g.DpiY / 96;
+
             this.FormControlHandshakeChild.PropertyChanged += DisplayState_PropertyChanged;
             this.FormControlHandshakeChild.CancelClick += ButtonCancel_Click;
             this.FormControlHandshakeChild.ConfirmClick += ButtonConfirm_Click;
@@ -72,11 +80,11 @@
             // Window height
             if (this.FormControlHandshakeChild.DisplayState.Mode == FormControlHandshake.State.HandshakeMode.Standard)
             {
-                this.Height = 400;
+                this.Height = (int)(400 * this.scaleY);
             }
             else
             {
-                this.Height = 300;
+                this.Height = (int)(300 * this.scaleY);
             }
 
             return;