diff --git a/Source/NETworkManager/Resources/Styles/ChildWindowStyles.xaml b/Source/NETworkManager/Resources/Styles/ChildWindowStyles.xaml
index fe902c9b8a..0840efad21 100644
--- a/Source/NETworkManager/Resources/Styles/ChildWindowStyles.xaml
+++ b/Source/NETworkManager/Resources/Styles/ChildWindowStyles.xaml
@@ -10,7 +10,7 @@
-
+
diff --git a/Source/NETworkManager/ViewModels/PowerShellConnectViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellConnectViewModel.cs
index 2b2a066ac8..64e5ed9e55 100644
--- a/Source/NETworkManager/ViewModels/PowerShellConnectViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PowerShellConnectViewModel.cs
@@ -18,7 +18,7 @@ public class PowerShellConnectViewModel : ViewModelBase
private bool _enableRemoteConsole;
- private List _executionPolicies = new();
+ private List _executionPolicies = [];
private ExecutionPolicy _executionPolicy;
diff --git a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
index 7836fb0e0b..a81f96da32 100644
--- a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
@@ -1,6 +1,7 @@
using Dragablz;
using log4net;
using MahApps.Metro.Controls.Dialogs;
+using MahApps.Metro.SimpleChildWindow;
using NETworkManager.Controls;
using NETworkManager.Localization.Resources;
using NETworkManager.Models;
@@ -579,16 +580,15 @@ private void TryFindExecutable()
Log.Warn("Install PowerShell or configure the path in the settings.");
}
- private async Task Connect(string host = null)
+ private Task Connect(string host = null)
{
- var customDialog = new CustomDialog
- {
- Title = Strings.Connect
- };
+ var childWindow = new PowerShellConnectChildWindow();
- var connectViewModel = new PowerShellConnectViewModel(async instance =>
+ var childWindowViewModel = new PowerShellConnectViewModel(instance =>
{
- await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
+ childWindow.IsOpen = false;
+ ConfigurationManager.Current.IsChildWindowOpen = false;
+
ConfigurationManager.OnDialogClose();
// Create profile info
@@ -606,21 +606,24 @@ private async Task Connect(string host = null)
// Otherwise, in some cases, incorrect values are taken over.
AddHostToHistory(instance.Host);
- // Connect
Connect(sessionInfo);
- }, async _ =>
+ }, _ =>
{
- await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
+ childWindow.IsOpen = false;
+ ConfigurationManager.Current.IsChildWindowOpen = false;
+
ConfigurationManager.OnDialogClose();
}, host);
- customDialog.Content = new PowerShellConnectDialog
- {
- DataContext = connectViewModel
- };
+ childWindow.Title = Strings.Connect;
+
+ childWindow.DataContext = childWindowViewModel;
+
+ ConfigurationManager.Current.IsChildWindowOpen = true;
ConfigurationManager.OnDialogOpen();
- await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
+
+ return (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow);
}
private void ConnectProfile()
diff --git a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
index 3223efcfc3..26f939c0c5 100644
--- a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
@@ -1,6 +1,7 @@
using Dragablz;
using log4net;
using MahApps.Metro.Controls.Dialogs;
+using MahApps.Metro.SimpleChildWindow;
using NETworkManager.Controls;
using NETworkManager.Localization.Resources;
using NETworkManager.Models;
@@ -239,7 +240,7 @@ public bool IsProfileFilterSet
OnPropertyChanged();
}
}
-
+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
@@ -504,7 +505,7 @@ public ICommand TextBoxSearchLostFocusCommand
private void OpenProfileFilterAction()
{
ConfigurationManager.Current.IsProfileFilterPopupOpen = true;
-
+
ProfileFilterIsOpen = true;
}
@@ -524,7 +525,7 @@ private void ClearProfileFilterAction()
_searchDisabled = true;
Search = string.Empty;
_searchDisabled = false;
-
+
foreach (var tag in ProfileFilterTags)
tag.IsSelected = false;
@@ -547,7 +548,7 @@ private void CollapseAllProfileGroupsAction()
{
SetIsExpandedForAllProfileGroups(false);
}
-
+
public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction());
private static void OpenSettingsAction()
@@ -588,16 +589,15 @@ private void TryFindExecutable()
Log.Warn("Install PuTTY or configure the path in the settings.");
}
- private async Task Connect(string host = null)
+ private Task Connect(string host = null)
{
- var customDialog = new CustomDialog
- {
- Title = Strings.Connect
- };
+ var childWindow = new PuTTYConnectChildWindow();
- var connectViewModel = new PuTTYConnectViewModel(async instance =>
+ var childWindowViewModel = new PuTTYConnectViewModel(instance =>
{
- await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
+ childWindow.IsOpen = false;
+ ConfigurationManager.Current.IsChildWindowOpen = false;
+
ConfigurationManager.OnDialogClose();
// Create profile info
@@ -630,19 +630,23 @@ private async Task Connect(string host = null)
AddProfileToHistory(instance.Profile);
Connect(sessionInfo);
- }, async _ =>
+ }, _ =>
{
- await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
+ childWindow.IsOpen = false;
+ ConfigurationManager.Current.IsChildWindowOpen = false;
+
ConfigurationManager.OnDialogClose();
}, host);
- customDialog.Content = new PuTTYConnectDialog
- {
- DataContext = connectViewModel
- };
+ childWindow.Title = Strings.Connect;
+
+ childWindow.DataContext = childWindowViewModel;
+
+ ConfigurationManager.Current.IsChildWindowOpen = true;
ConfigurationManager.OnDialogOpen();
- await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
+
+ return (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow);
}
private void ConnectProfile()
@@ -660,7 +664,7 @@ private void ConnectProfileExternal()
ProcessStartInfo info = new()
{
FileName = SettingsManager.Current.PuTTY_ApplicationFilePath,
- Arguments = Models.PuTTY.PuTTY.BuildCommandLine(sessionInfo)
+ Arguments = PuTTY.BuildCommandLine(sessionInfo)
};
Process.Start(info);
@@ -761,7 +765,7 @@ private void SetIsExpandedForAllProfileGroups(bool isExpanded)
foreach (var group in Profiles.Groups.Cast())
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
}
-
+
private void ResizeProfile(bool dueToChangedSize)
{
_canProfileWidthChange = false;
@@ -907,7 +911,7 @@ public void OnProfileFilterClosed()
{
ConfigurationManager.Current.IsProfileFilterPopupOpen = false;
}
-
+
public void OnProfileManagerDialogOpen()
{
ConfigurationManager.OnDialogOpen();
diff --git a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
index b56f761f2c..686350506b 100644
--- a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
@@ -527,7 +527,7 @@ private static void CloseItemAction(ItemActionCallbackArgs args)
// Connect via Dialog
private Task Connect(string host = null)
{
- var childWindow = new RemoteDesktopConnectChildWindow(Application.Current.MainWindow);
+ var childWindow = new RemoteDesktopConnectChildWindow();
var childWindowViewModel = new RemoteDesktopConnectViewModel(instance =>
{
@@ -606,7 +606,7 @@ private Task ConnectProfileAs()
var sessionInfo = RemoteDesktop.CreateSessionInfo(profileInfo);
- var childWindow = new RemoteDesktopConnectChildWindow(Application.Current.MainWindow);
+ var childWindow = new RemoteDesktopConnectChildWindow();
var childWindowViewModel = new RemoteDesktopConnectViewModel(instance =>
{
diff --git a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
index 2594332b32..fafe987dac 100644
--- a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
@@ -1,5 +1,6 @@
using Dragablz;
using MahApps.Metro.Controls.Dialogs;
+using MahApps.Metro.SimpleChildWindow;
using Microsoft.Web.WebView2.Core;
using NETworkManager.Controls;
using NETworkManager.Localization.Resources;
@@ -485,16 +486,15 @@ private static void OpenWebsiteAction(object url)
#region Methods
- private async Task Connect()
+ private Task Connect()
{
- var customDialog = new CustomDialog
- {
- Title = Strings.Connect
- };
+ var childWindow = new WebConsoleConnectChildWindow();
- var connectViewModel = new WebConsoleConnectViewModel(async instance =>
+ var childWindowViewModel = new WebConsoleConnectViewModel(instance =>
{
- await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
+ childWindow.IsOpen = false;
+ ConfigurationManager.Current.IsChildWindowOpen = false;
+
ConfigurationManager.OnDialogClose();
// Create profile info
@@ -509,19 +509,23 @@ private async Task Connect()
AddUrlToHistory(instance.Url);
Connect(info);
- }, async _ =>
+ }, _ =>
{
- await _dialogCoordinator.HideMetroDialogAsync(this, customDialog);
+ childWindow.IsOpen = false;
+ ConfigurationManager.Current.IsChildWindowOpen = false;
+
ConfigurationManager.OnDialogClose();
});
- customDialog.Content = new WebConsoleConnectDialog
- {
- DataContext = connectViewModel
- };
+ childWindow.Title = Strings.Connect;
+
+ childWindow.DataContext = childWindowViewModel;
+
+ ConfigurationManager.Current.IsChildWindowOpen = true;
ConfigurationManager.OnDialogOpen();
- await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
+
+ return (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow);
}
private void ConnectProfile()
diff --git a/Source/NETworkManager/Views/PowerShellConnectDialog.xaml b/Source/NETworkManager/Views/PowerShellConnectChildWindow.xaml
similarity index 62%
rename from Source/NETworkManager/Views/PowerShellConnectDialog.xaml
rename to Source/NETworkManager/Views/PowerShellConnectChildWindow.xaml
index 06930b16a9..40daf75d76 100644
--- a/Source/NETworkManager/Views/PowerShellConnectDialog.xaml
+++ b/Source/NETworkManager/Views/PowerShellConnectChildWindow.xaml
@@ -1,20 +1,24 @@
-
-
+
+
-
-
+
+
@@ -42,7 +46,7 @@
+ IsOn="{Binding EnableRemoteConsole}" />