From f6f43f9189c7b66438c2cae8b33a6ebe04bd0b1b Mon Sep 17 00:00:00 2001 From: Charlie Kindel Date: Fri, 25 Oct 2019 19:36:24 -0700 Subject: [PATCH] Fixed window size/position issue @ highdpi --- Installer/version.txt | 2 +- src/MCEControl.csproj | 13 +++++--- src/MainWindow.cs | 15 ++++++--- src/SettingsDialog.cs | 4 +-- src/app.manifest | 74 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 src/app.manifest diff --git a/Installer/version.txt b/Installer/version.txt index 22ec7fd..809c698 100644 --- a/Installer/version.txt +++ b/Installer/version.txt @@ -1 +1 @@ -2.1.0.1 \ No newline at end of file +2.1.0.32 \ No newline at end of file diff --git a/src/MCEControl.csproj b/src/MCEControl.csproj index 94e4890..e30241d 100644 --- a/src/MCEControl.csproj +++ b/src/MCEControl.csproj @@ -97,6 +97,12 @@ true + + + + + app.manifest + System @@ -303,6 +309,8 @@ + + @@ -336,11 +344,6 @@ - - - Designer - - False diff --git a/src/MainWindow.cs b/src/MainWindow.cs index a8c5460..2db2d12 100644 --- a/src/MainWindow.cs +++ b/src/MainWindow.cs @@ -14,6 +14,7 @@ using Microsoft.Win32.Security; using log4net; using Microsoft.Win32; +using System.Drawing; [assembly: System.CLSCompliant(true)] namespace MCEControl { @@ -205,10 +206,6 @@ private void mainWindow_Load(object sender, EventArgs e) { log4.Info($"Logger: Logging to {Logger.Instance.LogFile}"); Logger.Instance.TextBoxThreshold = LogManager.GetLogger("MCEControl").Logger.Repository.LevelMap[Instance.Settings.TextBoxLogThreshold]; - // Location can not be changed in constructor, has to be done here - Location = Settings.WindowLocation; - Size = Settings.WindowSize; - if (cmdWindow == null) cmdWindow = new CommandWindow(); @@ -226,6 +223,16 @@ private void mainWindow_Load(object sender, EventArgs e) { System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged); + // Location can not be changed in constructor, has to be done here + // Use Window's default for location initially. Size needs highDPI conversion. + if (Settings.WindowLocation.IsEmpty || Settings.WindowSize.IsEmpty) { + Size = new Size(this.LogicalToDeviceUnits(1024), this.LogicalToDeviceUnits(640)); + } + else { + Location = Settings.WindowLocation; + Size = Settings.WindowSize; + } + SetStatus($"Version: {Application.ProductVersion}"); Start(); } diff --git a/src/SettingsDialog.cs b/src/SettingsDialog.cs index 687c3d2..7539733 100644 --- a/src/SettingsDialog.cs +++ b/src/SettingsDialog.cs @@ -1244,8 +1244,8 @@ public class AppSettings : ICloneable { public int SerialServerDataBits; public StopBits SerialServerStopBits; public Handshake SerialServerHandshake; - public Point WindowLocation = new Point(120, 50); - public Size WindowSize = new Size(640, 400); + public Point WindowLocation; + public Size WindowSize; public bool ShowCommandWindow; public bool ActivityMonitorEnabled = false; public string ActivityMonitorCommand = "activity"; diff --git a/src/app.manifest b/src/app.manifest new file mode 100644 index 0000000..60711ac --- /dev/null +++ b/src/app.manifest @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + +