Skip to content

Commit fc3636d

Browse files
committed
Merge branch 'main' into feature/powershell_path
2 parents 443b3bf + c4c6537 commit fc3636d

17 files changed

+471
-167
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<b>A powerful open source tool for managing networks and troubleshooting network problems!</b>
66
</p>
77
<p>
8-
Connect and manage remote systems with Remote Desktop, PowerShell, PuTTY, TigerVNC or AWS (Systems Manager) Session Manager. Analyze and troubleshoot your network and systems with features such as the WiFi Analyzer, IP Scanner, Port Scanner, Ping Monitor, Traceroute, DNS lookup or LLDP/CDP capture (and many <a href="https://borntoberoot.net/NETworkManager/docs/features">more</a>) in a unfied interface. Hosts (or networks) can be saved in (encrypted) profiles and used across all features.
8+
Connect to remote systems and manage your network and server infrastructure using tools like Remote Desktop (RDP), PuTTY (SSH, Telnet, Serial), PowerShell (WinRM), TigerVNC (VNC), or AWS Console (AWS SSM). Analyze, troubleshoot, and obtain detailed information about your network and systems with features such as the WiFi Analyzer, IP Scanner, Port Scanner, Ping Monitor, Traceroute, DNS Lookup, and LLDP/CDP Capture (and many <a href="https://borntoberoot.net/NETworkManager/docs/features">more</a>) — all within a unified interface. Hosts and networks can be saved in encrypted profiles and used across all features.
99
<p>
1010
<a href="https://borntoberoot.net/NETworkManager/download" target="_blank">
1111
<img alt="All releases" src="https://img.shields.io/badge/>>_download_now_<<-00abbd?style=for-the-badge" height="48" />

Source/NETworkManager.Models/NETworkManager.Models.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<EmbeddedResource Include="Resources\PSDiscoveryProtocol.psm1"/>
2727
</ItemGroup>
2828
<ItemGroup>
29-
<PackageReference Include="AWSSDK.Core" Version="3.7.400.64"/>
29+
<PackageReference Include="AWSSDK.Core" Version="3.7.400.70"/>
3030
<PackageReference Include="DnsClient" Version="1.8.0"/>
3131
<PackageReference Include="IPNetwork2" Version="3.0.667"/>
3232
<PackageReference Include="Lextm.SharpSnmpLib" Version="12.5.5"/>

Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4+
using System.Diagnostics;
45
using System.Linq;
56
using System.Runtime.CompilerServices;
67
using System.Threading.Tasks;
78
using System.Windows;
89
using System.Windows.Forms;
910
using System.Windows.Input;
11+
using System.Windows.Interop;
1012
using Dragablz;
1113
using MahApps.Metro.Controls.Dialogs;
1214
using NETworkManager.Localization;
@@ -60,21 +62,16 @@ private async void FocusEmbeddedWindow()
6062
if (!_embeddedWindowApplicationNames.Contains(ApplicationName))
6163
return;
6264

63-
var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);
64-
65-
if (window == null)
66-
return;
67-
6865
// Find all TabablzControl in the active window
69-
foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren<TabablzControl>(window))
66+
foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren<TabablzControl>(this))
7067
{
7168
// Skip if no items
7269
if (tabablzControl.Items.Count == 0)
7370
continue;
7471

7572
// Focus embedded window in the selected tab
7673
(((DragablzTabItem)tabablzControl.SelectedItem)?.View as IEmbeddedWindow)?.FocusEmbeddedWindow();
77-
74+
7875
break;
7976
}
8077
}
@@ -212,7 +209,7 @@ private void RemoteDesktop_FullscreenAction(object view)
212209
private void RemoteDesktop_AdjustScreenAction(object view)
213210
{
214211
if (view is RemoteDesktopControl control)
215-
control.AdjustScreen();
212+
control.AdjustScreen(force: true);
216213
}
217214

218215
public ICommand RemoteDesktop_SendCtrlAltDelCommand =>
@@ -377,14 +374,8 @@ private void MetroWindow_Activated(object sender, EventArgs e)
377374

378375
private void DragablzTabHostWindow_OnClosing(object sender, CancelEventArgs e)
379376
{
380-
// Close all tabs properly when the window is closing
381-
var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive);
382-
383-
if (window == null)
384-
return;
385-
386377
// Find all TabablzControl in the active window
387-
foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren<TabablzControl>(window))
378+
foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren<TabablzControl>(this))
388379
foreach (var tabItem in tabablzControl.Items.OfType<DragablzTabItem>())
389380
((IDragablzTabItem)tabItem.View).CloseTab();
390381

@@ -439,4 +430,72 @@ private void TabablzControl_OnIsDraggingWindowChanged(object sender, RoutedPrope
439430
}
440431

441432
#endregion
433+
434+
#region Handle WndProc messages (handle window size events)
435+
436+
private HwndSource _hwndSource;
437+
438+
private const int WmExitSizeMove = 0x232;
439+
private const int WmSysCommand = 0x0112;
440+
private const int ScMaximize = 0xF030;
441+
private const int ScRestore = 0xF120;
442+
443+
protected override void OnSourceInitialized(EventArgs e)
444+
{
445+
base.OnSourceInitialized(e);
446+
447+
_hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
448+
_hwndSource?.AddHook(HwndHook);
449+
}
450+
451+
[DebuggerStepThrough]
452+
private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
453+
{
454+
// Window size events
455+
switch (msg)
456+
{
457+
// Handle window resize and move events
458+
case WmExitSizeMove:
459+
UpdateOnWindowResize();
460+
break;
461+
462+
// Handle system commands (like maximize and restore)
463+
case WmSysCommand:
464+
465+
switch (wParam.ToInt32())
466+
{
467+
// Window is maximized
468+
case ScMaximize:
469+
// Window is restored (back to normal size from maximized state)
470+
case ScRestore:
471+
UpdateOnWindowResize();
472+
break;
473+
}
474+
475+
break;
476+
}
477+
478+
handled = false;
479+
480+
return IntPtr.Zero;
481+
}
482+
483+
private void UpdateOnWindowResize()
484+
{
485+
// Find all TabablzControl
486+
foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren<TabablzControl>(this))
487+
{
488+
// Skip if no items
489+
if (tabablzControl.Items.Count == 0)
490+
continue;
491+
492+
foreach (var item in tabablzControl.Items.OfType<DragablzTabItem>())
493+
{
494+
if (item.View is RemoteDesktopControl control)
495+
control.UpdateOnWindowResize();
496+
}
497+
}
498+
}
499+
500+
#endregion
442501
}

Source/NETworkManager/Controls/IDragablzTabItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public interface IDragablzTabItem
1313
/// </summary>
1414
public void CloseTab()
1515
{
16+
1617
}
1718
}

Source/NETworkManager/Controls/IEmbeddedWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public interface IEmbeddedWindow
1111
/// </summary>
1212
public void FocusEmbeddedWindow()
1313
{
14+
1415
}
1516
}

Source/NETworkManager/Controls/RemoteDesktopControl.xaml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
1010
xmlns:local="clr-namespace:NETworkManager.Controls"
1111
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
12-
mc:Ignorable="d" Loaded="UserControl_Loaded"
12+
mc:Ignorable="d" Loaded="UserControl_Loaded"
1313
d:DataContext="{d:DesignInstance local:RemoteDesktopControl}">
1414
<local:UserControlBase.Resources>
1515
<converters:BooleanReverseConverter x:Key="BooleanReverseConverter" />
1616
<converters:BooleanReverseToVisibilityCollapsedConverter x:Key="BooleanReverseToVisibilityCollapsedConverter" />
1717
<converters:BooleanReverseToVisibilityHiddenConverter x:Key="BooleanReverseToVisibilityHiddenConverter" />
1818
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
1919
</local:UserControlBase.Resources>
20-
<Grid x:Name="RdpGrid" SizeChanged="RdpGrid_SizeChanged">
21-
<WindowsFormsHost MaxWidth="{Binding RdpClientWidth, Mode=OneWay}"
22-
MaxHeight="{Binding RdpClientHeight, Mode=OneWay}"
23-
Background="{DynamicResource ResourceKey=MahApps.Brushes.Window.Background}">
20+
<Grid x:Name="RdpGrid">
21+
<WindowsFormsHost MaxWidth="{Binding WindowsFormsHostMaxWidth, Mode=OneWay}"
22+
MaxHeight="{Binding WindowsFormsHostMaxHeight, Mode=OneWay}"
23+
Background="{DynamicResource ResourceKey=MahApps.Brushes.Window.Background}"
24+
DpiChanged="WindowsFormsHost_DpiChanged">
2425
<WindowsFormsHost.Style>
2526
<Style TargetType="{x:Type WindowsFormsHost}">
2627
<Style.Triggers>
@@ -31,14 +32,11 @@
3132
</DataTrigger>
3233
<DataTrigger Binding="{Binding IsConnected}" Value="False">
3334
<Setter Property="Visibility" Value="Hidden" />
34-
</DataTrigger>
35-
<DataTrigger Binding="{Binding IsReconnecting}" Value="True">
36-
<Setter Property="Visibility" Value="Hidden" />
37-
</DataTrigger>
35+
</DataTrigger>
3836
</Style.Triggers>
3937
</Style>
4038
</WindowsFormsHost.Style>
41-
<mstsc:AxMsRdpClient9NotSafeForScripting x:Name="RdpClient" />
39+
<mstsc:AxMsRdpClient10NotSafeForScripting x:Name="RdpClient" />
4240
</WindowsFormsHost>
4341
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" TextBlock.TextAlignment="Center"
4442
Visibility="{Binding IsConnected, Converter={StaticResource BooleanReverseToVisibilityCollapsedConverter}}">
@@ -65,18 +63,6 @@
6563
<TextBlock Grid.Row="3" Text="{x:Static localization:Strings.ConnectingDots}"
6664
Style="{StaticResource MessageTextBlock}"
6765
Visibility="{Binding IsConnecting, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" />
68-
</Grid>
69-
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" TextBlock.TextAlignment="Center"
70-
Visibility="{Binding IsReconnecting, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">
71-
<Grid.RowDefinitions>
72-
<RowDefinition Height="Auto" />
73-
<RowDefinition Height="Auto" />
74-
<RowDefinition Height="20" />
75-
<RowDefinition Height="Auto" />
76-
</Grid.RowDefinitions>
77-
<mah:ProgressRing Grid.Row="0" Grid.RowSpan="2" Height="50" Width="50" />
78-
<TextBlock Grid.Row="3" Text="{x:Static localization:Strings.ConnectingDots}"
79-
Style="{StaticResource MessageTextBlock}" />
80-
</Grid>
66+
</Grid>
8167
</Grid>
8268
</local:UserControlBase>

0 commit comments

Comments
 (0)