From 2e943a855a848db14e9ff6c95417afa6c3056b50 Mon Sep 17 00:00:00 2001 From: ClaudioESSilva Date: Thu, 12 Feb 2026 17:33:19 +0000 Subject: [PATCH 1/3] Add support for High DPI to the Dashboard --- Dashboard/App.xaml.cs | 60 ++++++++++++++++++++++++++++++++++++++ Dashboard/Dashboard.csproj | 1 + Dashboard/app.manifest | 49 +++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 Dashboard/app.manifest diff --git a/Dashboard/App.xaml.cs b/Dashboard/App.xaml.cs index 3e257435..4f21236f 100644 --- a/Dashboard/App.xaml.cs +++ b/Dashboard/App.xaml.cs @@ -8,6 +8,7 @@ using System; using System.IO; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -21,8 +22,33 @@ public partial class App : Application private const string MutexName = "PerformanceMonitorDashboard_SingleInstance"; private Mutex? _singleInstanceMutex; + // DPI awareness for proper scaling on high DPI displays + private enum PROCESS_DPI_AWARENESS + { + Process_DPI_Unaware = 0, + Process_System_DPI_Aware = 1, + Process_Per_Monitor_DPI_Aware = 2 + } + + private enum DPI_AWARENESS_CONTEXT + { + Unaware = -1, + SystemAware = -2, + PerMonitorAware = -3, + PerMonitorAwareV2 = -4 + } + + [DllImport("SHCore.dll", SetLastError = true)] + private static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness); + + [DllImport("user32.dll", SetLastError = true)] + private static extern bool SetProcessDpiAwarenessContext(int dpiFlag); + protected override void OnStartup(StartupEventArgs e) { + // Enable per-monitor DPI awareness for proper scaling on high DPI displays + EnableDpiAwareness(); + // Check for existing instance _singleInstanceMutex = new Mutex(true, MutexName, out bool isNewInstance); @@ -65,6 +91,40 @@ protected override void OnExit(ExitEventArgs e) base.OnExit(e); } + private static void EnableDpiAwareness() + { + try + { + // Try PerMonitorV2 first (Windows 10 1703+) - best scaling quality + if (Environment.OSVersion.Version.Major >= 10) + { + try + { + SetProcessDpiAwarenessContext((int)DPI_AWARENESS_CONTEXT.PerMonitorAwareV2); + return; + } + catch + { + // Fall through to try other methods + } + } + + // Try PerMonitor awareness (Windows 8.1+) + try + { + SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware); + } + catch + { + // If all else fails, WPF will use system DPI awareness + } + } + catch + { + // Silently fail - WPF will handle DPI at a basic level + } + } + private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { var exception = e.ExceptionObject as Exception; diff --git a/Dashboard/Dashboard.csproj b/Dashboard/Dashboard.csproj index e1ecd936..9c3d2a7f 100644 --- a/Dashboard/Dashboard.csproj +++ b/Dashboard/Dashboard.csproj @@ -10,6 +10,7 @@ Darling Data, LLC Copyright © 2026 Darling Data, LLC EDD.ico + app.manifest true latest-recommended diff --git a/Dashboard/app.manifest b/Dashboard/app.manifest new file mode 100644 index 00000000..c70b1558 --- /dev/null +++ b/Dashboard/app.manifest @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + true + PerMonitorV2 + true + + + From 1e96f31e7a530be4ab348ddcec561e48294f79ae Mon Sep 17 00:00:00 2001 From: ClaudioESSilva Date: Thu, 12 Feb 2026 17:33:32 +0000 Subject: [PATCH 2/3] Add support for High DPI to the Lite --- Lite/App.xaml.cs | 60 ++++++++++++++++++++++++++++++ Lite/PerformanceMonitorLite.csproj | 1 + Lite/app.manifest | 49 ++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 Lite/app.manifest diff --git a/Lite/App.xaml.cs b/Lite/App.xaml.cs index 21dc418c..55388deb 100644 --- a/Lite/App.xaml.cs +++ b/Lite/App.xaml.cs @@ -8,6 +8,7 @@ using System; using System.IO; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -21,6 +22,28 @@ public partial class App : Application private const string MutexName = "PerformanceMonitorLite_SingleInstance"; private Mutex? _singleInstanceMutex; + // DPI awareness for proper scaling on high DPI displays + private enum PROCESS_DPI_AWARENESS + { + Process_DPI_Unaware = 0, + Process_System_DPI_Aware = 1, + Process_Per_Monitor_DPI_Aware = 2 + } + + private enum DPI_AWARENESS_CONTEXT + { + Unaware = -1, + SystemAware = -2, + PerMonitorAware = -3, + PerMonitorAwareV2 = -4 + } + + [DllImport("SHCore.dll", SetLastError = true)] + private static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness); + + [DllImport("user32.dll", SetLastError = true)] + private static extern bool SetProcessDpiAwarenessContext(int dpiFlag); + /// /// Gets the application data directory where config and data files are stored. /// @@ -103,6 +126,9 @@ public static void SaveSmtpPassword(string password) protected override void OnStartup(StartupEventArgs e) { + // Enable per-monitor DPI awareness for proper scaling on high DPI displays + EnableDpiAwareness(); + // Check for existing instance _singleInstanceMutex = new Mutex(true, MutexName, out bool isNewInstance); @@ -160,6 +186,40 @@ protected override void OnExit(ExitEventArgs e) base.OnExit(e); } + private static void EnableDpiAwareness() + { + try + { + // Try PerMonitorV2 first (Windows 10 1703+) - best scaling quality + if (Environment.OSVersion.Version.Major >= 10) + { + try + { + SetProcessDpiAwarenessContext((int)DPI_AWARENESS_CONTEXT.PerMonitorAwareV2); + return; + } + catch + { + // Fall through to try other methods + } + } + + // Try PerMonitor awareness (Windows 8.1+) + try + { + SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware); + } + catch + { + // If all else fails, WPF will use system DPI awareness + } + } + catch + { + // Silently fail - WPF will handle DPI at a basic level + } + } + private static void LoadDefaultTimeRange() { try diff --git a/Lite/PerformanceMonitorLite.csproj b/Lite/PerformanceMonitorLite.csproj index e91aa06f..a058adb3 100644 --- a/Lite/PerformanceMonitorLite.csproj +++ b/Lite/PerformanceMonitorLite.csproj @@ -12,6 +12,7 @@ Copyright © 2026 Darling Data, LLC Lightweight SQL Server performance monitoring - no installation required on target servers EDD.ico + app.manifest true latest-recommended diff --git a/Lite/app.manifest b/Lite/app.manifest new file mode 100644 index 00000000..a3dc0922 --- /dev/null +++ b/Lite/app.manifest @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + true + PerMonitorV2 + true + + + From 28db7cc60556d8d8d94dd322e5fc07f021fb8b1a Mon Sep 17 00:00:00 2001 From: ClaudioESSilva Date: Fri, 13 Feb 2026 09:10:30 +0000 Subject: [PATCH 3/3] Clean unneeded code --- Dashboard/App.xaml.cs | 59 ------------------------------------------- Lite/App.xaml.cs | 59 ------------------------------------------- 2 files changed, 118 deletions(-) diff --git a/Dashboard/App.xaml.cs b/Dashboard/App.xaml.cs index 4f21236f..1a17661f 100644 --- a/Dashboard/App.xaml.cs +++ b/Dashboard/App.xaml.cs @@ -8,7 +8,6 @@ using System; using System.IO; -using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -22,33 +21,8 @@ public partial class App : Application private const string MutexName = "PerformanceMonitorDashboard_SingleInstance"; private Mutex? _singleInstanceMutex; - // DPI awareness for proper scaling on high DPI displays - private enum PROCESS_DPI_AWARENESS - { - Process_DPI_Unaware = 0, - Process_System_DPI_Aware = 1, - Process_Per_Monitor_DPI_Aware = 2 - } - - private enum DPI_AWARENESS_CONTEXT - { - Unaware = -1, - SystemAware = -2, - PerMonitorAware = -3, - PerMonitorAwareV2 = -4 - } - - [DllImport("SHCore.dll", SetLastError = true)] - private static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness); - - [DllImport("user32.dll", SetLastError = true)] - private static extern bool SetProcessDpiAwarenessContext(int dpiFlag); - protected override void OnStartup(StartupEventArgs e) { - // Enable per-monitor DPI awareness for proper scaling on high DPI displays - EnableDpiAwareness(); - // Check for existing instance _singleInstanceMutex = new Mutex(true, MutexName, out bool isNewInstance); @@ -91,39 +65,6 @@ protected override void OnExit(ExitEventArgs e) base.OnExit(e); } - private static void EnableDpiAwareness() - { - try - { - // Try PerMonitorV2 first (Windows 10 1703+) - best scaling quality - if (Environment.OSVersion.Version.Major >= 10) - { - try - { - SetProcessDpiAwarenessContext((int)DPI_AWARENESS_CONTEXT.PerMonitorAwareV2); - return; - } - catch - { - // Fall through to try other methods - } - } - - // Try PerMonitor awareness (Windows 8.1+) - try - { - SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware); - } - catch - { - // If all else fails, WPF will use system DPI awareness - } - } - catch - { - // Silently fail - WPF will handle DPI at a basic level - } - } private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { diff --git a/Lite/App.xaml.cs b/Lite/App.xaml.cs index 55388deb..7171a8bf 100644 --- a/Lite/App.xaml.cs +++ b/Lite/App.xaml.cs @@ -8,7 +8,6 @@ using System; using System.IO; -using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -22,28 +21,6 @@ public partial class App : Application private const string MutexName = "PerformanceMonitorLite_SingleInstance"; private Mutex? _singleInstanceMutex; - // DPI awareness for proper scaling on high DPI displays - private enum PROCESS_DPI_AWARENESS - { - Process_DPI_Unaware = 0, - Process_System_DPI_Aware = 1, - Process_Per_Monitor_DPI_Aware = 2 - } - - private enum DPI_AWARENESS_CONTEXT - { - Unaware = -1, - SystemAware = -2, - PerMonitorAware = -3, - PerMonitorAwareV2 = -4 - } - - [DllImport("SHCore.dll", SetLastError = true)] - private static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness); - - [DllImport("user32.dll", SetLastError = true)] - private static extern bool SetProcessDpiAwarenessContext(int dpiFlag); - /// /// Gets the application data directory where config and data files are stored. /// @@ -126,8 +103,6 @@ public static void SaveSmtpPassword(string password) protected override void OnStartup(StartupEventArgs e) { - // Enable per-monitor DPI awareness for proper scaling on high DPI displays - EnableDpiAwareness(); // Check for existing instance _singleInstanceMutex = new Mutex(true, MutexName, out bool isNewInstance); @@ -186,40 +161,6 @@ protected override void OnExit(ExitEventArgs e) base.OnExit(e); } - private static void EnableDpiAwareness() - { - try - { - // Try PerMonitorV2 first (Windows 10 1703+) - best scaling quality - if (Environment.OSVersion.Version.Major >= 10) - { - try - { - SetProcessDpiAwarenessContext((int)DPI_AWARENESS_CONTEXT.PerMonitorAwareV2); - return; - } - catch - { - // Fall through to try other methods - } - } - - // Try PerMonitor awareness (Windows 8.1+) - try - { - SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware); - } - catch - { - // If all else fails, WPF will use system DPI awareness - } - } - catch - { - // Silently fail - WPF will handle DPI at a basic level - } - } - private static void LoadDefaultTimeRange() { try