Skip to content

Commit 51ab08a

Browse files
committed
Fix: Initial size
1 parent 96adce7 commit 51ab08a

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Source/NETworkManager/Controls/PowerShellControl.xaml.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
102102

103103
// Fix 1: The control is not visible by default, thus height and width is not set. If the values are not set, the size does not scale properly
104104
// Fix 2: Somehow the initial size need to be 20px smaller than the actual size after using Dragablz (https://github.com/BornToBeRoot/NETworkManager/pull/2678)
105-
WindowHost.Height = (int)ActualHeight - 20;
106-
WindowHost.Width = (int)ActualWidth - 20;
105+
// Fix 3: The size needs to be scaled by the DPI, otherwise the embedded window is too small on high DPI screens (https://github.com/BornToBeRoot/NETworkManager/pull/3352)
106+
var dpi = System.Windows.Media.VisualTreeHelper.GetDpi(this);
107+
WindowHost.Height = (int)((ActualHeight - 20) * dpi.DpiScaleY);
108+
WindowHost.Width = (int)((ActualWidth - 20) * dpi.DpiScaleX);
107109

108110
Connect().ConfigureAwait(false);
109111

Source/NETworkManager/Controls/PuTTYControl.xaml.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
103103

104104
// Fix 1: The control is not visible by default, thus height and width is not set. If the values are not set, the size does not scale properly
105105
// Fix 2: Somehow the initial size need to be 20px smaller than the actual size after using Dragablz (https://github.com/BornToBeRoot/NETworkManager/pull/2678)
106-
WindowHost.Height = (int)ActualHeight - 20;
107-
WindowHost.Width = (int)ActualWidth - 20;
106+
// Fix 3: The size needs to be scaled by the DPI, otherwise the embedded window is too small on high DPI screens (https://github.com/BornToBeRoot/NETworkManager/pull/3352)
107+
var dpi = System.Windows.Media.VisualTreeHelper.GetDpi(this);
108+
WindowHost.Height = (int)((ActualHeight - 20) * dpi.DpiScaleY);
109+
WindowHost.Width = (int)((ActualWidth - 20) * dpi.DpiScaleX);
108110

109111
Connect().ConfigureAwait(false);
110112

Source/NETworkManager/Controls/TigerVNCControl.xaml.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
8888
return;
8989

9090
// Fix 1: The control is not visible by default, thus height and width is not set. If the values are not set, the size does not scale properly
91-
WindowHost.Height = (int)ActualHeight;
92-
WindowHost.Width = (int)ActualWidth;
91+
// Fix 2: The size needs to be scaled by the DPI, otherwise the embedded window is too small on high DPI screens (https://github.com/BornToBeRoot/NETworkManager/pull/3352)
92+
var dpi = System.Windows.Media.VisualTreeHelper.GetDpi(this);
93+
WindowHost.Height = (int)(ActualHeight * dpi.DpiScaleY);
94+
WindowHost.Width = (int)(ActualWidth * dpi.DpiScaleX);
9395

9496
Connect().ConfigureAwait(false);
9597

0 commit comments

Comments
 (0)