Skip to content

Commit 0aa2c57

Browse files
authored
Fix: Embedded window size (#2678)
* Fix: Embedded window size * Fix: Embedded window size
1 parent e37e930 commit 0aa2c57

4 files changed

Lines changed: 36 additions & 35 deletions

File tree

Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ public partial class AWSSessionManagerControl : UserControlBase, IDragablzTabIte
1919

2020
private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
2121
{
22-
if (IsConnected)
23-
ResizeEmbeddedWindow();
22+
ResizeEmbeddedWindow();
2423
}
2524

2625
#endregion
2726

2827
#region Variables
28+
2929
private bool _initialized;
3030
private bool _closed;
31-
31+
3232
private readonly IDialogCoordinator _dialogCoordinator;
33-
33+
3434
private readonly Guid _tabId;
3535
private readonly AWSSessionManagerSessionInfo _sessionInfo;
3636

@@ -79,7 +79,7 @@ public AWSSessionManagerControl(Guid tabId, AWSSessionManagerSessionInfo session
7979
_dialogCoordinator = DialogCoordinator.Instance;
8080

8181
ConfigurationManager.Current.AWSSessionManagerTabCount++;
82-
82+
8383
_tabId = tabId;
8484
_sessionInfo = sessionInfo;
8585

@@ -92,9 +92,10 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
9292
if (_initialized)
9393
return;
9494

95-
// Fix: 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
96-
WindowHost.Height = (int)ActualHeight;
97-
WindowHost.Width = (int)ActualWidth;
95+
// 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
96+
// 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)
97+
WindowHost.Height = (int)ActualHeight - 20;
98+
WindowHost.Width = (int)ActualWidth - 20;
9899

99100
Connect().ConfigureAwait(false);
100101
_initialized = true;
@@ -249,14 +250,14 @@ public void CloseTab()
249250
// Prevent multiple calls
250251
if (_closed)
251252
return;
252-
253+
253254
_closed = true;
254255

255256
// Disconnect the session
256257
Disconnect();
257-
258+
258259
ConfigurationManager.Current.AWSSessionManagerTabCount--;
259260
}
260261

261262
#endregion
262-
}
263+
}

Source/NETworkManager/Controls/PowerShellControl.xaml.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public partial class PowerShellControl : UserControlBase, IDragablzTabItem, IEmb
1919

2020
private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
2121
{
22-
if (IsConnected)
23-
ResizeEmbeddedWindow();
22+
ResizeEmbeddedWindow();
2423
}
2524

2625
#endregion
2726

2827
#region Variables
28+
2929
private bool _initialized;
3030
private bool _closed;
3131

@@ -79,10 +79,10 @@ public PowerShellControl(Guid tabId, PowerShellSessionInfo sessionInfo)
7979
_dialogCoordinator = DialogCoordinator.Instance;
8080

8181
ConfigurationManager.Current.PowerShellTabCount++;
82-
82+
8383
_tabId = tabId;
8484
_sessionInfo = sessionInfo;
85-
85+
8686
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
8787
}
8888

@@ -92,11 +92,13 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
9292
if (_initialized)
9393
return;
9494

95-
// Fix: 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
96-
WindowHost.Height = (int)ActualHeight;
97-
WindowHost.Width = (int)ActualWidth;
95+
// 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
96+
// 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)
97+
WindowHost.Height = (int)ActualHeight - 20;
98+
WindowHost.Width = (int)ActualWidth - 20;
9899

99100
Connect().ConfigureAwait(false);
101+
100102
_initialized = true;
101103
}
102104

@@ -143,7 +145,6 @@ private async Task Connect()
143145
_process.Exited += Process_Exited;
144146

145147
// Embed window into panel, remove border etc.
146-
// _process.WaitForInputIdle();
147148
_appWin = _process.MainWindowHandle;
148149

149150
if (_appWin == IntPtr.Zero)
@@ -249,12 +250,12 @@ public void CloseTab()
249250
// Prevent multiple calls
250251
if (_closed)
251252
return;
252-
253+
253254
_closed = true;
254255

255256
// Disconnect the session
256257
Disconnect();
257-
258+
258259
ConfigurationManager.Current.PowerShellTabCount--;
259260
}
260261

Source/NETworkManager/Controls/PuTTYControl.xaml.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public partial class PuTTYControl : UserControlBase, IDragablzTabItem, IEmbedded
2020

2121
private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
2222
{
23-
if (IsConnected)
24-
ResizeEmbeddedWindow();
23+
ResizeEmbeddedWindow();
2524
}
2625

2726
#endregion
@@ -79,7 +78,7 @@ public PuTTYControl(Guid tabId, PuTTYSessionInfo sessionInfo)
7978
DataContext = this;
8079

8180
_dialogCoordinator = DialogCoordinator.Instance;
82-
81+
8382
ConfigurationManager.Current.PuTTYTabCount++;
8483

8584
_tabId = tabId;
@@ -94,9 +93,10 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
9493
if (_initialized)
9594
return;
9695

97-
// Fix: 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
98-
WindowHost.Height = (int)ActualHeight;
99-
WindowHost.Width = (int)ActualWidth;
96+
// 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
97+
// 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)
98+
WindowHost.Height = (int)ActualHeight - 20;
99+
WindowHost.Width = (int)ActualWidth - 20;
100100

101101
Connect().ConfigureAwait(false);
102102

@@ -274,12 +274,12 @@ public void CloseTab()
274274
// Prevent multiple calls
275275
if (_closed)
276276
return;
277-
277+
278278
_closed = true;
279279

280280
// Disconnect the session
281281
Disconnect();
282-
282+
283283
ConfigurationManager.Current.PuTTYTabCount--;
284284
}
285285

Source/NETworkManager/Controls/TigerVNCControl.xaml.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ public partial class TigerVNCControl : UserControlBase, IDragablzTabItem
1919

2020
private void TigerVNCGrid_SizeChanged(object sender, SizeChangedEventArgs e)
2121
{
22-
if (IsConnected)
23-
ResizeEmbeddedWindow();
22+
ResizeEmbeddedWindow();
2423
}
2524

2625
#endregion
@@ -78,7 +77,7 @@ public TigerVNCControl(Guid tabId, TigerVNCSessionInfo sessionInfo)
7877
DataContext = this;
7978

8079
_dialogCoordinator = DialogCoordinator.Instance;
81-
80+
8281
ConfigurationManager.Current.TigerVNCTabCount++;
8382

8483
_tabId = tabId;
@@ -93,7 +92,7 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e)
9392
if (_initialized)
9493
return;
9594

96-
// Fix: 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
95+
// 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
9796
WindowHost.Height = (int)ActualHeight;
9897
WindowHost.Width = (int)ActualWidth;
9998

@@ -257,12 +256,12 @@ public void CloseTab()
257256
// Prevent multiple calls
258257
if (_closed)
259258
return;
260-
259+
261260
_closed = true;
262261

263262
// Disconnect the session
264263
Disconnect();
265-
264+
266265
ConfigurationManager.Current.TigerVNCTabCount--;
267266
}
268267

0 commit comments

Comments
 (0)