From ac78c64f54add350c0633c8371d1ba55cd8f46c6 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Thu, 19 Jun 2025 01:57:21 +0200 Subject: [PATCH 1/9] Feature: Migrate to simplechildwindow --- .../IProfileManagerMinimal.cs | 4 +- Source/NETworkManager/MainWindow.xaml.cs | 1 - Source/NETworkManager/ProfileDialogManager.cs | 42 +- .../AWSSessionManagerHostViewModel.cs | 6 +- .../ViewModels/DNSLookupHostViewModel.cs | 2 +- .../ViewModels/IPGeolocationHostViewModel.cs | 2 +- .../ViewModels/IPScannerHostViewModel.cs | 2 +- .../ViewModels/IPScannerViewModel.cs | 2 +- .../ViewModels/NetworkInterfaceViewModel.cs | 2 +- .../ViewModels/PingMonitorHostViewModel.cs | 2 +- .../ViewModels/PortScannerHostViewModel.cs | 2 +- .../ViewModels/PowerShellHostViewModel.cs | 2 +- .../ViewModels/ProfilesViewModel.cs | 3 +- .../ViewModels/PuTTYHostViewModel.cs | 2 +- .../ViewModels/RemoteDesktopHostViewModel.cs | 2 +- .../ViewModels/SNMPHostViewModel.cs | 2 +- .../ViewModels/TigerVNCHostViewModel.cs | 2 +- .../ViewModels/TracerouteHostViewModel.cs | 2 +- .../ViewModels/WakeOnLANViewModel.cs | 2 +- .../ViewModels/WebConsoleHostViewModel.cs | 2 +- .../ViewModels/WhoisHostViewModel.cs | 2 +- .../Views/ProfileChildWindow.xaml | 4626 +++++++++++++++++ .../Views/ProfileChildWindow.xaml.cs | 52 + 23 files changed, 4724 insertions(+), 42 deletions(-) create mode 100644 Source/NETworkManager/Views/ProfileChildWindow.xaml create mode 100644 Source/NETworkManager/Views/ProfileChildWindow.xaml.cs diff --git a/Source/NETworkManager.Profiles/IProfileManagerMinimal.cs b/Source/NETworkManager.Profiles/IProfileManagerMinimal.cs index 1950391bd5..4832dfbedd 100644 --- a/Source/NETworkManager.Profiles/IProfileManagerMinimal.cs +++ b/Source/NETworkManager.Profiles/IProfileManagerMinimal.cs @@ -11,6 +11,7 @@ public interface IProfileManagerMinimal /// public void OnProfileManagerDialogOpen() { + } /// @@ -18,5 +19,6 @@ public void OnProfileManagerDialogOpen() /// public void OnProfileManagerDialogClose() { + } -} \ No newline at end of file +} diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index 8d89e1d99c..891f37016f 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -472,7 +472,6 @@ await this.ShowMessageAsync(Strings.SettingsHaveBeenReset, // Show welcome dialog if (SettingsManager.Current.WelcomeDialog_Show) { - var childWindow = new WelcomeChildWindow(); var viewModel = new WelcomeViewModel(instance => diff --git a/Source/NETworkManager/ProfileDialogManager.cs b/Source/NETworkManager/ProfileDialogManager.cs index f7666e03c8..f181c8efd8 100644 --- a/Source/NETworkManager/ProfileDialogManager.cs +++ b/Source/NETworkManager/ProfileDialogManager.cs @@ -9,9 +9,11 @@ using NETworkManager.Views; using System; using System.Collections.Generic; +using System.Configuration; using System.Security; using System.Threading.Tasks; using System.Windows; +using MahApps.Metro.SimpleChildWindow; namespace NETworkManager; @@ -466,36 +468,36 @@ private static GroupInfo ParseGroupInfo(GroupViewModel instance) #region Dialog to add, edit, copy as and delete profile - public static Task ShowAddProfileDialog(object context, IProfileManagerMinimal viewModel, - IDialogCoordinator dialogCoordinator, ProfileInfo profile = null, string group = null, + public static Task ShowAddProfileDialog(Window parentWindow,IProfileManagerMinimal viewModel, + ProfileInfo profile = null, string group = null, ApplicationName applicationName = ApplicationName.None) { - CustomDialog customDialog = new() - { - Title = Strings.AddProfile, - Style = (Style)Application.Current.FindResource(DialogResourceKey) - }; - ProfileViewModel profileViewModel = new(async instance => + var childWindow = new ProfileChildWindow(parentWindow); + + ProfileViewModel profileViewModel = new(instance => { - await dialogCoordinator.HideMetroDialogAsync(context, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); - + ProfileManager.AddProfile(ParseProfileInfo(instance)); - }, async _ => + }, _ => { - await dialogCoordinator.HideMetroDialogAsync(context, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); }, ProfileManager.GetGroupNames(), group, ProfileEditMode.Add, profile, applicationName); - customDialog.Content = new ProfileDialog - { - DataContext = profileViewModel - }; - - viewModel.OnProfileManagerDialogOpen(); - - return dialogCoordinator.ShowMetroDialogAsync(context, customDialog); + childWindow.Title = Strings.AddProfile; + + childWindow.DataContext = profileViewModel; + + Settings.ConfigurationManager.Current.IsChildWindowOpen = true; + + return parentWindow.ShowChildWindowAsync(childWindow); } public static Task ShowEditProfileDialog(IProfileManagerMinimal viewModel, diff --git a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs index 5bc0474e38..7949331169 100644 --- a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs @@ -443,7 +443,7 @@ private void ConnectProfileExternalAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.AWSSessionManager) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.AWSSessionManager) .ConfigureAwait(false); } @@ -999,8 +999,8 @@ private void SetProfilesView(ProfileInfo profile = null) Profiles.Filter = o => { if (string.IsNullOrEmpty(Search)) - return true ; - + return true; + if (o is not ProfileInfo info) return false; diff --git a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs index 8ef01da9d7..382d3be891 100644 --- a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs @@ -251,7 +251,7 @@ private void LookupProfileAction() private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.DNSLookup) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.DNSLookup) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs index b0bb7f42eb..9f25e1463d 100644 --- a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs @@ -252,7 +252,7 @@ private void QueryProfileAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.IPGeolocation) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.IPGeolocation) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs index a352707c3a..f5d35e405f 100644 --- a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs @@ -251,7 +251,7 @@ private void ScanProfileAction() private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.IPScanner) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.IPScanner) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs index a95b877b2e..affc75a685 100644 --- a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs @@ -344,7 +344,7 @@ private async void AddProfileSelectedHostAction() var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive); - await ProfileDialogManager.ShowAddProfileDialog(window, this, _dialogCoordinator, profileInfo, null, + await ProfileDialogManager.ShowAddProfileDialog(window, this, profileInfo, null, ApplicationName.IPScanner); } diff --git a/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs b/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs index f11c4ecf84..0c970129c9 100644 --- a/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs @@ -751,7 +751,7 @@ private void ApplyProfileProfileAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.NetworkInterface) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.NetworkInterface) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs b/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs index 413f213ebb..f6c9e44825 100644 --- a/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs @@ -357,7 +357,7 @@ private void ExportAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.PingMonitor) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.PingMonitor) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs index bac9aa7a66..3856ead6ad 100644 --- a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs @@ -252,7 +252,7 @@ private void ScanProfileAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.PortScanner) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.PortScanner) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs index 7165e98b05..6e28099cfb 100644 --- a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs @@ -359,7 +359,7 @@ private void ConnectProfileExternalAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.PowerShell) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.PowerShell) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/ProfilesViewModel.cs b/Source/NETworkManager/ViewModels/ProfilesViewModel.cs index e71def69ba..2861c637a1 100644 --- a/Source/NETworkManager/ViewModels/ProfilesViewModel.cs +++ b/Source/NETworkManager/ViewModels/ProfilesViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Windows; using System.Windows.Data; using System.Windows.Input; using System.Windows.Threading; @@ -165,7 +166,7 @@ public bool IsSearching private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, SelectedGroup?.Name) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, SelectedGroup?.Name) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs index e560490cf1..a295673b6d 100644 --- a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs @@ -366,7 +366,7 @@ private void ConnectProfileExternalAction() private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.PuTTY) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.PuTTY) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs index 9995bbf22c..9205e65a6a 100644 --- a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs @@ -337,7 +337,7 @@ private void ConnectProfileExternalAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.RemoteDesktop) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.RemoteDesktop) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs b/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs index d624478b5b..898b1dc8eb 100644 --- a/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs @@ -249,7 +249,7 @@ private void AddTabProfileAction() private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.SNMP) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.SNMP) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs index 9240e006f6..ae9005b4bf 100644 --- a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs @@ -301,7 +301,7 @@ private void ConnectProfileExternalAction() private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.TigerVNC) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.TigerVNC) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs index dee7c15f94..6100e9ffc5 100644 --- a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs @@ -252,7 +252,7 @@ private void TraceProfileAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.Traceroute) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.Traceroute) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs b/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs index 03175c4d35..33cca4ba2c 100644 --- a/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs +++ b/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs @@ -308,7 +308,7 @@ private void WakeUpProfileAction() private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.WakeOnLAN) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.WakeOnLAN) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs index 59dbf9c47e..21c577b541 100644 --- a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs @@ -299,7 +299,7 @@ private void ConnectProfileAction() private void AddProfileAction() { ProfileDialogManager - .ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.WebConsole) + .ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.WebConsole) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs b/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs index 68351a70ef..cd3ba9aa05 100644 --- a/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs @@ -251,7 +251,7 @@ private void QueryProfileAction() private void AddProfileAction() { - ProfileDialogManager.ShowAddProfileDialog(this, this, _dialogCoordinator, null, null, ApplicationName.Whois) + ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.Whois) .ConfigureAwait(false); } diff --git a/Source/NETworkManager/Views/ProfileChildWindow.xaml b/Source/NETworkManager/Views/ProfileChildWindow.xaml new file mode 100644 index 0000000000..0d43555bbd --- /dev/null +++ b/Source/NETworkManager/Views/ProfileChildWindow.xaml @@ -0,0 +1,4626 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml b/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml index e9d33f5ddf..31585c9008 100644 --- a/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml +++ b/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml @@ -40,7 +40,7 @@ - - - + + + + + + + + + + + + + + + + - - - - - - + + + + + - - + - - - + + - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/Source/NETworkManager/Views/ProfileChildWindow.xaml b/Source/NETworkManager/Views/ProfileChildWindow.xaml index 0d43555bbd..0b0e41f089 100644 --- a/Source/NETworkManager/Views/ProfileChildWindow.xaml +++ b/Source/NETworkManager/Views/ProfileChildWindow.xaml @@ -22,12 +22,11 @@ ShowTitleBar="True" TitleBarBackground="Transparent" TitleBarNonActiveBackground="Transparent" - TitleFontSize="18" - Loaded="UserControl_Loaded" - TitleForeground="{DynamicResource MahApps.Brushes.Gray3}" - CloseByEscape="False" - Padding="20" - OverlayBrush="{DynamicResource ResourceKey=MahApps.Brushes.Gray.SemiTransparent}" + ShowCloseButton="True" + Loaded="UserControl_Loaded" + TitleForeground="{DynamicResource MahApps.Brushes.Gray3}" + CloseByEscape="False" + OverlayBrush="{DynamicResource ResourceKey=MahApps.Brushes.Gray.SemiTransparent}" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:ProfileViewModel}"> From c4062713d06c7927abbc96e3f4e6b591e5e9907f Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Mon, 23 Jun 2025 05:23:53 +0200 Subject: [PATCH 3/9] Feature: Improve design / dialogs --- Source/NETworkManager/MainWindow.xaml.cs | 2 + Source/NETworkManager/NETworkManager.csproj | 5 + Source/NETworkManager/ProfileDialogManager.cs | 129 +- .../Resources/Styles/TextBlockStyles.xaml | 8 +- .../Templates/ValidationErrorTemplates.xaml | 21 +- .../AWSSessionManagerHostViewModel.cs | 6 +- .../ViewModels/DNSLookupHostViewModel.cs | 6 +- .../ViewModels/IPGeolocationHostViewModel.cs | 6 +- .../ViewModels/IPScannerHostViewModel.cs | 6 +- .../ViewModels/NetworkInterfaceViewModel.cs | 6 +- .../ViewModels/PingMonitorHostViewModel.cs | 6 +- .../ViewModels/PortScannerHostViewModel.cs | 6 +- .../ViewModels/PowerShellHostViewModel.cs | 6 +- .../ViewModels/ProfilesViewModel.cs | 8 +- .../ViewModels/PuTTYHostViewModel.cs | 6 +- .../ViewModels/RemoteDesktopHostViewModel.cs | 6 +- .../ViewModels/SNMPHostViewModel.cs | 6 +- .../ViewModels/TigerVNCHostViewModel.cs | 6 +- .../ViewModels/TracerouteHostViewModel.cs | 6 +- .../ViewModels/WakeOnLANViewModel.cs | 6 +- .../ViewModels/WebConsoleHostViewModel.cs | 6 +- .../ViewModels/WhoisHostViewModel.cs | 6 +- .../Views/ConfirmDeleteChildWindow.xaml | 35 + .../Views/ConfirmDeleteChildWindow.xaml.cs | 9 + ...entialsPasswordProfileFileChildWindow.xaml | 112 +- ...ialsPasswordProfileFileChildWindow.xaml.cs | 14 +- .../Views/ProfileChildWindow.xaml | 20 +- .../NETworkManager/Views/ProfileDialog.xaml | 4617 ----------------- .../Views/ProfileDialog.xaml.cs | 40 - Source/NETworkManager/Views/ProfilesView.xaml | 119 +- 30 files changed, 310 insertions(+), 4925 deletions(-) create mode 100644 Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml create mode 100644 Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml.cs delete mode 100644 Source/NETworkManager/Views/ProfileDialog.xaml delete mode 100644 Source/NETworkManager/Views/ProfileDialog.xaml.cs diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index 891f37016f..2283b044c9 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -1442,6 +1442,8 @@ private async void LoadProfile(ProfileFileInfo info, bool showWrongPassword = fa ProfileManager.Unload(); }, info.Name, showWrongPassword); + childWindow.Title = Strings.UnlockProfileFile; + childWindow.DataContext = viewModel; ConfigurationManager.OnDialogOpen(); diff --git a/Source/NETworkManager/NETworkManager.csproj b/Source/NETworkManager/NETworkManager.csproj index a64d71b66d..651c15fcca 100644 --- a/Source/NETworkManager/NETworkManager.csproj +++ b/Source/NETworkManager/NETworkManager.csproj @@ -141,6 +141,11 @@ Wpf Designer + + MSBuild:Compile + Wpf + Designer + diff --git a/Source/NETworkManager/ProfileDialogManager.cs b/Source/NETworkManager/ProfileDialogManager.cs index f181c8efd8..dd95a33da0 100644 --- a/Source/NETworkManager/ProfileDialogManager.cs +++ b/Source/NETworkManager/ProfileDialogManager.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; using System.Configuration; +using System.Diagnostics; using System.Security; using System.Threading.Tasks; using System.Windows; @@ -308,7 +309,7 @@ private static GroupInfo ParseGroupInfo(GroupViewModel instance) { Name = name, Description = instance.Description?.Trim(), - + Profiles = profiles, // Remote Desktop @@ -468,133 +469,139 @@ private static GroupInfo ParseGroupInfo(GroupViewModel instance) #region Dialog to add, edit, copy as and delete profile - public static Task ShowAddProfileDialog(Window parentWindow,IProfileManagerMinimal viewModel, + public static Task ShowAddProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel, ProfileInfo profile = null, string group = null, ApplicationName applicationName = ApplicationName.None) { - var childWindow = new ProfileChildWindow(parentWindow); ProfileViewModel profileViewModel = new(instance => { childWindow.IsOpen = false; - Settings.ConfigurationManager.Current.IsChildWindowOpen = false; - + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); - + ProfileManager.AddProfile(ParseProfileInfo(instance)); }, _ => { + Debug.WriteLine("Profile dialog closed without saving"); + childWindow.IsOpen = false; Settings.ConfigurationManager.Current.IsChildWindowOpen = false; - + viewModel.OnProfileManagerDialogClose(); }, ProfileManager.GetGroupNames(), group, ProfileEditMode.Add, profile, applicationName); childWindow.Title = Strings.AddProfile; - - childWindow.DataContext = profileViewModel; + + childWindow.DataContext = profileViewModel; + + viewModel.OnProfileManagerDialogOpen(); Settings.ConfigurationManager.Current.IsChildWindowOpen = true; return parentWindow.ShowChildWindowAsync(childWindow); } - public static Task ShowEditProfileDialog(IProfileManagerMinimal viewModel, - IDialogCoordinator dialogCoordinator, ProfileInfo profile) + public static Task ShowEditProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel, + ProfileInfo profile) { - CustomDialog customDialog = new() - { - Title = Strings.EditProfile, - Style = (Style)Application.Current.FindResource(DialogResourceKey) - }; + var childWindow = new ProfileChildWindow(parentWindow); - ProfileViewModel profileViewModel = new(async instance => + ProfileViewModel profileViewModel = new(instance => { - await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); ProfileManager.ReplaceProfile(profile, ParseProfileInfo(instance)); - }, async _ => + }, _ => { - await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); }, ProfileManager.GetGroupNames(), profile.Group, ProfileEditMode.Edit, profile); - customDialog.Content = new ProfileDialog - { - DataContext = profileViewModel - }; + childWindow.Title = Strings.EditProfile; - viewModel.OnProfileManagerDialogOpen(); + childWindow.DataContext = profileViewModel; - return dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog); + viewModel.OnProfileManagerDialogOpen(); + + Settings.ConfigurationManager.Current.IsChildWindowOpen = true; + + return parentWindow.ShowChildWindowAsync(childWindow); } - public static Task ShowCopyAsProfileDialog(IProfileManagerMinimal viewModel, - IDialogCoordinator dialogCoordinator, ProfileInfo profile) + public static Task ShowCopyAsProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel, + ProfileInfo profile) { - CustomDialog customDialog = new() - { - Title = Strings.CopyProfile, - Style = (Style)Application.Current.FindResource(DialogResourceKey) - }; + var childWindow = new ProfileChildWindow(parentWindow); - ProfileViewModel profileViewModel = new(async instance => + ProfileViewModel profileViewModel = new(instance => { - await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); ProfileManager.AddProfile(ParseProfileInfo(instance)); - }, async _ => + }, _ => { - await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); }, ProfileManager.GetGroupNames(), profile.Group, ProfileEditMode.Copy, profile); - customDialog.Content = new ProfileDialog - { - DataContext = profileViewModel - }; - + childWindow.Title = Strings.CopyProfile; + + childWindow.DataContext = profileViewModel; + viewModel.OnProfileManagerDialogOpen(); + + Settings.ConfigurationManager.Current.IsChildWindowOpen = true; - return dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog); + return parentWindow.ShowChildWindowAsync(childWindow); } - public static Task ShowDeleteProfileDialog(IProfileManagerMinimal viewModel, - IDialogCoordinator dialogCoordinator, IList profiles) + public static Task ShowDeleteProfileDialog(Window parentWindow, IProfileManagerMinimal viewModel, + IList profiles) { - CustomDialog customDialog = new() - { - Title = profiles.Count == 1 - ? Strings.DeleteProfile - : Strings.DeleteProfiles - }; - - ConfirmDeleteViewModel confirmDeleteViewModel = new(async _ => + var childWindow = new ConfirmDeleteChildWindow(); + + ConfirmDeleteViewModel confirmDeleteViewModel = new(_ => { - await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + viewModel.OnProfileManagerDialogClose(); ProfileManager.RemoveProfiles(profiles); - }, async _ => + }, _ => { - await dialogCoordinator.HideMetroDialogAsync(viewModel, customDialog); + childWindow.IsOpen = false; + Settings.ConfigurationManager.Current.IsChildWindowOpen = false; + + viewModel.OnProfileManagerDialogClose(); }, profiles.Count == 1 ? Strings.DeleteProfileMessage : Strings.DeleteProfilesMessage); - customDialog.Content = new ConfirmDeleteDialog - { - DataContext = confirmDeleteViewModel - }; + childWindow.Title = Strings.DeleteProfile; + + childWindow.DataContext = confirmDeleteViewModel; viewModel.OnProfileManagerDialogOpen(); + + Settings.ConfigurationManager.Current.IsChildWindowOpen = true; - return dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog); + return parentWindow.ShowChildWindowAsync(childWindow); } #endregion diff --git a/Source/NETworkManager/Resources/Styles/TextBlockStyles.xaml b/Source/NETworkManager/Resources/Styles/TextBlockStyles.xaml index 2ef0067312..886e024a66 100644 --- a/Source/NETworkManager/Resources/Styles/TextBlockStyles.xaml +++ b/Source/NETworkManager/Resources/Styles/TextBlockStyles.xaml @@ -28,7 +28,7 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 6260d1f0ee87335afe698480a70db71045d555fd Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Mon, 23 Jun 2025 05:25:03 +0200 Subject: [PATCH 4/9] Chore: Cleanup --- ...entialsPasswordProfileFileChildWindow.xaml | 42 +------------------ 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/Source/NETworkManager/Views/CredentialsPasswordProfileFileChildWindow.xaml b/Source/NETworkManager/Views/CredentialsPasswordProfileFileChildWindow.xaml index cc1756ab91..eb3e8b751f 100644 --- a/Source/NETworkManager/Views/CredentialsPasswordProfileFileChildWindow.xaml +++ b/Source/NETworkManager/Views/CredentialsPasswordProfileFileChildWindow.xaml @@ -75,29 +75,10 @@ - - From 9088777b99ad8f738083ba2050730c83062715c4 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Tue, 24 Jun 2025 00:14:36 +0200 Subject: [PATCH 5/9] Feature: Delete dialog added --- .../Views/ConfirmDeleteChildWindow.xaml | 25 ++++++++++++++++--- ...entialsPasswordProfileFileChildWindow.xaml | 5 ++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml b/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml index 0ebf687adc..ade7d6bdf3 100644 --- a/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml +++ b/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml @@ -6,6 +6,9 @@ xmlns:viewModels="clr-namespace:NETworkManager.ViewModels" xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization" xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow" + xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" + ChildWindowWidth="450" + ChildWindowMaxHeight="500" ShowTitleBar="True" TitleBarBackground="Transparent" TitleBarNonActiveBackground="Transparent" @@ -22,9 +25,25 @@ - - - + + + + + + + + + + + - - - + diff --git a/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml.cs b/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml.cs deleted file mode 100644 index 69d2796792..0000000000 --- a/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NETworkManager.Views; - -public partial class ConfirmDeleteChildWindow -{ - public ConfirmDeleteChildWindow() - { - InitializeComponent(); - } -} diff --git a/Source/NETworkManager/Views/ConfirmDeleteDialog.xaml b/Source/NETworkManager/Views/ConfirmDeleteDialog.xaml deleted file mode 100644 index 170aa8c094..0000000000 --- a/Source/NETworkManager/Views/ConfirmDeleteDialog.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - + - - - - - + diff --git a/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml b/Source/NETworkManager/Views/OKCancelInfoMessageChildWindow.xaml similarity index 97% rename from Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml rename to Source/NETworkManager/Views/OKCancelInfoMessageChildWindow.xaml index ade7d6bdf3..1fd3d8456a 100644 --- a/Source/NETworkManager/Views/ConfirmDeleteChildWindow.xaml +++ b/Source/NETworkManager/Views/OKCancelInfoMessageChildWindow.xaml @@ -1,4 +1,4 @@ - + mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:OKCancelInfoMessageViewModel}"> diff --git a/Source/NETworkManager/Views/OKCancelInfoMessageChildWindow.xaml.cs b/Source/NETworkManager/Views/OKCancelInfoMessageChildWindow.xaml.cs new file mode 100644 index 0000000000..aa4845464b --- /dev/null +++ b/Source/NETworkManager/Views/OKCancelInfoMessageChildWindow.xaml.cs @@ -0,0 +1,9 @@ +namespace NETworkManager.Views; + +public partial class OKCancelInfoMessageChildWindow +{ + public OKCancelInfoMessageChildWindow() + { + InitializeComponent(); + } +} diff --git a/Source/NETworkManager/Views/PortScannerSettingsView.xaml b/Source/NETworkManager/Views/PortScannerSettingsView.xaml index db3eb952f6..1efe63feb7 100644 --- a/Source/NETworkManager/Views/PortScannerSettingsView.xaml +++ b/Source/NETworkManager/Views/PortScannerSettingsView.xaml @@ -70,94 +70,26 @@ - - - - - + - - - - - + - - - - - + diff --git a/Source/NETworkManager/Views/SettingsProfilesView.xaml b/Source/NETworkManager/Views/SettingsProfilesView.xaml index 11799a4b0f..5112afb2c9 100644 --- a/Source/NETworkManager/Views/SettingsProfilesView.xaml +++ b/Source/NETworkManager/Views/SettingsProfilesView.xaml @@ -144,95 +144,25 @@ - - - - - + \ No newline at end of file From 285b3d324c7c5922c784e48e8f53a1e6e53a9113 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Tue, 24 Jun 2025 00:59:04 +0200 Subject: [PATCH 7/9] Docs: #3087 --- Website/docs/changelog/next-release.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index ac3b8ecf77..695bc5779b 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -40,6 +40,8 @@ Release date: **xx.xx.2025** ## Improvements - Redesign welcome dialog. [#3077](https://github.com/BornToBeRoot/NETworkManager/pull/3077) +- Redesign profile dialog. [#3087](https://github.com/BornToBeRoot/NETworkManager/pull/3087) +- Redesign confirm delete dialog. [#3087](https://github.com/BornToBeRoot/NETworkManager/pull/3087) - Add upgrade dialog when updating from a previous version. [#3077](https://github.com/BornToBeRoot/NETworkManager/pull/3077) **WiFi** From 8df1bcfa1c87278cdc033928d6061e676c596f62 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Tue, 24 Jun 2025 01:12:39 +0200 Subject: [PATCH 8/9] Fix: Profile file name case insensitive --- .../NETworkManager.Validators/ProfileFileUniqueValidator.cs | 6 ++++-- Website/docs/changelog/next-release.md | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/NETworkManager.Validators/ProfileFileUniqueValidator.cs b/Source/NETworkManager.Validators/ProfileFileUniqueValidator.cs index 0f4b524fba..4d7fdc15fa 100644 --- a/Source/NETworkManager.Validators/ProfileFileUniqueValidator.cs +++ b/Source/NETworkManager.Validators/ProfileFileUniqueValidator.cs @@ -1,4 +1,5 @@ -using System.Globalization; +using System; +using System.Globalization; using System.Linq; using System.Windows.Controls; using NETworkManager.Localization.Resources; @@ -10,7 +11,8 @@ public class ProfileFileUniqueValidator : ValidationRule { public override ValidationResult Validate(object value, CultureInfo cultureInfo) { - return ProfileManager.ProfileFiles.Any(x => x.Name == value as string) + return ProfileManager.ProfileFiles.Any(x => + string.Equals(x.Name, value as string, StringComparison.OrdinalIgnoreCase)) ? new ValidationResult(false, Strings.ProfileNameAlreadyExists) : ValidationResult.ValidResult; } diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 695bc5779b..0c4f69757f 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -82,6 +82,9 @@ Release date: **xx.xx.2025** ## Bugfixes +- Fixed an issue where the profile file could be overwritten when creating a new profile file with the same name, but with another case (`Profile` exists, but `profile` is created). [#3087](https://github.com/BornToBeRoot/NETworkManager/pull/3087) +- Fixed an application crash when a profile file is renamed to another case (e.g. `Profile` to `profile`) [#3087](https://github.com/BornToBeRoot/NETworkManager/pull/3087). + **Network Interface** - Re-select the network interface after a network change or configuration update. Thanks to [@Ghislain1](https://github.com/Ghislain1) [#3004](https://github.com/BornToBeRoot/NETworkManager/pull/3004) [#2962](https://github.com/BornToBeRoot/NETworkManager/pull/2962) From d2d6df4a61fb1ea8c022db496155ee08fb13b160 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Tue, 24 Jun 2025 01:15:59 +0200 Subject: [PATCH 9/9] Update DNSLookup.cs --- Source/NETworkManager.Models/Network/DNSLookup.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/NETworkManager.Models/Network/DNSLookup.cs b/Source/NETworkManager.Models/Network/DNSLookup.cs index 6afe12d0b9..556a91763b 100644 --- a/Source/NETworkManager.Models/Network/DNSLookup.cs +++ b/Source/NETworkManager.Models/Network/DNSLookup.cs @@ -232,8 +232,6 @@ private void ProcessDnsAnswers(IEnumerable answers, NameServe if (answers is not DnsResourceRecord[] dnsResourceRecords) return; - Debug.WriteLine(dnsResourceRecords); - // A foreach (var record in dnsResourceRecords.OfType()) OnRecordReceived(new DNSLookupRecordReceivedArgs(