From d6c064171421f051356db2a278b4e8879fbf1604 Mon Sep 17 00:00:00 2001 From: Bruce Wayne Date: Fri, 24 Nov 2023 01:26:59 +0800 Subject: [PATCH] fix: DPI awareness --- NatTypeTester.WinUI/Views/MainPage.xaml.cs | 11 +++ NatTypeTester/NatTypeTester.csproj | 1 + NatTypeTester/app.manifest | 80 ++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 NatTypeTester/app.manifest diff --git a/NatTypeTester.WinUI/Views/MainPage.xaml.cs b/NatTypeTester.WinUI/Views/MainPage.xaml.cs index a75792c4a..85c05bf4e 100644 --- a/NatTypeTester.WinUI/Views/MainPage.xaml.cs +++ b/NatTypeTester.WinUI/Views/MainPage.xaml.cs @@ -11,6 +11,17 @@ public MainPage() this.WhenActivated(d => { + #region DPI + + double scale = XamlRoot.RasterizationScale; + if (scale is not 1.0) + { + AppWindow appWindow = Locator.Current.GetRequiredService().AppWindow; + appWindow.Resize(new SizeInt32((int)(appWindow.Size.Width * scale), (int)(appWindow.Size.Height * scale))); + } + + #endregion + this.Bind(ViewModel, vm => vm.Config.StunServer, v => v.ServersComboBox.Text diff --git a/NatTypeTester/NatTypeTester.csproj b/NatTypeTester/NatTypeTester.csproj index d17f63a7a..61b16b973 100644 --- a/NatTypeTester/NatTypeTester.csproj +++ b/NatTypeTester/NatTypeTester.csproj @@ -8,6 +8,7 @@ true 8.0.0 icon.ico + app.manifest diff --git a/NatTypeTester/app.manifest b/NatTypeTester/app.manifest new file mode 100644 index 000000000..93c7d67cd --- /dev/null +++ b/NatTypeTester/app.manifest @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PerMonitorV2 + true + true + + + + + + + +