From ffd9c3720d89e53c7b907f4088a9addbaaa8239d Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Thu, 4 Apr 2024 00:22:45 +0200
Subject: [PATCH 01/22] Feature: Enable dockablz
---
Source/3rdparty/Dragablz | 2 +-
.../Controls/DragablzTabHostWindow.xaml | 1418 +++++++++--------
.../Controls/DragablzTabHostWindow.xaml.cs | 18 +-
3 files changed, 736 insertions(+), 702 deletions(-)
diff --git a/Source/3rdparty/Dragablz b/Source/3rdparty/Dragablz
index 2b70e0f3a6..3075a3cc69 160000
--- a/Source/3rdparty/Dragablz
+++ b/Source/3rdparty/Dragablz
@@ -1 +1 @@
-Subproject commit 2b70e0f3a686372ea0ddd4d5bf58e5ac317edcaf
+Subproject commit 3075a3cc69a57a73529daa739afab5370f10eafb
diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
index c1d32d6506..1ae9a143e6 100644
--- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
+++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:controls="clr-namespace:NETworkManager.Controls"
xmlns:application="clr-namespace:NETworkManager.Models;assembly=NETworkManager.Models"
@@ -20,711 +21,730 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Gesture="MiddleClick" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs
index 438f2f715e..d3f4e7b2de 100644
--- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs
+++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs
@@ -29,7 +29,7 @@ public DragablzTabHostWindow(ApplicationName applicationName)
InterTabClient = new DragablzInterTabClient(applicationName);
- InterTabController.Partition = applicationName.ToString();
+ Partition = applicationName.ToString();
Title =
$"NETworkManager {AssemblyManager.Current.Version} - {ResourceTranslator.Translate(ResourceIdentifier.ApplicationName, applicationName)}";
@@ -109,6 +109,21 @@ public ApplicationName ApplicationName
}
}
+ private string _partition;
+
+ public string Partition
+ {
+ get => _partition;
+ set
+ {
+ if (value == _partition)
+ return;
+
+ _partition = value;
+ OnPropertyChanged();
+ }
+ }
+
private bool _headerContextMenuIsOpen;
public bool HeaderContextMenuIsOpen
@@ -177,7 +192,6 @@ private void CloseItemAction(ItemActionCallbackArgs args)
case ApplicationName.IPGeolocation:
((IPGeolocationView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
break;
-
}
}
From 732fbe7eb55e25b35b0d1f2ac039159844a6fbf8 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sat, 6 Apr 2024 04:32:47 +0200
Subject: [PATCH 02/22] Feature: Enable dockablz
---
Source/3rdparty/Dragablz | 2 +-
Source/NETworkManager.sln.DotSettings | 1 +
.../Controls/DragablzInterTabClient.cs | 13 +++-------
.../Controls/DragablzTabHostWindow.xaml | 6 ++---
.../Controls/DragablzTabHostWindow.xaml.cs | 13 +++++-----
.../ViewModels/IPScannerHostViewModel.cs | 26 +++++++++++++++----
.../Views/IPScannerHostView.xaml | 24 ++++++++++++++---
.../Views/IPScannerHostView.xaml.cs | 2 --
8 files changed, 57 insertions(+), 30 deletions(-)
diff --git a/Source/3rdparty/Dragablz b/Source/3rdparty/Dragablz
index 3075a3cc69..7ac6fe4543 160000
--- a/Source/3rdparty/Dragablz
+++ b/Source/3rdparty/Dragablz
@@ -1 +1 @@
-Subproject commit 3075a3cc69a57a73529daa739afab5370f10eafb
+Subproject commit 7ac6fe4543daabd2ce381d80fa002eb9952dae3c
diff --git a/Source/NETworkManager.sln.DotSettings b/Source/NETworkManager.sln.DotSettings
index 169874be03..8b76d71be8 100644
--- a/Source/NETworkManager.sln.DotSettings
+++ b/Source/NETworkManager.sln.DotSettings
@@ -51,6 +51,7 @@
True
True
True
+ True
True
True
True
diff --git a/Source/NETworkManager/Controls/DragablzInterTabClient.cs b/Source/NETworkManager/Controls/DragablzInterTabClient.cs
index 1839758c91..cd3eae37e4 100644
--- a/Source/NETworkManager/Controls/DragablzInterTabClient.cs
+++ b/Source/NETworkManager/Controls/DragablzInterTabClient.cs
@@ -4,23 +4,16 @@
namespace NETworkManager.Controls;
-public class DragablzInterTabClient : IInterTabClient
+public class DragablzInterTabClient(ApplicationName applicationName) : IInterTabClient
{
- private readonly ApplicationName _applicationName;
-
- public DragablzInterTabClient(ApplicationName applicationName)
- {
- _applicationName = applicationName;
- }
-
public INewTabHost GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
{
- var dragablzTabHostWindow = new DragablzTabHostWindow(_applicationName);
+ var dragablzTabHostWindow = new DragablzTabHostWindow(applicationName);
return new NewTabHost(dragablzTabHostWindow, dragablzTabHostWindow.TabsContainer);
}
public TabEmptiedResponse TabEmptiedHandler(TabablzControl tabControl, Window window)
{
- return window is MainWindow ? TabEmptiedResponse.DoNothing : TabEmptiedResponse.CloseWindowOrLayoutBranch;
+ return window is MainWindow ? TabEmptiedResponse.CloseLayoutBranch : TabEmptiedResponse.CloseWindowOrLayoutBranch;
}
}
\ No newline at end of file
diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
index 1ae9a143e6..6c5cc9324d 100644
--- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
+++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
@@ -21,14 +21,14 @@
-
+
+ Partition="{Binding InterTabPartition}" />
@@ -39,7 +39,7 @@
+ Partition="{Binding InterTabPartition}" />
-
+
- -->
+ Focusable="False"
+ Style="{StaticResource ProfileGridSplitter}" />
Date: Sun, 7 Apr 2024 20:54:12 +0200
Subject: [PATCH 06/22] Chore: Add tab count
---
.../ConfigurationInfo.cs | 239 +++++++++++++++---
.../ConfigurationManager.cs | 14 +-
2 files changed, 215 insertions(+), 38 deletions(-)
diff --git a/Source/NETworkManager.Settings/ConfigurationInfo.cs b/Source/NETworkManager.Settings/ConfigurationInfo.cs
index b2123bfb92..213e45cb2e 100644
--- a/Source/NETworkManager.Settings/ConfigurationInfo.cs
+++ b/Source/NETworkManager.Settings/ConfigurationInfo.cs
@@ -37,22 +37,22 @@ public ConfigurationInfo(bool isAdmin, string executionPath, string applicationF
///
/// Execution path of the application like "C:\Program Files\NETworkManager".
///
- public string ExecutionPath { get; set; }
+ public string ExecutionPath { get; }
///
/// Full path of the application like "C:\Program Files\NETworkManager\NETworkManager.exe"
///
- public string ApplicationFullName { get; set; }
+ public string ApplicationFullName { get; }
///
/// Application name like "NETworkManager".
///
- public string ApplicationName { get; set; }
+ public string ApplicationName { get; }
///
/// Indicates if the application is running in portable mode.
///
- public bool IsPortable { get; set; }
+ public bool IsPortable { get; }
#endregion
@@ -69,7 +69,6 @@ public ConfigurationInfo(bool isAdmin, string executionPath, string applicationF
public ApplicationName CurrentApplication { get; set; } = Models.ApplicationName.None;
private int _ipScannerTabCount;
-
public int IPScannerTabCount
{
get => _ipScannerTabCount;
@@ -79,41 +78,219 @@ public int IPScannerTabCount
return;
Debug.WriteLine("IPScanner current tabs: " + value);
-
+
_ipScannerTabCount = value;
OnPropertyChanged();
}
}
-
- ///
- /// Indicates if Remote Desktop has tabs.
- ///
- public bool RemoteDesktopHasTabs { get; set; }
- ///
- /// Indicates if PowerShell has tabs.
- ///
- public bool PowerShellHasTabs { get; set; }
+ private int _portScannerTabCount;
+ public int PortScannerTabCount
+ {
+ get => _portScannerTabCount;
+ set
+ {
+ if (value == _portScannerTabCount)
+ return;
- ///
- /// Indicates if PuTTY has tabs.
- ///
- public bool PuTTYHasTabs { get; set; }
+ Debug.WriteLine("Port Scanner current tabs: " + value);
- ///
- /// Indicates if AWS Session Manager has tabs.
- ///
- public bool AWSSessionManagerHasTabs { get; set; }
+ _portScannerTabCount = value;
+ OnPropertyChanged();
+ }
+ }
- ///
- /// Indicates if TigerVNC has tabs.
- ///
- public bool TigerVNCHasTabs { get; set; }
+ private int _tracerouteTabCount;
+ public int TracerouteTabCount
+ {
+ get => _tracerouteTabCount;
+ set
+ {
+ if (value == _tracerouteTabCount)
+ return;
- ///
- /// Indicates if WebConsole has tabs.
- ///
- public bool WebConsoleHasTabs { get; set; }
+ Debug.WriteLine("Traceroute current tabs: " + value);
+
+ _tracerouteTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _dnsLookupTabCount;
+ public int DNSLookupTabCount
+ {
+ get => _dnsLookupTabCount;
+ set
+ {
+ if (value == _dnsLookupTabCount)
+ return;
+
+ Debug.WriteLine("DNS Lookup current tabs: " + value);
+
+ _dnsLookupTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _remoteDesktopTabCount;
+ public int RemoteDesktopTabCount
+ {
+ get => _remoteDesktopTabCount;
+ set
+ {
+ if (value == _remoteDesktopTabCount)
+ return;
+
+ Debug.WriteLine("Remote Desktop current tabs: " + value);
+
+ _remoteDesktopTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _powerShellTabCount;
+ public int PowerShellTabCount
+ {
+ get => _powerShellTabCount;
+ set
+ {
+ if (value == _powerShellTabCount)
+ return;
+
+ Debug.WriteLine("PowerShell current tabs: " + value);
+
+ _powerShellTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _puTTYTabCount;
+ public int PuTTYTabCount
+ {
+ get => _puTTYTabCount;
+ set
+ {
+ if (value == _puTTYTabCount)
+ return;
+
+ Debug.WriteLine("PuTTY current tabs: " + value);
+
+ _puTTYTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _awsSessionManagerTabCount;
+ public int AWSSessionManagerTabCount
+ {
+ get => _awsSessionManagerTabCount;
+ set
+ {
+ if (value == _awsSessionManagerTabCount)
+ return;
+
+ Debug.WriteLine("AWS SSM current tabs: " + value);
+
+ _awsSessionManagerTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _tigerVNCTabCount;
+ public int TigerVNCTabCount
+ {
+ get => _tigerVNCTabCount;
+ set
+ {
+ if (value == _tigerVNCTabCount)
+ return;
+
+ Debug.WriteLine("TigerVNC current tabs: " + value);
+
+ _tigerVNCTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _webConsoleTabCount;
+ public int WebConsoleTabCount
+ {
+ get => _webConsoleTabCount;
+ set
+ {
+ if (value == _webConsoleTabCount)
+ return;
+
+ Debug.WriteLine("WebConsole current tabs: " + value);
+
+ _webConsoleTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _snmpTabCount;
+ public int SNMPTabCount
+ {
+ get => _snmpTabCount;
+ set
+ {
+ if (value == _snmpTabCount)
+ return;
+
+ Debug.WriteLine("SNMP current tabs: " + value);
+
+ _snmpTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _sntpLookupTabCount;
+ public int SNTPLookupTabCount
+ {
+ get => _sntpLookupTabCount;
+ set
+ {
+ if (value == _sntpLookupTabCount)
+ return;
+
+ Debug.WriteLine("SNTP Lookup current tabs: " + value);
+
+ _sntpLookupTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _whoisTabCount;
+ public int WhoisTabCount
+ {
+ get => _whoisTabCount;
+ set
+ {
+ if (value == _whoisTabCount)
+ return;
+
+ Debug.WriteLine("Whois current tabs: " + value);
+
+ _whoisTabCount = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private int _ipGeolocationTabCount;
+ public int IPGeolocationTabCount
+ {
+ get => _ipGeolocationTabCount;
+ set
+ {
+ if (value == _ipGeolocationTabCount)
+ return;
+
+ Debug.WriteLine("IP Geolocation current tabs: " + value);
+
+ _ipGeolocationTabCount = value;
+ OnPropertyChanged();
+ }
+ }
///
/// Private variable for .
diff --git a/Source/NETworkManager.Settings/ConfigurationManager.cs b/Source/NETworkManager.Settings/ConfigurationManager.cs
index 2fa6ce36dc..03e8b9f5a0 100644
--- a/Source/NETworkManager.Settings/ConfigurationManager.cs
+++ b/Source/NETworkManager.Settings/ConfigurationManager.cs
@@ -36,7 +36,7 @@ static ConfigurationManager()
///
/// Current that is used in the application.
///
- public static ConfigurationInfo Current { get; set; }
+ public static ConfigurationInfo Current { get; }
///
/// Method can be called before opening a dialog to fix airspace issues.
@@ -46,12 +46,12 @@ public static void OnDialogOpen()
{
switch (Current.CurrentApplication)
{
- case ApplicationName.RemoteDesktop when Current.RemoteDesktopHasTabs:
- case ApplicationName.PowerShell when Current.PowerShellHasTabs:
- case ApplicationName.PuTTY when Current.PuTTYHasTabs:
- case ApplicationName.AWSSessionManager when Current.AWSSessionManagerHasTabs:
- case ApplicationName.TigerVNC when Current.TigerVNCHasTabs:
- case ApplicationName.WebConsole when Current.WebConsoleHasTabs:
+ case ApplicationName.RemoteDesktop when Current.RemoteDesktopTabCount > 1:
+ case ApplicationName.PowerShell when Current.PowerShellTabCount > 1:
+ case ApplicationName.PuTTY when Current.PuTTYTabCount > 1:
+ case ApplicationName.AWSSessionManager when Current.AWSSessionManagerTabCount > 1:
+ case ApplicationName.TigerVNC when Current.TigerVNCTabCount > 1:
+ case ApplicationName.WebConsole when Current.WebConsoleTabCount > 1:
Current.FixAirspace = true;
break;
}
From 285fd96d40d3f83a628951107e03700985a6c3d6 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 20:55:18 +0200
Subject: [PATCH 07/22] Chore: Cleanup
---
.../ViewModels/AWSSessionManagerHostViewModel.cs | 9 +--------
.../ViewModels/PowerShellHostViewModel.cs | 8 +-------
Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs | 9 +--------
.../ViewModels/RemoteDesktopHostViewModel.cs | 10 +---------
.../NETworkManager/ViewModels/TigerVNCHostViewModel.cs | 9 +--------
.../ViewModels/WebConsoleHostViewModel.cs | 9 +--------
6 files changed, 6 insertions(+), 48 deletions(-)
diff --git a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
index 9cfd622019..ddfb45b4c8 100644
--- a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
@@ -309,8 +309,7 @@ public AWSSessionManagerHostViewModel(IDialogCoordinator instance)
InterTabClient = new DragablzInterTabClient(ApplicationName.AWSSessionManager);
- TabItems = new ObservableCollection();
- TabItems.CollectionChanged += TabItems_CollectionChanged;
+ TabItems = [];
// Profiles
SetProfilesView();
@@ -1038,11 +1037,5 @@ private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
IsSearching = false;
}
- private void TabItems_CollectionChanged(object sender,
- NotifyCollectionChangedEventArgs e)
- {
- ConfigurationManager.Current.AWSSessionManagerHasTabs = TabItems.Count > 0;
- }
-
#endregion
}
\ No newline at end of file
diff --git a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
index 47692898e7..6b5ca5b725 100644
--- a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
@@ -239,8 +239,7 @@ public PowerShellHostViewModel(IDialogCoordinator instance)
InterTabClient = new DragablzInterTabClient(ApplicationName.PowerShell);
- TabItems = new ObservableCollection();
- TabItems.CollectionChanged += TabItems_CollectionChanged;
+ TabItems = [];
// Profiles
SetProfilesView();
@@ -640,11 +639,6 @@ private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
IsSearching = false;
}
- private void TabItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- ConfigurationManager.Current.PowerShellHasTabs = TabItems.Count > 0;
- }
-
private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SettingsInfo.PowerShell_ApplicationFilePath))
diff --git a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
index 399cbb29d3..55b5c03473 100644
--- a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
@@ -239,8 +239,7 @@ public PuTTYHostViewModel(IDialogCoordinator instance)
InterTabClient = new DragablzInterTabClient(ApplicationName.PuTTY);
- TabItems = new ObservableCollection();
- TabItems.CollectionChanged += TabItems_CollectionChanged;
+ TabItems = [];
// Profiles
SetProfilesView();
@@ -742,11 +741,5 @@ private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
IsSearching = false;
}
- private void TabItems_CollectionChanged(object sender,
- NotifyCollectionChangedEventArgs e)
- {
- ConfigurationManager.Current.PuTTYHasTabs = TabItems.Count > 0;
- }
-
#endregion
}
\ No newline at end of file
diff --git a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
index bb99b9e9bd..a12dd0011f 100644
--- a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
@@ -181,8 +181,7 @@ public RemoteDesktopHostViewModel(IDialogCoordinator instance)
InterTabClient = new DragablzInterTabClient(ApplicationName.RemoteDesktop);
- TabItems = new ObservableCollection();
- TabItems.CollectionChanged += TabItems_CollectionChanged;
+ TabItems = [];
// Profiles
SetProfilesView();
@@ -630,12 +629,5 @@ private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
IsSearching = false;
}
-
- private void TabItems_CollectionChanged(object sender,
- NotifyCollectionChangedEventArgs e)
- {
- ConfigurationManager.Current.RemoteDesktopHasTabs = TabItems.Count > 0;
- }
-
#endregion
}
\ No newline at end of file
diff --git a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
index d48ded2bb6..f40a308b1b 100644
--- a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
@@ -200,8 +200,7 @@ public TigerVNCHostViewModel(IDialogCoordinator instance)
InterTabClient = new DragablzInterTabClient(ApplicationName.TigerVNC);
- TabItems = new ObservableCollection();
- TabItems.CollectionChanged += TabItems_CollectionChanged;
+ TabItems = [];
// Profiles
SetProfilesView();
@@ -561,12 +560,6 @@ private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
IsSearching = false;
}
- private void TabItems_CollectionChanged(object sender,
- NotifyCollectionChangedEventArgs e)
- {
- ConfigurationManager.Current.TigerVNCHasTabs = TabItems.Count > 0;
- }
-
private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SettingsInfo.TigerVNC_ApplicationFilePath))
diff --git a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
index 9f8c5c92a7..370c14f3d6 100644
--- a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
@@ -213,8 +213,7 @@ public WebConsoleHostViewModel(IDialogCoordinator instance)
InterTabClient = new DragablzInterTabClient(ApplicationName.WebConsole);
- TabItems = new ObservableCollection();
- TabItems.CollectionChanged += TabItems_CollectionChanged;
+ TabItems = [];
// Profiles
SetProfilesView();
@@ -529,11 +528,5 @@ private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
IsSearching = false;
}
- private void TabItems_CollectionChanged(object sender,
- NotifyCollectionChangedEventArgs e)
- {
- ConfigurationManager.Current.WebConsoleHasTabs = TabItems.Count > 0;
- }
-
#endregion
}
\ No newline at end of file
From 13e2e94a6b95577b570b7d5ebad4dbec9d9bf62d Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 20:56:40 +0200
Subject: [PATCH 08/22] Feature: Parition & Close handler
---
.../ViewModels/DNSLookupHostViewModel.cs | 22 +++++++++++++---
.../ViewModels/DNSLookupViewModel.cs | 10 +++++++
.../ViewModels/IPScannerHostViewModel.cs | 2 +-
.../ViewModels/IPScannerViewModel.cs | 4 +--
.../ViewModels/PortScannerHostViewModel.cs | 24 ++++++++++++++---
.../ViewModels/PortScannerViewModel.cs | 13 ++++++++--
.../ViewModels/TracerouteHostViewModel.cs | 26 +++++++++++++++----
.../ViewModels/TracerouteViewModel.cs | 12 +++++++++
.../Views/DNSLookupView.xaml.cs | 7 +++++
9 files changed, 102 insertions(+), 18 deletions(-)
diff --git a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
index 730145c24e..2968634d93 100644
--- a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
@@ -27,6 +27,22 @@ public class DNSLookupHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -175,11 +191,11 @@ public DNSLookupHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.DNSLookup);
-
+ InterTabPartition = ApplicationName.DNSLookup.ToString();
+
var tabId = Guid.NewGuid();
- TabItems =
- [
+ TabItems = [
new DragablzTabItem(Strings.NewTab, new DNSLookupView(tabId), tabId)
];
diff --git a/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs
index b72a8867e5..43c604f798 100644
--- a/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs
+++ b/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs
@@ -31,6 +31,7 @@ public class DNSLookupViewModel : ViewModelBase
private readonly Guid _tabId;
private bool _firstLoad = true;
+ private bool _closed;
private readonly bool _isLoading;
@@ -205,6 +206,8 @@ public DNSLookupViewModel(IDialogCoordinator instance, Guid tabId, string host)
_dialogCoordinator = instance;
+ ConfigurationManager.Current.DNSLookupTabCount++;
+
_tabId = tabId;
Host = host;
@@ -342,6 +345,13 @@ private void Query()
public void OnClose()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ ConfigurationManager.Current.DNSLookupTabCount--;
}
// Modify history list
diff --git a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
index 96d33952d9..4b6df5fdd6 100644
--- a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
@@ -196,7 +196,7 @@ public IPScannerHostViewModel(IDialogCoordinator instance)
var tabId = Guid.NewGuid();
TabItems = [
- new(Strings.NewTab, new IPScannerView(tabId), tabId)
+ new DragablzTabItem(Strings.NewTab, new IPScannerView(tabId), tabId)
];
// Profiles
diff --git a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs
index 4f8dcdbb22..75c4a5fb50 100644
--- a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs
@@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
-using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
@@ -41,6 +40,7 @@ public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal
private readonly Guid _tabId;
private bool _firstLoad = true;
+ private bool _closed;
private string _host;
@@ -583,8 +583,6 @@ await _dialogCoordinator.ShowMessageAsync(window, Strings.Error,
return _dialogCoordinator.ShowMetroDialogAsync(window, customDialog);
}
- private bool _closed;
-
public void OnClose()
{
// Prevent multiple calls
diff --git a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
index 312a6babb3..182c7953bc 100644
--- a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
@@ -27,6 +27,22 @@ public class PortScannerHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -175,13 +191,13 @@ public PortScannerHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.PortScanner);
+ InterTabPartition = ApplicationName.IPScanner.ToString();
var tabId = Guid.NewGuid();
- TabItems = new ObservableCollection
- {
- new(Strings.NewTab, new PortScannerView(tabId), tabId)
- };
+ TabItems = [
+ new DragablzTabItem(Strings.NewTab, new PortScannerView(tabId), tabId)
+ ];
// Profiles
SetProfilesView();
diff --git a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs
index 2387c1e7eb..3431775503 100644
--- a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs
@@ -34,8 +34,7 @@ public class PortScannerViewModel : ViewModelBase
private readonly Guid _tabId;
private bool _firstLoad = true;
-
- private string _lastSortDescriptionAscending = string.Empty;
+ private bool _closed;
private string _host;
@@ -231,6 +230,8 @@ public PortScannerViewModel(IDialogCoordinator instance, Guid tabId, string host
{
_dialogCoordinator = instance;
+ ConfigurationManager.Current.PortScannerTabCount++;
+
_tabId = tabId;
Host = host;
Ports = port;
@@ -263,9 +264,17 @@ public void OnLoaded()
public void OnClose()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
// Stop scan
if (IsRunning)
Stop();
+
+ ConfigurationManager.Current.PortScannerTabCount--;
}
#endregion
diff --git a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs
index fbe180b84a..e6b1e4b119 100644
--- a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs
@@ -27,6 +27,22 @@ public class TracerouteHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -175,13 +191,13 @@ public TracerouteHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.Traceroute);
-
+ InterTabPartition = ApplicationName.Traceroute.ToString();
+
var tabId = Guid.NewGuid();
- TabItems = new ObservableCollection
- {
- new(Strings.NewTab, new TracerouteView(tabId), tabId)
- };
+ TabItems = [
+ new DragablzTabItem(Strings.NewTab, new TracerouteView(tabId), tabId)
+ ];
// Profiles
SetProfilesView();
diff --git a/Source/NETworkManager/ViewModels/TracerouteViewModel.cs b/Source/NETworkManager/ViewModels/TracerouteViewModel.cs
index 60549642d4..ddd0e142c7 100644
--- a/Source/NETworkManager/ViewModels/TracerouteViewModel.cs
+++ b/Source/NETworkManager/ViewModels/TracerouteViewModel.cs
@@ -37,6 +37,7 @@ public class TracerouteViewModel : ViewModelBase
private readonly Guid _tabId;
private bool _firstLoad = true;
+ private bool _closed;
private string _host;
@@ -171,6 +172,8 @@ public TracerouteViewModel(IDialogCoordinator instance, Guid tabId, string host)
{
_dialogCoordinator = instance;
+ ConfigurationManager.Current.TracerouteTabCount++;
+
_tabId = tabId;
Host = host;
@@ -402,8 +405,17 @@ private void AddHostToHistory(string host)
public void OnClose()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ // Stop trace
if (IsRunning)
StopTrace();
+
+ ConfigurationManager.Current.TracerouteTabCount--;
}
#endregion
diff --git a/Source/NETworkManager/Views/DNSLookupView.xaml.cs b/Source/NETworkManager/Views/DNSLookupView.xaml.cs
index 852c454752..ed72e99eb5 100644
--- a/Source/NETworkManager/Views/DNSLookupView.xaml.cs
+++ b/Source/NETworkManager/Views/DNSLookupView.xaml.cs
@@ -17,12 +17,19 @@ public DNSLookupView(Guid tabId, string host = null)
_viewModel = new DNSLookupViewModel(DialogCoordinator.Instance, tabId, host);
DataContext = _viewModel;
+
+ Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
_viewModel.OnLoaded();
}
+
+ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
+ {
+ _viewModel.OnClose();
+ }
public void CloseTab()
{
From 78933e7276b3a0cf54244761dc6d58f0188402d1 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 21:07:10 +0200
Subject: [PATCH 09/22] Feature: Add Parition
---
.../AWSSessionManagerHostViewModel.cs | 18 +++++++++++++++++-
.../ViewModels/DNSLookupHostViewModel.cs | 1 -
.../ViewModels/IPScannerHostViewModel.cs | 1 -
.../ViewModels/PortScannerHostViewModel.cs | 1 -
.../ViewModels/PowerShellHostViewModel.cs | 16 ++++++++++++++++
.../ViewModels/PuTTYHostViewModel.cs | 16 ++++++++++++++++
.../ViewModels/RemoteDesktopHostViewModel.cs | 18 +++++++++++++++++-
.../ViewModels/TigerVNCHostViewModel.cs | 18 +++++++++++++++++-
.../ViewModels/TracerouteHostViewModel.cs | 1 -
.../ViewModels/WebConsoleHostViewModel.cs | 18 +++++++++++++++++-
10 files changed, 100 insertions(+), 8 deletions(-)
diff --git a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
index ddfb45b4c8..71d2e24a93 100644
--- a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
@@ -43,6 +43,21 @@ public class AWSSessionManagerHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -308,7 +323,8 @@ public AWSSessionManagerHostViewModel(IDialogCoordinator instance)
CheckSettings();
InterTabClient = new DragablzInterTabClient(ApplicationName.AWSSessionManager);
-
+ InterTabPartition = ApplicationName.AWSSessionManager.ToString();
+
TabItems = [];
// Profiles
diff --git a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
index 2968634d93..33335cdd71 100644
--- a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
@@ -29,7 +29,6 @@ public class DNSLookupHostViewModel : ViewModelBase, IProfileManager
public IInterTabClient InterTabClient { get; }
private string _interTabPartition;
-
public string InterTabPartition
{
get => _interTabPartition;
diff --git a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
index 4b6df5fdd6..3f2e7253e8 100644
--- a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
@@ -29,7 +29,6 @@ public class IPScannerHostViewModel : ViewModelBase, IProfileManager
public IInterTabClient InterTabClient { get; }
private string _interTabPartition;
-
public string InterTabPartition
{
get => _interTabPartition;
diff --git a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
index 182c7953bc..e79b61131b 100644
--- a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
@@ -29,7 +29,6 @@ public class PortScannerHostViewModel : ViewModelBase, IProfileManager
public IInterTabClient InterTabClient { get; }
private string _interTabPartition;
-
public string InterTabPartition
{
get => _interTabPartition;
diff --git a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
index 6b5ca5b725..5b4ed29fac 100644
--- a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
@@ -34,6 +34,21 @@ public class PowerShellHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -238,6 +253,7 @@ public PowerShellHostViewModel(IDialogCoordinator instance)
CheckSettings();
InterTabClient = new DragablzInterTabClient(ApplicationName.PowerShell);
+ InterTabPartition = ApplicationName.PowerShell.ToString();
TabItems = [];
diff --git a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
index 55b5c03473..c619226cd5 100644
--- a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
@@ -34,6 +34,21 @@ public class PuTTYHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -238,6 +253,7 @@ public PuTTYHostViewModel(IDialogCoordinator instance)
CheckSettings();
InterTabClient = new DragablzInterTabClient(ApplicationName.PuTTY);
+ InterTabPartition = ApplicationName.PuTTY.ToString();
TabItems = [];
diff --git a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
index a12dd0011f..a31cc781ff 100644
--- a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
@@ -32,6 +32,21 @@ public class RemoteDesktopHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -180,7 +195,8 @@ public RemoteDesktopHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.RemoteDesktop);
-
+ InterTabPartition = ApplicationName.RemoteDesktop.ToString();
+
TabItems = [];
// Profiles
diff --git a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
index f40a308b1b..c37ff8c1ea 100644
--- a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
@@ -34,6 +34,21 @@ public class TigerVNCHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -199,7 +214,8 @@ public TigerVNCHostViewModel(IDialogCoordinator instance)
CheckSettings();
InterTabClient = new DragablzInterTabClient(ApplicationName.TigerVNC);
-
+ InterTabPartition = ApplicationName.TigerVNC.ToString();
+
TabItems = [];
// Profiles
diff --git a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs
index e6b1e4b119..d9b19f61d8 100644
--- a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs
@@ -29,7 +29,6 @@ public class TracerouteHostViewModel : ViewModelBase, IProfileManager
public IInterTabClient InterTabClient { get; }
private string _interTabPartition;
-
public string InterTabPartition
{
get => _interTabPartition;
diff --git a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
index 370c14f3d6..517f456da9 100644
--- a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
@@ -33,6 +33,21 @@ public class WebConsoleHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -212,7 +227,8 @@ public WebConsoleHostViewModel(IDialogCoordinator instance)
}
InterTabClient = new DragablzInterTabClient(ApplicationName.WebConsole);
-
+ InterTabPartition = ApplicationName.WebConsole.ToString();
+
TabItems = [];
// Profiles
From dbdadd336d8ec214706fe6148c0bef259aed9fa3 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 21:12:51 +0200
Subject: [PATCH 10/22] Feature: Add Partition
---
.../ViewModels/IPGeolocationHostViewModel.cs | 27 ++++++++++++++-----
.../ViewModels/SNMPHostViewModel.cs | 18 ++++++++++++-
.../ViewModels/SNTPLookupHostViewModel.cs | 23 +++++++++++++---
.../ViewModels/WhoisHostViewModel.cs | 23 +++++++++++++---
4 files changed, 76 insertions(+), 15 deletions(-)
diff --git a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs
index bda38f40cd..533fe5bca7 100644
--- a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs
@@ -27,6 +27,21 @@ public class IPGeolocationHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -175,13 +190,13 @@ public IPGeolocationHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.IPGeolocation);
+ InterTabPartition = ApplicationName.IPScanner.ToString();
var tabId = Guid.NewGuid();
- TabItems = new ObservableCollection
- {
- new(Strings.NewTab, new IPGeolocationView(tabId), tabId)
- };
+ TabItems = [
+ new DragablzTabItem(Strings.NewTab, new IPGeolocationView(tabId), tabId)
+ ];
// Profiles
SetProfilesView();
@@ -323,10 +338,10 @@ private void ResizeProfile(bool dueToChangedSize)
private void AddTab(string domain = null)
{
- var _tabId = Guid.NewGuid();
+ var tabId = Guid.NewGuid();
TabItems.Add(new DragablzTabItem(domain ?? Strings.NewTab,
- new IPGeolocationView(_tabId, domain), _tabId));
+ new IPGeolocationView(tabId, domain), tabId));
SelectedTabIndex = TabItems.Count - 1;
}
diff --git a/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs b/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs
index 04fed9831d..34851de2dd 100644
--- a/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs
@@ -29,6 +29,21 @@ public class SNMPHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -177,8 +192,9 @@ public SNMPHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.SNMP);
+ InterTabPartition = ApplicationName.SNMP.ToString();
- TabItems = new ObservableCollection();
+ TabItems = [];
AddTab();
// Profiles
diff --git a/Source/NETworkManager/ViewModels/SNTPLookupHostViewModel.cs b/Source/NETworkManager/ViewModels/SNTPLookupHostViewModel.cs
index 5a5e32e542..e9c2406c41 100644
--- a/Source/NETworkManager/ViewModels/SNTPLookupHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/SNTPLookupHostViewModel.cs
@@ -15,6 +15,21 @@ public class SNTPLookupHostViewModel : ViewModelBase
#region Variables
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private int _selectedTabIndex;
@@ -39,13 +54,13 @@ public int SelectedTabIndex
public SNTPLookupHostViewModel()
{
InterTabClient = new DragablzInterTabClient(ApplicationName.SNTPLookup);
+ InterTabPartition = ApplicationName.SNTPLookup.ToString();
var tabId = Guid.NewGuid();
- TabItems = new ObservableCollection
- {
- new(Strings.NewTab, new SNTPLookupView(tabId), tabId)
- };
+ TabItems = [
+ new DragablzTabItem(Strings.NewTab, new SNTPLookupView(tabId), tabId)
+ ];
LoadSettings();
}
diff --git a/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs b/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs
index bba1026153..43cd690cde 100644
--- a/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs
@@ -27,6 +27,21 @@ public class WhoisHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
+
+ private string _interTabPartition;
+ public string InterTabPartition
+ {
+ get => _interTabPartition;
+ set
+ {
+ if (value == _interTabPartition)
+ return;
+
+ _interTabPartition = value;
+ OnPropertyChanged();
+ }
+ }
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -175,13 +190,13 @@ public WhoisHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.Whois);
+ InterTabPartition = ApplicationName.Whois.ToString();
var tabId = Guid.NewGuid();
- TabItems = new ObservableCollection
- {
- new(Strings.NewTab, new WhoisView(tabId), tabId)
- };
+ TabItems = [
+ new DragablzTabItem(Strings.NewTab, new WhoisView(tabId), tabId)
+ ];
// Profiles
SetProfilesView();
From fad221aeae32cf9cb5b95f8ad3f71e714a94a9f4 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 21:22:21 +0200
Subject: [PATCH 11/22] Feature: Add close handler
---
.../ViewModels/IPGeolocationViewModel.cs | 10 ++++++++++
Source/NETworkManager/ViewModels/SNMPViewModel.cs | 11 ++++++++++-
.../NETworkManager/ViewModels/SNTPLookupViewModel.cs | 12 ++++++++++--
Source/NETworkManager/ViewModels/WhoisViewModel.cs | 12 +++++++++++-
.../NETworkManager/Views/IPGeolocationView.xaml.cs | 7 +++++++
Source/NETworkManager/Views/SNMPView.xaml.cs | 7 +++++++
Source/NETworkManager/Views/SNTPLookupView.xaml.cs | 7 +++++++
Source/NETworkManager/Views/WhoisView.xaml.cs | 7 +++++++
8 files changed, 69 insertions(+), 4 deletions(-)
diff --git a/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs
index a83928b6b4..caebe46bcf 100644
--- a/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs
@@ -29,6 +29,7 @@ public class IPGeolocationViewModel : ViewModelBase
private readonly Guid _tabId;
private bool _firstLoad = true;
+ private bool _closed;
private string _host;
@@ -130,6 +131,8 @@ public IPGeolocationViewModel(IDialogCoordinator instance, Guid tabId, string ho
{
_dialogCoordinator = instance;
+ ConfigurationManager.Current.IPGeolocationTabCount++;
+
_tabId = tabId;
Host = host;
@@ -281,6 +284,13 @@ await _dialogCoordinator.ShowMessageAsync(window, Strings.Error,
public void OnClose()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ ConfigurationManager.Current.IPGeolocationTabCount--;
}
private void AddHostToHistory(string host)
diff --git a/Source/NETworkManager/ViewModels/SNMPViewModel.cs b/Source/NETworkManager/ViewModels/SNMPViewModel.cs
index bfa55e3896..7d53d2f328 100644
--- a/Source/NETworkManager/ViewModels/SNMPViewModel.cs
+++ b/Source/NETworkManager/ViewModels/SNMPViewModel.cs
@@ -35,6 +35,8 @@ public SNMPViewModel(IDialogCoordinator instance, Guid tabId, SNMPSessionInfo se
_isLoading = true;
_dialogCoordinator = instance;
+
+ ConfigurationManager.Current.SNMPTabCount++;
_tabId = tabId;
Host = sessionInfo?.Host;
@@ -101,8 +103,8 @@ public SNMPViewModel(IDialogCoordinator instance, Guid tabId, SNMPSessionInfo se
private CancellationTokenSource _cancellationTokenSource;
private readonly Guid _tabId;
-
private readonly bool _isLoading;
+ private bool _closed;
private string _host;
@@ -643,6 +645,13 @@ private void StopWork()
public void OnClose()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ ConfigurationManager.Current.SNMPTabCount--;
}
private async Task OpenOIDProfileSelection()
diff --git a/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs b/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs
index 86d3c5fdf2..1a9521b972 100644
--- a/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs
+++ b/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs
@@ -28,8 +28,8 @@ public class SNTPLookupViewModel : ViewModelBase
private readonly IDialogCoordinator _dialogCoordinator;
private readonly Guid _tabId;
-
private readonly bool _isLoading;
+ private bool _closed;
public ICollectionView SNTPServers { get; }
@@ -66,7 +66,7 @@ public bool IsRunning
}
}
- private ObservableCollection _results = new();
+ private ObservableCollection _results = [];
public ObservableCollection Results
{
@@ -151,6 +151,7 @@ public SNTPLookupViewModel(IDialogCoordinator instance, Guid tabId)
_isLoading = true;
_dialogCoordinator = instance;
+ ConfigurationManager.Current.SNTPLookupTabCount++;
_tabId = tabId;
@@ -280,6 +281,13 @@ await _dialogCoordinator.ShowMessageAsync(window, Strings.Error,
public void OnClose()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ ConfigurationManager.Current.SNTPLookupTabCount--;
}
#endregion
diff --git a/Source/NETworkManager/ViewModels/WhoisViewModel.cs b/Source/NETworkManager/ViewModels/WhoisViewModel.cs
index 4a87a3b955..ebf53af467 100644
--- a/Source/NETworkManager/ViewModels/WhoisViewModel.cs
+++ b/Source/NETworkManager/ViewModels/WhoisViewModel.cs
@@ -26,7 +26,8 @@ public class WhoisViewModel : ViewModelBase
private readonly Guid _tabId;
private bool _firstLoad = true;
-
+ private bool _closed;
+
private string _domain;
public string Domain
@@ -127,6 +128,8 @@ public WhoisViewModel(IDialogCoordinator instance, Guid tabId, string domain)
{
_dialogCoordinator = instance;
+ ConfigurationManager.Current.WhoisTabCount++;
+
_tabId = tabId;
Domain = domain;
@@ -222,6 +225,13 @@ private async Task Query()
public void OnClose()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ ConfigurationManager.Current.WhoisTabCount--;
}
private void AddDomainToHistory(string domain)
diff --git a/Source/NETworkManager/Views/IPGeolocationView.xaml.cs b/Source/NETworkManager/Views/IPGeolocationView.xaml.cs
index 44b391908f..d51d9cf5bd 100644
--- a/Source/NETworkManager/Views/IPGeolocationView.xaml.cs
+++ b/Source/NETworkManager/Views/IPGeolocationView.xaml.cs
@@ -16,6 +16,8 @@ public IPGeolocationView(Guid tabId, string domain = null)
_viewModel = new IPGeolocationViewModel(DialogCoordinator.Instance, tabId, domain);
DataContext = _viewModel;
+
+ Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
private void UserControl_OnLoaded(object sender, RoutedEventArgs e)
@@ -23,6 +25,11 @@ private void UserControl_OnLoaded(object sender, RoutedEventArgs e)
_viewModel.OnLoaded();
}
+ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
+ {
+ _viewModel.OnClose();
+ }
+
public void CloseTab()
{
_viewModel.OnClose();
diff --git a/Source/NETworkManager/Views/SNMPView.xaml.cs b/Source/NETworkManager/Views/SNMPView.xaml.cs
index aa49b7a903..befa1b0447 100644
--- a/Source/NETworkManager/Views/SNMPView.xaml.cs
+++ b/Source/NETworkManager/Views/SNMPView.xaml.cs
@@ -22,8 +22,15 @@ public SNMPView(Guid tabId, SNMPSessionInfo sessionInfo)
_viewModel = new SNMPViewModel(DialogCoordinator.Instance, tabId, sessionInfo);
DataContext = _viewModel;
+
+ Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
+ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
+ {
+ _viewModel.OnClose();
+ }
+
public void CloseTab()
{
_viewModel.OnClose();
diff --git a/Source/NETworkManager/Views/SNTPLookupView.xaml.cs b/Source/NETworkManager/Views/SNTPLookupView.xaml.cs
index 4acc6bdc5c..06368e6e5a 100644
--- a/Source/NETworkManager/Views/SNTPLookupView.xaml.cs
+++ b/Source/NETworkManager/Views/SNTPLookupView.xaml.cs
@@ -17,8 +17,15 @@ public SNTPLookupView(Guid tabId)
_viewModel = new SNTPLookupViewModel(DialogCoordinator.Instance, tabId);
DataContext = _viewModel;
+
+ Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
+ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
+ {
+ _viewModel.OnClose();
+ }
+
public void CloseTab()
{
_viewModel.OnClose();
diff --git a/Source/NETworkManager/Views/WhoisView.xaml.cs b/Source/NETworkManager/Views/WhoisView.xaml.cs
index 95af1a9c3b..2891d1204a 100644
--- a/Source/NETworkManager/Views/WhoisView.xaml.cs
+++ b/Source/NETworkManager/Views/WhoisView.xaml.cs
@@ -16,6 +16,8 @@ public WhoisView(Guid tabId, string domain = null)
_viewModel = new WhoisViewModel(DialogCoordinator.Instance, tabId, domain);
DataContext = _viewModel;
+
+ Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
private void UserControl_OnLoaded(object sender, RoutedEventArgs e)
@@ -23,6 +25,11 @@ private void UserControl_OnLoaded(object sender, RoutedEventArgs e)
_viewModel.OnLoaded();
}
+ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
+ {
+ _viewModel.OnClose();
+ }
+
public void CloseTab()
{
_viewModel.OnClose();
From e4c491ec9702f1fe635c3f7ffc60ef69eff067b0 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 21:47:12 +0200
Subject: [PATCH 12/22] Feature: Close handler
---
.../Controls/AWSSessionManagerControl.xaml.cs | 19 +++++++++----
.../Controls/PowerShellControl.xaml.cs | 19 +++++++++----
.../Controls/PuTTYControl.xaml.cs | 16 ++++++++---
.../Controls/RemoteDesktopControl.xaml.cs | 27 ++++++++++++++-----
.../Controls/TightVNCControl.xaml.cs | 19 +++++++++----
.../Controls/WebConsoleControl.xaml.cs | 22 ++++++++++-----
6 files changed, 91 insertions(+), 31 deletions(-)
diff --git a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
index aa37240df3..40029a8b67 100644
--- a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
+++ b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
@@ -28,7 +28,7 @@ private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
#region Variables
private bool _initialized;
- private bool _closing; // When the tab is closed --> OnClose()
+ private bool _closed;
private readonly IDialogCoordinator _dialogCoordinator;
@@ -78,6 +78,8 @@ public AWSSessionManagerControl(AWSSessionManagerSessionInfo sessionInfo)
_dialogCoordinator = DialogCoordinator.Instance;
+ ConfigurationManager.Current.AWSSessionManagerTabCount++;
+
_sessionInfo = sessionInfo;
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
@@ -108,7 +110,7 @@ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
public ICommand ReconnectCommand
{
- get { return new RelayCommand(p => ReconnectAction()); }
+ get { return new RelayCommand(_ => ReconnectAction()); }
}
private void ReconnectAction()
@@ -191,7 +193,7 @@ private async Task Connect()
}
catch (Exception ex)
{
- if (!_closing)
+ if (!_closed)
{
var settings = AppearanceManager.MetroDialog;
settings.AffirmativeButtonText = Strings.OK;
@@ -227,7 +229,7 @@ public void ResizeEmbeddedWindow()
WindowHost.ClientSize.Height, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE);
}
- public void Disconnect()
+ private void Disconnect()
{
if (IsConnected)
_process.Kill();
@@ -243,9 +245,16 @@ private void Reconnect()
public void CloseTab()
{
- _closing = true;
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+ // Disconnect the session
Disconnect();
+
+ ConfigurationManager.Current.AWSSessionManagerTabCount--;
}
#endregion
diff --git a/Source/NETworkManager/Controls/PowerShellControl.xaml.cs b/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
index 2290f037a5..52b76b985b 100644
--- a/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
+++ b/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
@@ -28,7 +28,7 @@ private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
#region Variables
private bool _initialized;
- private bool _closing; // When the tab is closed --> OnClose()
+ private bool _closed;
private readonly IDialogCoordinator _dialogCoordinator;
@@ -78,6 +78,8 @@ public PowerShellControl(PowerShellSessionInfo sessionInfo)
_dialogCoordinator = DialogCoordinator.Instance;
+ ConfigurationManager.Current.PowerShellTabCount++;
+
_sessionInfo = sessionInfo;
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
@@ -108,7 +110,7 @@ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
public ICommand ReconnectCommand
{
- get { return new RelayCommand(p => ReconnectAction()); }
+ get { return new RelayCommand(_ => ReconnectAction()); }
}
private void ReconnectAction()
@@ -191,7 +193,7 @@ private async Task Connect()
}
catch (Exception ex)
{
- if (!_closing)
+ if (!_closed)
{
var settings = AppearanceManager.MetroDialog;
settings.AffirmativeButtonText = Strings.OK;
@@ -227,7 +229,7 @@ public void ResizeEmbeddedWindow()
WindowHost.ClientSize.Height, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE);
}
- public void Disconnect()
+ private void Disconnect()
{
if (IsConnected)
_process.Kill();
@@ -243,9 +245,16 @@ private void Reconnect()
public void CloseTab()
{
- _closing = true;
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+ // Disconnect the session
Disconnect();
+
+ ConfigurationManager.Current.PowerShellTabCount--;
}
#endregion
diff --git a/Source/NETworkManager/Controls/PuTTYControl.xaml.cs b/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
index 8f2886389b..50235ff6c2 100644
--- a/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
+++ b/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
@@ -30,6 +30,7 @@ private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
private bool _initialized;
private bool _closing; // When the tab is closed --> OnClose()
+ private bool _closed;
private readonly IDialogCoordinator _dialogCoordinator;
@@ -78,6 +79,8 @@ public PuTTYControl(PuTTYSessionInfo sessionInfo)
DataContext = this;
_dialogCoordinator = DialogCoordinator.Instance;
+
+ ConfigurationManager.Current.PuTTYTabCount++;
_sessionInfo = sessionInfo;
@@ -110,7 +113,7 @@ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
public ICommand ReconnectCommand
{
- get { return new RelayCommand(p => ReconnectAction()); }
+ get { return new RelayCommand(_ => ReconnectAction()); }
}
private void ReconnectAction()
@@ -244,7 +247,7 @@ public void ResizeEmbeddedWindow()
WindowHost.ClientSize.Height, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE);
}
- public void Disconnect()
+ private void Disconnect()
{
if (IsConnected)
_process.Kill();
@@ -267,9 +270,16 @@ public void RestartSession()
public void CloseTab()
{
- _closing = true;
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+ // Disconnect the session
Disconnect();
+
+ ConfigurationManager.Current.PuTTYTabCount--;
}
#endregion
diff --git a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
index a7aa430702..331b545e03 100644
--- a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
+++ b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
@@ -8,6 +8,7 @@
using MSTSCLib;
using NETworkManager.Localization.Resources;
using NETworkManager.Models.RemoteDesktop;
+using NETworkManager.Settings;
using NETworkManager.Utilities;
namespace NETworkManager.Controls;
@@ -17,6 +18,7 @@ public partial class RemoteDesktopControl : UserControlBase
#region Variables
private bool _initialized;
+ private bool _closed;
private readonly RemoteDesktopSessionInfo _sessionInfo;
@@ -26,9 +28,9 @@ public partial class RemoteDesktopControl : UserControlBase
public double RdpClientWidth
{
get => _rdpClientWidth;
- set
+ private set
{
- if (value == _rdpClientWidth)
+ if (Math.Abs(value - _rdpClientWidth) < double.Epsilon)
return;
_rdpClientWidth = value;
@@ -42,9 +44,9 @@ public double RdpClientWidth
public double RdpClientHeight
{
get => _rdpClientHeight;
- set
+ private set
{
- if (value == _rdpClientHeight)
+ if (Math.Abs(value - _rdpClientHeight) < double.Epsilon)
return;
_rdpClientHeight = value;
@@ -87,7 +89,7 @@ public bool IsConnecting
public string DisconnectReason
{
get => _disconnectReason;
- set
+ private set
{
if (value == _disconnectReason)
return;
@@ -120,6 +122,8 @@ public RemoteDesktopControl(RemoteDesktopSessionInfo sessionInfo)
{
InitializeComponent();
DataContext = this;
+
+ ConfigurationManager.Current.RemoteDesktopTabCount++;
_sessionInfo = sessionInfo;
@@ -147,7 +151,7 @@ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
public ICommand ReconnectCommand
{
- get { return new RelayCommand(p => ReconnectAction()); }
+ get { return new RelayCommand(_ => ReconnectAction()); }
}
private void ReconnectAction()
@@ -157,7 +161,7 @@ private void ReconnectAction()
public ICommand DisconnectCommand
{
- get { return new RelayCommand(p => DisconnectAction()); }
+ get { return new RelayCommand(_ => DisconnectAction()); }
}
private void DisconnectAction()
@@ -373,7 +377,16 @@ private void Disconnect()
public void CloseTab()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ // Disconnect the session
Disconnect();
+
+ ConfigurationManager.Current.RemoteDesktopTabCount--;
}
///
diff --git a/Source/NETworkManager/Controls/TightVNCControl.xaml.cs b/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
index c6e159998e..2a9f4e19d5 100644
--- a/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
+++ b/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
@@ -28,7 +28,7 @@ private void TigerVNCGrid_SizeChanged(object sender, SizeChangedEventArgs e)
#region Variables
private bool _initialized;
- private bool _closing; // When the tab is closed --> OnClose()
+ private bool _closed;
private readonly IDialogCoordinator _dialogCoordinator;
@@ -77,6 +77,8 @@ public TigerVNCControl(TigerVNCSessionInfo sessionInfo)
DataContext = this;
_dialogCoordinator = DialogCoordinator.Instance;
+
+ ConfigurationManager.Current.TigerVNCTabCount++;
_sessionInfo = sessionInfo;
@@ -109,7 +111,7 @@ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
public ICommand ReconnectCommand
{
- get { return new RelayCommand(p => ReconnectAction()); }
+ get { return new RelayCommand(_ => ReconnectAction()); }
}
private void ReconnectAction()
@@ -205,7 +207,7 @@ private async Task Connect()
}
catch (Exception ex)
{
- if (!_closing)
+ if (!_closed)
{
var settings = AppearanceManager.MetroDialog;
settings.AffirmativeButtonText = Strings.OK;
@@ -234,7 +236,7 @@ private void ResizeEmbeddedWindow()
WindowHost.ClientSize.Height, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE);
}
- public void Disconnect()
+ private void Disconnect()
{
if (IsConnected)
_process.Kill();
@@ -250,9 +252,16 @@ private void Reconnect()
public void CloseTab()
{
- _closing = true;
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+ // Disconnect the session
Disconnect();
+
+ ConfigurationManager.Current.TigerVNCTabCount--;
}
#endregion
diff --git a/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs b/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
index 2f899fcf59..04b5a97104 100644
--- a/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
+++ b/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
@@ -13,7 +13,8 @@ public partial class WebConsoleControl : UserControlBase
#region Variables
private bool _initialized;
-
+ private bool _closed;
+
private readonly WebConsoleSessionInfo _sessionInfo;
private bool _isLoading;
@@ -70,6 +71,8 @@ public WebConsoleControl(WebConsoleSessionInfo sessionInfo)
InitializeComponent();
DataContext = this;
+ ConfigurationManager.Current.WebConsoleTabCount++;
+
_sessionInfo = sessionInfo;
Browser2.NavigationStarting += Browser2_NavigationStarting;
@@ -109,7 +112,7 @@ private bool NavigateCommand_CanExecute(object obj)
return !IsLoading;
}
- public ICommand NavigateCommand => new RelayCommand(p => NavigateAction(), NavigateCommand_CanExecute);
+ public ICommand NavigateCommand => new RelayCommand(_ => NavigateAction(), NavigateCommand_CanExecute);
private void NavigateAction()
{
@@ -121,7 +124,7 @@ private bool StopCommand_CanExecute(object obj)
return IsLoading;
}
- public ICommand StopCommand => new RelayCommand(p => StopAction(), StopCommand_CanExecute);
+ public ICommand StopCommand => new RelayCommand(_ => StopAction(), StopCommand_CanExecute);
private void StopAction()
{
@@ -133,7 +136,7 @@ private bool ReloadCommand_CanExecute(object obj)
return !IsLoading;
}
- public ICommand ReloadCommand => new RelayCommand(p => ReloadAction(), ReloadCommand_CanExecute);
+ public ICommand ReloadCommand => new RelayCommand(_ => ReloadAction(), ReloadCommand_CanExecute);
private void ReloadAction()
{
@@ -145,7 +148,7 @@ private bool GoBackCommand_CanExecute(object obj)
return !IsLoading && Browser2.CanGoBack;
}
- public ICommand GoBackCommand => new RelayCommand(p => GoBackAction(), GoBackCommand_CanExecute);
+ public ICommand GoBackCommand => new RelayCommand(_ => GoBackAction(), GoBackCommand_CanExecute);
private void GoBackAction()
{
@@ -157,7 +160,7 @@ private bool GoForwardCommand_CanExecute(object obj)
return !IsLoading && Browser2.CanGoForward;
}
- public ICommand GoForwardCommand => new RelayCommand(p => GoForwardAction(), GoForwardCommand_CanExecute);
+ public ICommand GoForwardCommand => new RelayCommand(_ => GoForwardAction(), GoForwardCommand_CanExecute);
private void GoForwardAction()
{
@@ -180,6 +183,13 @@ private void Stop()
public void CloseTab()
{
+ // Prevent multiple calls
+ if (_closed)
+ return;
+
+ _closed = true;
+
+ ConfigurationManager.Current.WebConsoleTabCount--;
}
#endregion
From eeb1a564aa14cb2c09dbfcc108b26424b6ad5fba Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 21:51:19 +0200
Subject: [PATCH 13/22] Fix: Tab count issues
---
.../NETworkManager.Settings/ConfigurationManager.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Source/NETworkManager.Settings/ConfigurationManager.cs b/Source/NETworkManager.Settings/ConfigurationManager.cs
index 03e8b9f5a0..f95b48a9fe 100644
--- a/Source/NETworkManager.Settings/ConfigurationManager.cs
+++ b/Source/NETworkManager.Settings/ConfigurationManager.cs
@@ -46,12 +46,12 @@ public static void OnDialogOpen()
{
switch (Current.CurrentApplication)
{
- case ApplicationName.RemoteDesktop when Current.RemoteDesktopTabCount > 1:
- case ApplicationName.PowerShell when Current.PowerShellTabCount > 1:
- case ApplicationName.PuTTY when Current.PuTTYTabCount > 1:
- case ApplicationName.AWSSessionManager when Current.AWSSessionManagerTabCount > 1:
- case ApplicationName.TigerVNC when Current.TigerVNCTabCount > 1:
- case ApplicationName.WebConsole when Current.WebConsoleTabCount > 1:
+ case ApplicationName.RemoteDesktop when Current.RemoteDesktopTabCount > 0:
+ case ApplicationName.PowerShell when Current.PowerShellTabCount > 0:
+ case ApplicationName.PuTTY when Current.PuTTYTabCount > 0:
+ case ApplicationName.AWSSessionManager when Current.AWSSessionManagerTabCount > 0:
+ case ApplicationName.TigerVNC when Current.TigerVNCTabCount > 0:
+ case ApplicationName.WebConsole when Current.WebConsoleTabCount > 0:
Current.FixAirspace = true;
break;
}
From eb67916a66b990ad861efa3f79054bcf10a8034b Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 23:29:03 +0200
Subject: [PATCH 14/22] Feature: Add dockablz
---
.../Controls/DragablzTabHostWindow.xaml | 8 +-
.../AWSSessionManagerHostViewModel.cs | 18 +-
.../ViewModels/IPGeolocationHostViewModel.cs | 2 +-
.../ViewModels/PortScannerHostViewModel.cs | 2 +-
.../ViewModels/PowerShellHostViewModel.cs | 18 +-
.../ViewModels/PuTTYHostViewModel.cs | 18 +-
.../Views/AWSSessionManagerHostView.xaml | 297 +++++++-------
.../Views/AWSSessionManagerHostView.xaml.cs | 2 -
.../Views/DNSLookupHostView.xaml | 99 +++--
.../Views/DNSLookupHostView.xaml.cs | 2 -
.../Views/IPGeolocationHostView.xaml | 45 ++-
.../Views/IPGeolocationHostView.xaml.cs | 2 -
.../Views/IPScannerHostView.xaml | 74 ++--
.../Views/PortScannerHostView.xaml | 99 +++--
.../Views/PortScannerHostView.xaml.cs | 2 -
.../Views/PowerShellHostView.xaml | 297 +++++++-------
.../Views/PowerShellHostView.xaml.cs | 2 -
.../NETworkManager/Views/PuTTYHostView.xaml | 323 +++++++--------
.../Views/PuTTYHostView.xaml.cs | 2 -
.../Views/RemoteDesktopHostView.xaml | 375 +++++++++---------
.../Views/RemoteDesktopHostView.xaml.cs | 2 -
Source/NETworkManager/Views/SNMPHostView.xaml | 99 +++--
.../NETworkManager/Views/SNMPHostView.xaml.cs | 2 -
.../Views/SNTPLookupHostView.xaml | 97 +++--
.../Views/SNTPLookupHostView.xaml.cs | 2 -
.../Views/TigerVNCHostView.xaml | 267 +++++++------
.../Views/TigerVNCHostView.xaml.cs | 2 -
.../Views/TracerouteHostView.xaml | 99 +++--
.../Views/TracerouteHostView.xaml.cs | 2 -
.../Views/WebConsoleHostView.xaml | 267 +++++++------
.../Views/WebConsoleHostView.xaml.cs | 2 -
.../NETworkManager/Views/WhoisHostView.xaml | 45 ++-
.../Views/WhoisHostView.xaml.cs | 2 -
33 files changed, 1368 insertions(+), 1207 deletions(-)
diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
index e1701e832c..1d83b92675 100644
--- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
+++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
@@ -18,6 +18,9 @@
dialogs:DialogParticipation.Register="{Binding}"
ShowCloseButton="False"
d:DataContext="{d:DesignInstance controls:DragablzTabHostWindow}">
+
+
+
@@ -34,10 +37,7 @@
-
-
-
-
+
diff --git a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
index 71d2e24a93..6a9859f982 100644
--- a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
@@ -62,6 +62,7 @@ public string InterTabPartition
private readonly bool _isLoading;
private bool _isViewActive = true;
+ private bool _disableFocusEmbeddedWindow;
private bool _isAWSCLIInstalled;
@@ -138,8 +139,21 @@ public bool IsSyncing
}
}
- private bool _disableFocusEmbeddedWindow;
+ private int _selectedTabIndex;
+ public int SelectedTabIndex
+ {
+ get => _selectedTabIndex;
+ set
+ {
+ if (value == _selectedTabIndex)
+ return;
+
+ _selectedTabIndex = value;
+ OnPropertyChanged();
+ }
+ }
+
private DragablzTabItem _selectedTabItem;
public DragablzTabItem SelectedTabItem
@@ -837,7 +851,7 @@ private void Connect(AWSSessionManagerSessionInfo sessionInfo, string header = n
// Select the added tab
_disableFocusEmbeddedWindow = true;
- SelectedTabItem = TabItems.Last();
+ SelectedTabIndex = TabItems.Count - 1;
_disableFocusEmbeddedWindow = false;
}
diff --git a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs
index 533fe5bca7..4e0824a2c4 100644
--- a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs
@@ -190,7 +190,7 @@ public IPGeolocationHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.IPGeolocation);
- InterTabPartition = ApplicationName.IPScanner.ToString();
+ InterTabPartition = ApplicationName.IPGeolocation.ToString();
var tabId = Guid.NewGuid();
diff --git a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
index e79b61131b..a55cc117ab 100644
--- a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs
@@ -190,7 +190,7 @@ public PortScannerHostViewModel(IDialogCoordinator instance)
_dialogCoordinator = instance;
InterTabClient = new DragablzInterTabClient(ApplicationName.PortScanner);
- InterTabPartition = ApplicationName.IPScanner.ToString();
+ InterTabPartition = ApplicationName.PortScanner.ToString();
var tabId = Guid.NewGuid();
diff --git a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
index 5b4ed29fac..c2b475bdd3 100644
--- a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
@@ -53,6 +53,7 @@ public string InterTabPartition
private readonly bool _isLoading;
private bool _isViewActive = true;
+ private bool _disableFocusEmbeddedWindow;
private bool _isConfigured;
@@ -69,8 +70,21 @@ public bool IsConfigured
}
}
- private bool _disableFocusEmbeddedWindow;
+ private int _selectedTabIndex;
+ public int SelectedTabIndex
+ {
+ get => _selectedTabIndex;
+ set
+ {
+ if (value == _selectedTabIndex)
+ return;
+
+ _selectedTabIndex = value;
+ OnPropertyChanged();
+ }
+ }
+
private DragablzTabItem _selectedTabItem;
public DragablzTabItem SelectedTabItem
@@ -502,7 +516,7 @@ private void Connect(PowerShellSessionInfo sessionInfo, string header = null)
// Select the added tab
_disableFocusEmbeddedWindow = true;
- SelectedTabItem = TabItems.Last();
+ SelectedTabIndex = TabItems.Count - 1;
_disableFocusEmbeddedWindow = false;
}
diff --git a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
index c619226cd5..9515218745 100644
--- a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
@@ -53,6 +53,7 @@ public string InterTabPartition
private readonly bool _isLoading;
private bool _isViewActive = true;
+ private bool _disableFocusEmbeddedWindow;
private bool _isConfigured;
@@ -69,8 +70,21 @@ public bool IsConfigured
}
}
- private bool _disableFocusEmbeddedWindow;
+ private int _selectedTabIndex;
+ public int SelectedTabIndex
+ {
+ get => _selectedTabIndex;
+ set
+ {
+ if (value == _selectedTabIndex)
+ return;
+
+ _selectedTabIndex = value;
+ OnPropertyChanged();
+ }
+ }
+
private DragablzTabItem _selectedTabItem;
public DragablzTabItem SelectedTabItem
@@ -528,7 +542,7 @@ private void Connect(PuTTYSessionInfo sessionInfo, string header = null)
// Select the added tab
_disableFocusEmbeddedWindow = true;
- SelectedTabItem = TabItems.Last();
+ SelectedTabIndex = TabItems.Count - 1;
_disableFocusEmbeddedWindow = false;
}
diff --git a/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml b/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml
index d1acb7c6b0..72aaae5980 100644
--- a/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml
+++ b/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
@@ -20,8 +21,10 @@
+
+
@@ -50,150 +53,158 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -127,8 +127,8 @@
+ Focusable="False"
+ Style="{StaticResource ProfileGridSplitter}" />
+
@@ -29,50 +31,59 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/PortScannerHostView.xaml.cs b/Source/NETworkManager/Views/PortScannerHostView.xaml.cs
index 3d7580b6bd..66f5010b5f 100644
--- a/Source/NETworkManager/Views/PortScannerHostView.xaml.cs
+++ b/Source/NETworkManager/Views/PortScannerHostView.xaml.cs
@@ -15,8 +15,6 @@ public PortScannerHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.PortScanner.ToString();
}
private void ContextMenu_Opened(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/PowerShellHostView.xaml b/Source/NETworkManager/Views/PowerShellHostView.xaml
index 5777105e68..d194a9bf4f 100644
--- a/Source/NETworkManager/Views/PowerShellHostView.xaml
+++ b/Source/NETworkManager/Views/PowerShellHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
@@ -20,7 +21,9 @@
+
+
@@ -43,150 +46,158 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/PowerShellHostView.xaml.cs b/Source/NETworkManager/Views/PowerShellHostView.xaml.cs
index 5fbf72af70..aff3e6322e 100644
--- a/Source/NETworkManager/Views/PowerShellHostView.xaml.cs
+++ b/Source/NETworkManager/Views/PowerShellHostView.xaml.cs
@@ -18,8 +18,6 @@ public PowerShellHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.PowerShell.ToString();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/PuTTYHostView.xaml b/Source/NETworkManager/Views/PuTTYHostView.xaml
index 3cd69abe6d..7c480ccad9 100644
--- a/Source/NETworkManager/Views/PuTTYHostView.xaml
+++ b/Source/NETworkManager/Views/PuTTYHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
@@ -20,7 +21,9 @@
+
+
@@ -43,163 +46,171 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/PuTTYHostView.xaml.cs b/Source/NETworkManager/Views/PuTTYHostView.xaml.cs
index b04bf99de8..c818de1f97 100644
--- a/Source/NETworkManager/Views/PuTTYHostView.xaml.cs
+++ b/Source/NETworkManager/Views/PuTTYHostView.xaml.cs
@@ -18,8 +18,6 @@ public PuTTYHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.PuTTY.ToString();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/RemoteDesktopHostView.xaml b/Source/NETworkManager/Views/RemoteDesktopHostView.xaml
index be1e346d1b..7d6ccaf70e 100644
--- a/Source/NETworkManager/Views/RemoteDesktopHostView.xaml
+++ b/Source/NETworkManager/Views/RemoteDesktopHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
@@ -19,7 +20,9 @@
+
+
@@ -32,189 +35,197 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs b/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs
index 5dd30d73f5..3b3e0c3ff0 100644
--- a/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs
+++ b/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs
@@ -18,8 +18,6 @@ public RemoteDesktopHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.RemoteDesktop.ToString();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/SNMPHostView.xaml b/Source/NETworkManager/Views/SNMPHostView.xaml
index 49d2248981..5250f39f6c 100644
--- a/Source/NETworkManager/Views/SNMPHostView.xaml
+++ b/Source/NETworkManager/Views/SNMPHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
@@ -16,6 +17,7 @@
+
@@ -29,50 +31,59 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/SNMPHostView.xaml.cs b/Source/NETworkManager/Views/SNMPHostView.xaml.cs
index 76e3183a0d..2ae25bd035 100644
--- a/Source/NETworkManager/Views/SNMPHostView.xaml.cs
+++ b/Source/NETworkManager/Views/SNMPHostView.xaml.cs
@@ -15,8 +15,6 @@ public SNMPHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.SNMP.ToString();
}
private void ContextMenu_Opened(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/SNTPLookupHostView.xaml b/Source/NETworkManager/Views/SNTPLookupHostView.xaml
index 38b940ff80..5988972033 100644
--- a/Source/NETworkManager/Views/SNTPLookupHostView.xaml
+++ b/Source/NETworkManager/Views/SNTPLookupHostView.xaml
@@ -4,60 +4,73 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
+ xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
+ xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
dialogs:DialogParticipation.Register="{Binding}"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:SNTPLookupHostViewModel}">
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/SNTPLookupHostView.xaml.cs b/Source/NETworkManager/Views/SNTPLookupHostView.xaml.cs
index 22aa442022..8489833b5e 100644
--- a/Source/NETworkManager/Views/SNTPLookupHostView.xaml.cs
+++ b/Source/NETworkManager/Views/SNTPLookupHostView.xaml.cs
@@ -11,8 +11,6 @@ public SNTPLookupHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.SNTPLookup.ToString();
}
public void OnViewHide()
diff --git a/Source/NETworkManager/Views/TigerVNCHostView.xaml b/Source/NETworkManager/Views/TigerVNCHostView.xaml
index f0a74c8476..566ea4040b 100644
--- a/Source/NETworkManager/Views/TigerVNCHostView.xaml
+++ b/Source/NETworkManager/Views/TigerVNCHostView.xaml
@@ -7,6 +7,7 @@
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
@@ -19,7 +20,9 @@
+
+
@@ -42,135 +45,143 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/TigerVNCHostView.xaml.cs b/Source/NETworkManager/Views/TigerVNCHostView.xaml.cs
index 67bd6e06e6..a20dc1cb21 100644
--- a/Source/NETworkManager/Views/TigerVNCHostView.xaml.cs
+++ b/Source/NETworkManager/Views/TigerVNCHostView.xaml.cs
@@ -19,8 +19,6 @@ public TigerVNCHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.TigerVNC.ToString();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/TracerouteHostView.xaml b/Source/NETworkManager/Views/TracerouteHostView.xaml
index cdcce5a47a..6a56c52d41 100644
--- a/Source/NETworkManager/Views/TracerouteHostView.xaml
+++ b/Source/NETworkManager/Views/TracerouteHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
@@ -16,6 +17,7 @@
+
@@ -29,50 +31,59 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/TracerouteHostView.xaml.cs b/Source/NETworkManager/Views/TracerouteHostView.xaml.cs
index 0eac21f362..d4a1bca14e 100644
--- a/Source/NETworkManager/Views/TracerouteHostView.xaml.cs
+++ b/Source/NETworkManager/Views/TracerouteHostView.xaml.cs
@@ -16,8 +16,6 @@ public TracerouteHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.Traceroute.ToString();
}
private void ContextMenu_Opened(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/WebConsoleHostView.xaml b/Source/NETworkManager/Views/WebConsoleHostView.xaml
index cbeb0cade9..6c8bb2e1e4 100644
--- a/Source/NETworkManager/Views/WebConsoleHostView.xaml
+++ b/Source/NETworkManager/Views/WebConsoleHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
@@ -19,7 +20,9 @@
+
+
@@ -42,135 +45,143 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/WebConsoleHostView.xaml.cs b/Source/NETworkManager/Views/WebConsoleHostView.xaml.cs
index b0f297a1b4..286ca1ed54 100644
--- a/Source/NETworkManager/Views/WebConsoleHostView.xaml.cs
+++ b/Source/NETworkManager/Views/WebConsoleHostView.xaml.cs
@@ -15,8 +15,6 @@ public WebConsoleHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.WebConsole.ToString();
}
private void ContextMenu_Opened(object sender, RoutedEventArgs e)
diff --git a/Source/NETworkManager/Views/WhoisHostView.xaml b/Source/NETworkManager/Views/WhoisHostView.xaml
index b76c0a0f42..4371659aae 100644
--- a/Source/NETworkManager/Views/WhoisHostView.xaml
+++ b/Source/NETworkManager/Views/WhoisHostView.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
@@ -16,6 +17,7 @@
+
@@ -29,12 +31,28 @@
Width="{Binding ProfileWidth, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
MaxWidth="{x:Static settings:GlobalStaticConfiguration.Profile_MaxWidthExpanded}" />
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
diff --git a/Source/NETworkManager/Views/WhoisHostView.xaml.cs b/Source/NETworkManager/Views/WhoisHostView.xaml.cs
index 9ac3ce9aeb..ba327aa810 100644
--- a/Source/NETworkManager/Views/WhoisHostView.xaml.cs
+++ b/Source/NETworkManager/Views/WhoisHostView.xaml.cs
@@ -15,8 +15,6 @@ public WhoisHostView()
{
InitializeComponent();
DataContext = _viewModel;
-
- InterTabController.Partition = ApplicationName.Whois.ToString();
}
private void ContextMenu_Opened(object sender, RoutedEventArgs e)
From 5fa57b4c7edd4c3b4ddec992a0f13eafd1337b42 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Sun, 7 Apr 2024 23:57:36 +0200
Subject: [PATCH 15/22] Feature: ContextMenu in dragged out / splitted tab
---
.../Controls/DragablzTabHostWindow.xaml | 38 ++--
.../Views/AWSSessionManagerHostView.xaml | 104 ++++-----
.../Views/PowerShellHostView.xaml | 198 +++++++++---------
.../NETworkManager/Views/PuTTYHostView.xaml | 104 ++++-----
.../Views/RemoteDesktopHostView.xaml | 101 ++++-----
.../Views/TigerVNCHostView.xaml | 168 +++++++--------
.../Views/WebConsoleHostView.xaml | 168 +++++++--------
7 files changed, 447 insertions(+), 434 deletions(-)
diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
index 1d83b92675..a7c3476ec5 100644
--- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
+++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
@@ -26,24 +26,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml b/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml
index 72aaae5980..016d1ea8f9 100644
--- a/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml
+++ b/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml
@@ -55,56 +55,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -199,7 +151,57 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -96,103 +195,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -205,7 +157,57 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -219,7 +173,56 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -95,88 +179,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -95,88 +179,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Date: Mon, 8 Apr 2024 00:35:48 +0200
Subject: [PATCH 16/22] Fix: Update headers
---
.../Controls/AWSSessionManagerControl.xaml.cs | 9 +--
.../Controls/DragablzTabItem.cs | 66 +++++++++++++++----
.../Controls/PowerShellControl.xaml.cs | 7 +-
.../Controls/PuTTYControl.xaml.cs | 7 +-
.../Controls/RemoteDesktopControl.xaml.cs | 4 +-
.../Controls/TightVNCControl.xaml.cs | 4 +-
.../Controls/WebConsoleControl.xaml.cs | 4 +-
.../AWSSessionManagerHostViewModel.cs | 4 +-
.../ViewModels/DNSLookupViewModel.cs | 21 +++---
.../ViewModels/IPGeolocationViewModel.cs | 7 +-
.../ViewModels/IPScannerViewModel.cs | 7 +-
.../ViewModels/PortScannerViewModel.cs | 9 +--
.../ViewModels/PowerShellHostViewModel.cs | 4 +-
.../ViewModels/PuTTYHostViewModel.cs | 11 ++--
.../ViewModels/RemoteDesktopHostViewModel.cs | 5 +-
.../ViewModels/SNMPViewModel.cs | 7 +-
.../ViewModels/SNTPLookupViewModel.cs | 7 +-
.../ViewModels/TigerVNCHostViewModel.cs | 4 +-
.../ViewModels/TracerouteViewModel.cs | 7 +-
.../ViewModels/WebConsoleHostViewModel.cs | 4 +-
.../ViewModels/WhoisViewModel.cs | 7 +-
21 files changed, 116 insertions(+), 89 deletions(-)
diff --git a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
index 40029a8b67..7dceef8a26 100644
--- a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
+++ b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
@@ -26,12 +26,12 @@ private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
#endregion
#region Variables
-
private bool _initialized;
private bool _closed;
-
+
private readonly IDialogCoordinator _dialogCoordinator;
-
+
+ private readonly Guid _tabId;
private readonly AWSSessionManagerSessionInfo _sessionInfo;
private Process _process;
@@ -71,7 +71,7 @@ public bool IsConnecting
#region Constructor, load
- public AWSSessionManagerControl(AWSSessionManagerSessionInfo sessionInfo)
+ public AWSSessionManagerControl(Guid tabId, AWSSessionManagerSessionInfo sessionInfo)
{
InitializeComponent();
DataContext = this;
@@ -80,6 +80,7 @@ public AWSSessionManagerControl(AWSSessionManagerSessionInfo sessionInfo)
ConfigurationManager.Current.AWSSessionManagerTabCount++;
+ _tabId = tabId;
_sessionInfo = sessionInfo;
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
diff --git a/Source/NETworkManager/Controls/DragablzTabItem.cs b/Source/NETworkManager/Controls/DragablzTabItem.cs
index 146f6e2cf1..3a695dd110 100644
--- a/Source/NETworkManager/Controls/DragablzTabItem.cs
+++ b/Source/NETworkManager/Controls/DragablzTabItem.cs
@@ -1,19 +1,21 @@
using System;
+using System.Linq;
+using System.Windows;
using System.Windows.Controls;
+using Dragablz;
+using NETworkManager.Utilities;
using NETworkManager.ViewModels;
namespace NETworkManager.Controls;
public class DragablzTabItem : ViewModelBase
{
- private string _header;
-
- public DragablzTabItem(string header, UserControl view)
- {
- Header = header;
- View = view;
- }
-
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// Header of the tab.
+ /// View of the tab.
+ /// Id of the tab.
public DragablzTabItem(string header, UserControl view, Guid id)
{
Header = header;
@@ -21,10 +23,18 @@ public DragablzTabItem(string header, UserControl view, Guid id)
Id = id;
}
+ ///
+ /// Private field for the property.
+ ///
+ private string _header;
+
+ ///
+ /// Header of the tab.
+ ///
public string Header
{
get => _header;
- set
+ private set
{
if (value == _header)
return;
@@ -34,7 +44,39 @@ public string Header
}
}
- public UserControl View { get; set; }
+ ///
+ /// View of the tab.
+ ///
+ public UserControl View { get; }
+
+ ///
+ /// Id of the tab.
+ ///
+ public Guid Id { get; }
- public Guid Id { get; set; }
-}
\ No newline at end of file
+ ///
+ /// Method to set the of a based on the
+ /// in the current by finding the tab item in all `s
+ /// via the .
+ ///
+ /// Id of the tab to set the header.
+ /// New header to set.
+ public static void SetTabHeader(Guid tabId, string header)
+ {
+ var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
+
+ if (window == null)
+ return;
+
+ foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
+ {
+ var tabItem = tabablzControl.Items.OfType().FirstOrDefault(x => x.Id == tabId);
+
+ if (tabItem == null)
+ continue;
+
+ tabItem.Header = header;
+ break;
+ }
+ }
+}
diff --git a/Source/NETworkManager/Controls/PowerShellControl.xaml.cs b/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
index 52b76b985b..82fcb333a7 100644
--- a/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
+++ b/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
@@ -26,12 +26,12 @@ private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
#endregion
#region Variables
-
private bool _initialized;
private bool _closed;
private readonly IDialogCoordinator _dialogCoordinator;
+ private readonly Guid _tabId;
private readonly PowerShellSessionInfo _sessionInfo;
private Process _process;
@@ -71,7 +71,7 @@ public bool IsConnecting
#region Constructor, load
- public PowerShellControl(PowerShellSessionInfo sessionInfo)
+ public PowerShellControl(Guid tabId, PowerShellSessionInfo sessionInfo)
{
InitializeComponent();
DataContext = this;
@@ -80,8 +80,9 @@ public PowerShellControl(PowerShellSessionInfo sessionInfo)
ConfigurationManager.Current.PowerShellTabCount++;
+ _tabId = tabId;
_sessionInfo = sessionInfo;
-
+
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
diff --git a/Source/NETworkManager/Controls/PuTTYControl.xaml.cs b/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
index 50235ff6c2..930bbe55da 100644
--- a/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
+++ b/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
@@ -29,11 +29,11 @@ private void WindowGrid_SizeChanged(object sender, SizeChangedEventArgs e)
#region Variables
private bool _initialized;
- private bool _closing; // When the tab is closed --> OnClose()
private bool _closed;
private readonly IDialogCoordinator _dialogCoordinator;
+ private readonly Guid _tabId;
private readonly PuTTYSessionInfo _sessionInfo;
private Process _process;
@@ -73,7 +73,7 @@ public bool IsConnecting
#region Constructor, load
- public PuTTYControl(PuTTYSessionInfo sessionInfo)
+ public PuTTYControl(Guid tabId, PuTTYSessionInfo sessionInfo)
{
InitializeComponent();
DataContext = this;
@@ -82,6 +82,7 @@ public PuTTYControl(PuTTYSessionInfo sessionInfo)
ConfigurationManager.Current.PuTTYTabCount++;
+ _tabId = tabId;
_sessionInfo = sessionInfo;
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
@@ -211,7 +212,7 @@ private async Task Connect()
}
catch (Exception ex)
{
- if (!_closing)
+ if (!_closed)
{
var settings = AppearanceManager.MetroDialog;
settings.AffirmativeButtonText = Strings.OK;
diff --git a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
index 331b545e03..8c5ab0362c 100644
--- a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
+++ b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
@@ -20,6 +20,7 @@ public partial class RemoteDesktopControl : UserControlBase
private bool _initialized;
private bool _closed;
+ private readonly Guid _tabId;
private readonly RemoteDesktopSessionInfo _sessionInfo;
// Fix WindowsFormsHost width
@@ -118,13 +119,14 @@ public bool IsReconnecting
#region Constructor, load
- public RemoteDesktopControl(RemoteDesktopSessionInfo sessionInfo)
+ public RemoteDesktopControl(Guid tabId, RemoteDesktopSessionInfo sessionInfo)
{
InitializeComponent();
DataContext = this;
ConfigurationManager.Current.RemoteDesktopTabCount++;
+ _tabId = tabId;
_sessionInfo = sessionInfo;
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
diff --git a/Source/NETworkManager/Controls/TightVNCControl.xaml.cs b/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
index 2a9f4e19d5..13f3f631d0 100644
--- a/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
+++ b/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
@@ -32,6 +32,7 @@ private void TigerVNCGrid_SizeChanged(object sender, SizeChangedEventArgs e)
private readonly IDialogCoordinator _dialogCoordinator;
+ private readonly Guid _tabId;
private readonly TigerVNCSessionInfo _sessionInfo;
private Process _process;
@@ -71,7 +72,7 @@ public bool IsConnecting
#region Constructor, load
- public TigerVNCControl(TigerVNCSessionInfo sessionInfo)
+ public TigerVNCControl(Guid tabId, TigerVNCSessionInfo sessionInfo)
{
InitializeComponent();
DataContext = this;
@@ -80,6 +81,7 @@ public TigerVNCControl(TigerVNCSessionInfo sessionInfo)
ConfigurationManager.Current.TigerVNCTabCount++;
+ _tabId = tabId;
_sessionInfo = sessionInfo;
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
diff --git a/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs b/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
index 04b5a97104..404594225a 100644
--- a/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
+++ b/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
@@ -15,6 +15,7 @@ public partial class WebConsoleControl : UserControlBase
private bool _initialized;
private bool _closed;
+ private readonly Guid _tabId;
private readonly WebConsoleSessionInfo _sessionInfo;
private bool _isLoading;
@@ -66,13 +67,14 @@ public string Url
#region Constructor, load
- public WebConsoleControl(WebConsoleSessionInfo sessionInfo)
+ public WebConsoleControl(Guid tabId, WebConsoleSessionInfo sessionInfo)
{
InitializeComponent();
DataContext = this;
ConfigurationManager.Current.WebConsoleTabCount++;
+ _tabId = tabId;
_sessionInfo = sessionInfo;
Browser2.NavigationStarting += Browser2_NavigationStarting;
diff --git a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
index 6a9859f982..3cb0536280 100644
--- a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
@@ -847,7 +847,9 @@ private void Connect(AWSSessionManagerSessionInfo sessionInfo, string header = n
{
sessionInfo.ApplicationFilePath = SettingsManager.Current.AWSSessionManager_ApplicationFilePath;
- TabItems.Add(new DragablzTabItem(header ?? sessionInfo.InstanceID, new AWSSessionManagerControl(sessionInfo)));
+ var tabId = Guid.NewGuid();
+
+ TabItems.Add(new DragablzTabItem(header ?? sessionInfo.InstanceID, new AWSSessionManagerControl(tabId, sessionInfo), tabId));
// Select the added tab
_disableFocusEmbeddedWindow = true;
diff --git a/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs
index 43c604f798..dbf47f7d20 100644
--- a/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs
+++ b/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs
@@ -10,7 +10,6 @@
using System.Windows.Input;
using System.Windows.Threading;
using DnsClient;
-using Dragablz;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using NETworkManager.Controls;
@@ -207,7 +206,7 @@ public DNSLookupViewModel(IDialogCoordinator instance, Guid tabId, string host)
_dialogCoordinator = instance;
ConfigurationManager.Current.DNSLookupTabCount++;
-
+
_tabId = tabId;
Host = host;
@@ -295,6 +294,8 @@ private void ExportAction()
#region Methods
+
+
private void Query()
{
IsStatusMessageDisplayed = false;
@@ -304,13 +305,8 @@ private void Query()
// Reset the latest results
Results.Clear();
-
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = Host;
+
+ DragablzTabItem.SetTabHeader(_tabId, Host);
AddHostToHistory(Host);
@@ -348,9 +344,9 @@ public void OnClose()
// Prevent multiple calls
if (_closed)
return;
-
+
_closed = true;
-
+
ConfigurationManager.Current.DNSLookupTabCount--;
}
@@ -373,7 +369,7 @@ private void AddHostToHistory(string host)
private async Task Export()
{
var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
+
var customDialog = new CustomDialog
{
Title = Strings.Export
@@ -417,6 +413,7 @@ await _dialogCoordinator.ShowMessageAsync(window, Strings.Error,
await _dialogCoordinator.ShowMetroDialogAsync(window, customDialog);
}
+
#endregion
#region Events
diff --git a/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs
index caebe46bcf..811f8a338c 100644
--- a/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs
@@ -193,12 +193,7 @@ private async Task Query()
Result = null;
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = Host;
+ DragablzTabItem.SetTabHeader(_tabId, Host);
try
{
diff --git a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs
index 75c4a5fb50..9192036044 100644
--- a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs
+++ b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs
@@ -377,12 +377,7 @@ private async Task Start()
Results.Clear();
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = Host;
+ DragablzTabItem.SetTabHeader(_tabId, Host);
_cancellationTokenSource = new CancellationTokenSource();
diff --git a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs
index 3431775503..428ee3e6cf 100644
--- a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs
@@ -357,13 +357,8 @@ private async Task Start()
Results.Clear();
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = Host;
-
+ DragablzTabItem.SetTabHeader(_tabId, Host);
+
_cancellationTokenSource = new CancellationTokenSource();
// Resolve hostnames
diff --git a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
index c2b475bdd3..df227cb0da 100644
--- a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs
@@ -510,9 +510,11 @@ private void Connect(PowerShellSessionInfo sessionInfo, string header = null)
{
sessionInfo.ApplicationFilePath = SettingsManager.Current.PowerShell_ApplicationFilePath;
+ var tabId = Guid.NewGuid();
+
TabItems.Add(new DragablzTabItem(
header ?? (sessionInfo.EnableRemoteConsole ? sessionInfo.Host : Strings.PowerShell),
- new PowerShellControl(sessionInfo)));
+ new PowerShellControl(tabId, sessionInfo), tabId));
// Select the added tab
_disableFocusEmbeddedWindow = true;
diff --git a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
index 9515218745..d4bf38eef5 100644
--- a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs
@@ -34,8 +34,9 @@ public class PuTTYHostViewModel : ViewModelBase, IProfileManager
private readonly DispatcherTimer _searchDispatcherTimer = new();
public IInterTabClient InterTabClient { get; }
-
+
private string _interTabPartition;
+
public string InterTabPartition
{
get => _interTabPartition;
@@ -48,7 +49,7 @@ public string InterTabPartition
OnPropertyChanged();
}
}
-
+
public ObservableCollection TabItems { get; }
private readonly bool _isLoading;
@@ -84,7 +85,7 @@ public int SelectedTabIndex
OnPropertyChanged();
}
}
-
+
private DragablzTabItem _selectedTabItem;
public DragablzTabItem SelectedTabItem
@@ -538,7 +539,9 @@ private void Connect(PuTTYSessionInfo sessionInfo, string header = null)
// Must be added here. So that it works with profiles and the connect dialog.
sessionInfo.ApplicationFilePath = SettingsManager.Current.PuTTY_ApplicationFilePath;
- TabItems.Add(new DragablzTabItem(header ?? sessionInfo.HostOrSerialLine, new PuTTYControl(sessionInfo)));
+ var tabId = Guid.NewGuid();
+
+ TabItems.Add(new DragablzTabItem(header ?? sessionInfo.HostOrSerialLine, new PuTTYControl(tabId, sessionInfo), tabId));
// Select the added tab
_disableFocusEmbeddedWindow = true;
diff --git a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
index a31cc781ff..26409f8b46 100644
--- a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs
@@ -508,7 +508,10 @@ private async Task ConnectProfileAs()
private void Connect(RemoteDesktopSessionInfo sessionInfo, string header = null)
{
- TabItems.Add(new DragablzTabItem(header ?? sessionInfo.Hostname, new RemoteDesktopControl(sessionInfo)));
+ var tabId = Guid.NewGuid();
+
+ TabItems.Add(new DragablzTabItem(header ?? sessionInfo.Hostname, new RemoteDesktopControl(tabId, sessionInfo), tabId));
+
SelectedTabIndex = TabItems.Count - 1;
}
diff --git a/Source/NETworkManager/ViewModels/SNMPViewModel.cs b/Source/NETworkManager/ViewModels/SNMPViewModel.cs
index 7d53d2f328..ad8cb0f51e 100644
--- a/Source/NETworkManager/ViewModels/SNMPViewModel.cs
+++ b/Source/NETworkManager/ViewModels/SNMPViewModel.cs
@@ -530,12 +530,7 @@ private async void StartWork()
QueryResults.Clear();
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = Host;
+ DragablzTabItem.SetTabHeader(_tabId, Host);
// Try to parse the string into an IP-Address
if (!IPAddress.TryParse(Host, out var ipAddress))
diff --git a/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs b/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs
index 1a9521b972..7b91c7ed03 100644
--- a/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs
+++ b/Source/NETworkManager/ViewModels/SNTPLookupViewModel.cs
@@ -215,12 +215,7 @@ private void Query()
// Reset the latest results
Results.Clear();
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = SNTPServer.Name;
+ DragablzTabItem.SetTabHeader(_tabId, SNTPServer.Name);
SNTPLookupSettings settings = new(
SettingsManager.Current.SNTPLookup_Timeout
diff --git a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
index c37ff8c1ea..45996d3a79 100644
--- a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs
@@ -427,7 +427,9 @@ private void Connect(TigerVNCSessionInfo sessionInfo, string header = null)
{
sessionInfo.ApplicationFilePath = SettingsManager.Current.TigerVNC_ApplicationFilePath;
- TabItems.Add(new DragablzTabItem(header ?? sessionInfo.Host, new TigerVNCControl(sessionInfo)));
+ var tabId = Guid.NewGuid();
+
+ TabItems.Add(new DragablzTabItem(header ?? sessionInfo.Host, new TigerVNCControl(tabId, sessionInfo), tabId));
SelectedTabIndex = TabItems.Count - 1;
}
diff --git a/Source/NETworkManager/ViewModels/TracerouteViewModel.cs b/Source/NETworkManager/ViewModels/TracerouteViewModel.cs
index ddd0e142c7..31982eb25c 100644
--- a/Source/NETworkManager/ViewModels/TracerouteViewModel.cs
+++ b/Source/NETworkManager/ViewModels/TracerouteViewModel.cs
@@ -285,12 +285,7 @@ private async Task StartTrace()
Results.Clear();
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = Host;
+ DragablzTabItem.SetTabHeader(_tabId, Host);
_cancellationTokenSource = new CancellationTokenSource();
diff --git a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
index 517f456da9..f859ea7916 100644
--- a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
+++ b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs
@@ -410,7 +410,9 @@ private void ConnectProfile()
private void Connect(WebConsoleSessionInfo sessionInfo, string header = null)
{
- TabItems.Add(new DragablzTabItem(header ?? sessionInfo.Url, new WebConsoleControl(sessionInfo)));
+ var tabId = Guid.NewGuid();
+
+ TabItems.Add(new DragablzTabItem(header ?? sessionInfo.Url, new WebConsoleControl(tabId, sessionInfo), tabId));
SelectedTabIndex = TabItems.Count - 1;
}
diff --git a/Source/NETworkManager/ViewModels/WhoisViewModel.cs b/Source/NETworkManager/ViewModels/WhoisViewModel.cs
index ebf53af467..1559c5c45d 100644
--- a/Source/NETworkManager/ViewModels/WhoisViewModel.cs
+++ b/Source/NETworkManager/ViewModels/WhoisViewModel.cs
@@ -190,12 +190,7 @@ private async Task Query()
Result = null;
- // Change the tab title (not nice, but it works)
- var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
-
- if (window != null)
- foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
- tabablzControl.Items.OfType().First(x => x.Id == _tabId).Header = Domain;
+ DragablzTabItem.SetTabHeader(_tabId, Domain);
try
{
From b94c6ef0455e1fad767f7e9630f64180e355d33f Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Mon, 8 Apr 2024 01:39:40 +0200
Subject: [PATCH 17/22] Feature: Add interface to close tab
---
.../ClipboardHelper.cs | 15 ++-
.../NETworkManager.Utilities.csproj | 1 +
.../Controls/AWSSessionManagerControl.xaml.cs | 2 +-
.../Controls/DragablzTabHostWindow.xaml | 8 +-
.../Controls/DragablzTabHostWindow.xaml.cs | 105 +++++++-----------
.../Controls/IDragablzTabItem.cs | 17 +++
.../Controls/PowerShellControl.xaml.cs | 2 +-
.../Controls/PuTTYControl.xaml.cs | 2 +-
.../Controls/RemoteDesktopControl.xaml.cs | 2 +-
.../Controls/TightVNCControl.xaml.cs | 2 +-
.../Controls/WebConsoleControl.xaml.cs | 2 +-
.../Views/DNSLookupView.xaml.cs | 3 +-
.../Views/IPGeolocationView.xaml.cs | 3 +-
.../Views/IPScannerView.xaml.cs | 3 +-
.../Views/PortScannerView.xaml.cs | 3 +-
.../Views/PowerShellHostView.xaml.cs | 1 +
.../Views/RemoteDesktopHostView.xaml.cs | 1 +
Source/NETworkManager/Views/SNMPView.xaml.cs | 7 +-
.../Views/SNTPLookupView.xaml.cs | 3 +-
.../Views/TracerouteView.xaml.cs | 3 +-
Source/NETworkManager/Views/WhoisView.xaml.cs | 3 +-
21 files changed, 100 insertions(+), 88 deletions(-)
create mode 100644 Source/NETworkManager/Controls/IDragablzTabItem.cs
diff --git a/Source/NETworkManager.Utilities/ClipboardHelper.cs b/Source/NETworkManager.Utilities/ClipboardHelper.cs
index 3d3507a68f..973b4b660c 100644
--- a/Source/NETworkManager.Utilities/ClipboardHelper.cs
+++ b/Source/NETworkManager.Utilities/ClipboardHelper.cs
@@ -1,4 +1,6 @@
-using System.Windows;
+using System;
+using System.Windows;
+using log4net;
namespace NETworkManager.Utilities;
@@ -7,12 +9,19 @@ namespace NETworkManager.Utilities;
///
public static class ClipboardHelper
{
+ private static readonly ILog Log = LogManager.GetLogger(typeof(ClipboardHelper));
+
///
/// Methods to set a text to the clipboard.
///
/// Some text...
public static void SetClipboard(string text)
{
- Clipboard.SetDataObject(text, true);
+ try {
+ Clipboard.SetDataObject(text, true);
+ }
+ catch (Exception e) {
+ Log.Error($"Failed to set clipboard: {e.Message}");
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj b/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj
index 88b8712ff5..98feba3747 100644
--- a/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj
+++ b/Source/NETworkManager.Utilities/NETworkManager.Utilities.csproj
@@ -18,5 +18,6 @@
+
\ No newline at end of file
diff --git a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
index 7dceef8a26..8e9042f12c 100644
--- a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
+++ b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml.cs
@@ -13,7 +13,7 @@
namespace NETworkManager.Controls;
-public partial class AWSSessionManagerControl : UserControlBase
+public partial class AWSSessionManagerControl : UserControlBase, IDragablzTabItem
{
#region Events
diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
index a7c3476ec5..de94bc07db 100644
--- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
+++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml
@@ -16,7 +16,7 @@
Style="{DynamicResource DefaultWindow}" MinWidth="800" Width="1024" Height="768" MinHeight="600"
TitleAlignment="Left" Activated="MetroWindow_Activated"
dialogs:DialogParticipation.Register="{Binding}"
- ShowCloseButton="False"
+ Closing="DragablzTabHostWindow_OnClosing"
d:DataContext="{d:DesignInstance controls:DragablzTabHostWindow}">
@@ -731,7 +731,8 @@
-
+
-
+
diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs
index caca0e568e..012d05d381 100644
--- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs
+++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs
@@ -1,7 +1,9 @@
using System;
using System.ComponentModel;
+using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using Dragablz;
@@ -12,7 +14,7 @@
using NETworkManager.Models.RemoteDesktop;
using NETworkManager.Settings;
using NETworkManager.Utilities;
-using NETworkManager.Views;
+using Application = System.Windows.Application;
namespace NETworkManager.Controls;
@@ -57,13 +59,13 @@ private async void FocusEmbeddedWindow()
switch (ApplicationName)
{
case ApplicationName.PowerShell:
- ((PowerShellControl)((DragablzTabItem)TabsContainer?.SelectedItem)?.View)?.FocusEmbeddedWindow();
+ //((PowerShellControl)((DragablzTabItem)TabsContainer?.SelectedItem)?.View)?.FocusEmbeddedWindow();
break;
case ApplicationName.PuTTY:
- ((PuTTYControl)((DragablzTabItem)TabsContainer?.SelectedItem)?.View)?.FocusEmbeddedWindow();
+ //((PuTTYControl)((DragablzTabItem)TabsContainer?.SelectedItem)?.View)?.FocusEmbeddedWindow();
break;
case ApplicationName.AWSSessionManager:
- ((AWSSessionManagerControl)((DragablzTabItem)TabsContainer?.SelectedItem)?.View)?.FocusEmbeddedWindow();
+ //((AWSSessionManagerControl)((DragablzTabItem)TabsContainer?.SelectedItem)?.View)?.FocusEmbeddedWindow();
break;
}
}
@@ -76,6 +78,21 @@ private void MetroWindow_Activated(object sender, EventArgs e)
{
FocusEmbeddedWindow();
}
+
+ private void DragablzTabHostWindow_OnClosing(object sender, CancelEventArgs e)
+ {
+ // Close all tabs properly when the window is closing
+ var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
+
+ if (window == null)
+ return;
+
+ foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(window))
+ {
+ foreach(var tabItem in tabablzControl.Items.OfType())
+ ((IDragablzTabItem)tabItem.View).CloseTab();
+ }
+ }
#endregion
@@ -147,52 +164,7 @@ public bool HeaderContextMenuIsOpen
private void CloseItemAction(ItemActionCallbackArgs args)
{
- // Switch between application identifiers...
- switch (_applicationName)
- {
- case ApplicationName.IPScanner:
- ((IPScannerView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.PortScanner:
- ((PortScannerView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.Traceroute:
- ((TracerouteView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.DNSLookup:
- ((DNSLookupView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.RemoteDesktop:
- ((RemoteDesktopControl)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.PowerShell:
- ((PowerShellControl)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.PuTTY:
- ((PuTTYControl)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.AWSSessionManager:
- ((AWSSessionManagerControl)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.TigerVNC:
- ((TigerVNCControl)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.WebConsole:
- ((WebConsoleControl)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.SNMP:
- ((SNMPView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.SNTPLookup:
- ((SNTPLookupView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.Whois:
- ((WhoisView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- case ApplicationName.IPGeolocation:
- ((IPGeolocationView)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
- break;
- }
+ ((IDragablzTabItem)((DragablzTabItem)args.DragablzItem.Content).View).CloseTab();
}
#region RemoteDesktop commands
@@ -256,22 +228,23 @@ private void RemoteDesktop_AdjustScreenAction(object view)
private async void RemoteDesktop_SendCtrlAltDelAction(object view)
{
- if (view is RemoteDesktopControl control)
- try
- {
- control.SendKey(Keystroke.CtrlAltDel);
- }
- catch (Exception ex)
- {
- ConfigurationManager.OnDialogOpen();
-
- await this.ShowMessageAsync(Strings.Error,
- string.Format("{0}\n\nMessage:\n{1}",
- Strings.CouldNotSendKeystroke, ex.Message,
- MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog));
-
- ConfigurationManager.OnDialogClose();
- }
+ if (view is not RemoteDesktopControl control)
+ return;
+
+ try
+ {
+ control.SendKey(Keystroke.CtrlAltDel);
+ }
+ catch (Exception ex)
+ {
+ ConfigurationManager.OnDialogOpen();
+
+ await this.ShowMessageAsync(Strings.Error,
+ string.Format("{0}\n\nMessage:\n{1}",
+ Strings.CouldNotSendKeystroke, ex.Message));
+
+ ConfigurationManager.OnDialogClose();
+ }
}
#endregion
diff --git a/Source/NETworkManager/Controls/IDragablzTabItem.cs b/Source/NETworkManager/Controls/IDragablzTabItem.cs
new file mode 100644
index 0000000000..73bbc65082
--- /dev/null
+++ b/Source/NETworkManager/Controls/IDragablzTabItem.cs
@@ -0,0 +1,17 @@
+using Dragablz;
+
+namespace NETworkManager.Controls;
+
+///
+/// Interface for a user control that is a in a in a .
+///
+public interface IDragablzTabItem
+{
+ ///
+ /// Event is fired when the tab is closed.
+ ///
+ public void CloseTab()
+ {
+
+ }
+}
diff --git a/Source/NETworkManager/Controls/PowerShellControl.xaml.cs b/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
index 82fcb333a7..0101a6a58f 100644
--- a/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
+++ b/Source/NETworkManager/Controls/PowerShellControl.xaml.cs
@@ -13,7 +13,7 @@
namespace NETworkManager.Controls;
-public partial class PowerShellControl : UserControlBase
+public partial class PowerShellControl : UserControlBase, IDragablzTabItem
{
#region Events
diff --git a/Source/NETworkManager/Controls/PuTTYControl.xaml.cs b/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
index 930bbe55da..384e37ebea 100644
--- a/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
+++ b/Source/NETworkManager/Controls/PuTTYControl.xaml.cs
@@ -14,7 +14,7 @@
namespace NETworkManager.Controls;
-public partial class PuTTYControl : UserControlBase
+public partial class PuTTYControl : UserControlBase, IDragablzTabItem
{
#region Events
diff --git a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
index 8c5ab0362c..a9df7ed35c 100644
--- a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
+++ b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
@@ -13,7 +13,7 @@
namespace NETworkManager.Controls;
-public partial class RemoteDesktopControl : UserControlBase
+public partial class RemoteDesktopControl : UserControlBase, IDragablzTabItem
{
#region Variables
diff --git a/Source/NETworkManager/Controls/TightVNCControl.xaml.cs b/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
index 13f3f631d0..5f8445175c 100644
--- a/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
+++ b/Source/NETworkManager/Controls/TightVNCControl.xaml.cs
@@ -13,7 +13,7 @@
namespace NETworkManager.Controls;
-public partial class TigerVNCControl : UserControlBase
+public partial class TigerVNCControl : UserControlBase, IDragablzTabItem
{
#region Events
diff --git a/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs b/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
index 404594225a..9286f3452d 100644
--- a/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
+++ b/Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
@@ -8,7 +8,7 @@
namespace NETworkManager.Controls;
-public partial class WebConsoleControl : UserControlBase
+public partial class WebConsoleControl : UserControlBase, IDragablzTabItem
{
#region Variables
diff --git a/Source/NETworkManager/Views/DNSLookupView.xaml.cs b/Source/NETworkManager/Views/DNSLookupView.xaml.cs
index ed72e99eb5..715ff11fc5 100644
--- a/Source/NETworkManager/Views/DNSLookupView.xaml.cs
+++ b/Source/NETworkManager/Views/DNSLookupView.xaml.cs
@@ -2,11 +2,12 @@
using System.Windows;
using System.Windows.Controls;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.ViewModels;
namespace NETworkManager.Views;
-public partial class DNSLookupView
+public partial class DNSLookupView : IDragablzTabItem
{
private readonly DNSLookupViewModel _viewModel;
diff --git a/Source/NETworkManager/Views/IPGeolocationView.xaml.cs b/Source/NETworkManager/Views/IPGeolocationView.xaml.cs
index d51d9cf5bd..0c877dba1d 100644
--- a/Source/NETworkManager/Views/IPGeolocationView.xaml.cs
+++ b/Source/NETworkManager/Views/IPGeolocationView.xaml.cs
@@ -1,11 +1,12 @@
using System;
using System.Windows;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.ViewModels;
namespace NETworkManager.Views;
-public partial class IPGeolocationView
+public partial class IPGeolocationView : IDragablzTabItem
{
private readonly IPGeolocationViewModel _viewModel;
diff --git a/Source/NETworkManager/Views/IPScannerView.xaml.cs b/Source/NETworkManager/Views/IPScannerView.xaml.cs
index ecb93e0259..67376f4d6b 100644
--- a/Source/NETworkManager/Views/IPScannerView.xaml.cs
+++ b/Source/NETworkManager/Views/IPScannerView.xaml.cs
@@ -6,6 +6,7 @@
using System.Windows.Data;
using System.Windows.Media;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.Models.Network;
using NETworkManager.Utilities;
using NETworkManager.ViewModels;
@@ -13,7 +14,7 @@
namespace NETworkManager.Views;
-public partial class IPScannerView
+public partial class IPScannerView : IDragablzTabItem
{
private readonly IPScannerViewModel _viewModel;
diff --git a/Source/NETworkManager/Views/PortScannerView.xaml.cs b/Source/NETworkManager/Views/PortScannerView.xaml.cs
index 2dc33c7311..69bac6bafe 100644
--- a/Source/NETworkManager/Views/PortScannerView.xaml.cs
+++ b/Source/NETworkManager/Views/PortScannerView.xaml.cs
@@ -2,11 +2,12 @@
using System.Windows;
using System.Windows.Controls;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.ViewModels;
namespace NETworkManager.Views;
-public partial class PortScannerView
+public partial class PortScannerView : IDragablzTabItem
{
private readonly PortScannerViewModel _viewModel;
diff --git a/Source/NETworkManager/Views/PowerShellHostView.xaml.cs b/Source/NETworkManager/Views/PowerShellHostView.xaml.cs
index aff3e6322e..2f7720d010 100644
--- a/Source/NETworkManager/Views/PowerShellHostView.xaml.cs
+++ b/Source/NETworkManager/Views/PowerShellHostView.xaml.cs
@@ -3,6 +3,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.Models;
using NETworkManager.ViewModels;
diff --git a/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs b/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs
index 3b3e0c3ff0..97b86d9377 100644
--- a/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs
+++ b/Source/NETworkManager/Views/RemoteDesktopHostView.xaml.cs
@@ -3,6 +3,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.Models;
using NETworkManager.ViewModels;
diff --git a/Source/NETworkManager/Views/SNMPView.xaml.cs b/Source/NETworkManager/Views/SNMPView.xaml.cs
index befa1b0447..31b4bea053 100644
--- a/Source/NETworkManager/Views/SNMPView.xaml.cs
+++ b/Source/NETworkManager/Views/SNMPView.xaml.cs
@@ -5,13 +5,14 @@
using System.Windows.Controls;
using System.Windows.Data;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.Models.Network;
using NETworkManager.Utilities;
using NETworkManager.ViewModels;
namespace NETworkManager.Views;
-public partial class SNMPView
+public partial class SNMPView : IDragablzTabItem
{
private readonly SNMPViewModel _viewModel;
@@ -22,7 +23,7 @@ public SNMPView(Guid tabId, SNMPSessionInfo sessionInfo)
_viewModel = new SNMPViewModel(DialogCoordinator.Instance, tabId, sessionInfo);
DataContext = _viewModel;
-
+
Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
@@ -30,7 +31,7 @@ private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
{
_viewModel.OnClose();
}
-
+
public void CloseTab()
{
_viewModel.OnClose();
diff --git a/Source/NETworkManager/Views/SNTPLookupView.xaml.cs b/Source/NETworkManager/Views/SNTPLookupView.xaml.cs
index 06368e6e5a..e321a6fcd6 100644
--- a/Source/NETworkManager/Views/SNTPLookupView.xaml.cs
+++ b/Source/NETworkManager/Views/SNTPLookupView.xaml.cs
@@ -2,11 +2,12 @@
using System.Windows;
using System.Windows.Controls;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.ViewModels;
namespace NETworkManager.Views;
-public partial class SNTPLookupView
+public partial class SNTPLookupView : IDragablzTabItem
{
private readonly SNTPLookupViewModel _viewModel;
diff --git a/Source/NETworkManager/Views/TracerouteView.xaml.cs b/Source/NETworkManager/Views/TracerouteView.xaml.cs
index 7fb3d4b967..a20efd293a 100644
--- a/Source/NETworkManager/Views/TracerouteView.xaml.cs
+++ b/Source/NETworkManager/Views/TracerouteView.xaml.cs
@@ -2,11 +2,12 @@
using System.Windows;
using System.Windows.Controls;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.ViewModels;
namespace NETworkManager.Views;
-public partial class TracerouteView
+public partial class TracerouteView : IDragablzTabItem
{
private readonly TracerouteViewModel _viewModel;
diff --git a/Source/NETworkManager/Views/WhoisView.xaml.cs b/Source/NETworkManager/Views/WhoisView.xaml.cs
index 2891d1204a..f6bc5bfa24 100644
--- a/Source/NETworkManager/Views/WhoisView.xaml.cs
+++ b/Source/NETworkManager/Views/WhoisView.xaml.cs
@@ -1,11 +1,12 @@
using System;
using System.Windows;
using MahApps.Metro.Controls.Dialogs;
+using NETworkManager.Controls;
using NETworkManager.ViewModels;
namespace NETworkManager.Views;
-public partial class WhoisView
+public partial class WhoisView : IDragablzTabItem
{
private readonly WhoisViewModel _viewModel;
From 69ab2ba692c9604aadd789ddc2a2fd0d32858fa3 Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Mon, 8 Apr 2024 02:38:21 +0200
Subject: [PATCH 18/22] Chore: Upgrade dragablz
---
Source/3rdparty/Dragablz | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Source/3rdparty/Dragablz b/Source/3rdparty/Dragablz
index d093dc63d9..2df62f5af3 160000
--- a/Source/3rdparty/Dragablz
+++ b/Source/3rdparty/Dragablz
@@ -1 +1 @@
-Subproject commit d093dc63d93eb0ce483ae6b5ac6c313c95849926
+Subproject commit 2df62f5af358d456d725919d44f189675d31d9cc
From 38d2996bf2658c40f15ec73d011709bfc0d5238c Mon Sep 17 00:00:00 2001
From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Date: Mon, 8 Apr 2024 21:55:29 +0200
Subject: [PATCH 19/22] Feature: Hide embedded window while dragging
---
InnoSetup.iss | 2 +-
Source/GlobalAssemblyInfo.cs | 4 +-
.../ConfigurationInfo.cs | 112 +++++++++++++-----
.../Controls/AWSSessionManagerControl.xaml | 18 ++-
.../Controls/DragablzTabHostWindow.xaml | 3 +-
.../Controls/DragablzTabHostWindow.xaml.cs | 51 ++++++++
.../Controls/PowerShellControl.xaml | 17 ++-
.../NETworkManager/Controls/PuTTYControl.xaml | 17 ++-
.../Controls/RemoteDesktopControl.xaml | 7 +-
...htVNCControl.xaml => TigerVNCControl.xaml} | 17 ++-
...ontrol.xaml.cs => TigerVNCControl.xaml.cs} | 0
.../Controls/WebConsoleControl.xaml | 5 +-
12 files changed, 206 insertions(+), 47 deletions(-)
rename Source/NETworkManager/Controls/{TightVNCControl.xaml => TigerVNCControl.xaml} (81%)
rename Source/NETworkManager/Controls/{TightVNCControl.xaml.cs => TigerVNCControl.xaml.cs} (100%)
diff --git a/InnoSetup.iss b/InnoSetup.iss
index d4554459df..6c7ffbdacf 100644
--- a/InnoSetup.iss
+++ b/InnoSetup.iss
@@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "NETworkManager"
-#define MyAppVersion "2024.4.1.0"
+#define MyAppVersion "2024.4.8.0"
#define MyAppPublisher "BornToBeRoot"
#define MyAppURL "https://github.com/BornToBeRoot/NETworkManager/"
#define MyAppExeName "NETworkManager.exe"
diff --git a/Source/GlobalAssemblyInfo.cs b/Source/GlobalAssemblyInfo.cs
index 2d4b248a22..c3ecb51536 100644
--- a/Source/GlobalAssemblyInfo.cs
+++ b/Source/GlobalAssemblyInfo.cs
@@ -6,5 +6,5 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-[assembly: AssemblyVersion("2024.4.1.0")]
-[assembly: AssemblyFileVersion("2024.4.1.0")]
+[assembly: AssemblyVersion("2024.4.8.0")]
+[assembly: AssemblyFileVersion("2024.4.8.0")]
diff --git a/Source/NETworkManager.Settings/ConfigurationInfo.cs b/Source/NETworkManager.Settings/ConfigurationInfo.cs
index 213e45cb2e..4d818175cc 100644
--- a/Source/NETworkManager.Settings/ConfigurationInfo.cs
+++ b/Source/NETworkManager.Settings/ConfigurationInfo.cs
@@ -77,8 +77,6 @@ public int IPScannerTabCount
if (value == _ipScannerTabCount)
return;
- Debug.WriteLine("IPScanner current tabs: " + value);
-
_ipScannerTabCount = value;
OnPropertyChanged();
}
@@ -93,8 +91,6 @@ public int PortScannerTabCount
if (value == _portScannerTabCount)
return;
- Debug.WriteLine("Port Scanner current tabs: " + value);
-
_portScannerTabCount = value;
OnPropertyChanged();
}
@@ -109,8 +105,6 @@ public int TracerouteTabCount
if (value == _tracerouteTabCount)
return;
- Debug.WriteLine("Traceroute current tabs: " + value);
-
_tracerouteTabCount = value;
OnPropertyChanged();
}
@@ -125,8 +119,6 @@ public int DNSLookupTabCount
if (value == _dnsLookupTabCount)
return;
- Debug.WriteLine("DNS Lookup current tabs: " + value);
-
_dnsLookupTabCount = value;
OnPropertyChanged();
}
@@ -141,13 +133,25 @@ public int RemoteDesktopTabCount
if (value == _remoteDesktopTabCount)
return;
- Debug.WriteLine("Remote Desktop current tabs: " + value);
-
_remoteDesktopTabCount = value;
OnPropertyChanged();
}
}
+ private bool _isRemoteDesktopWindowDragging;
+ public bool IsRemoteDesktopWindowDragging
+ {
+ get => _isRemoteDesktopWindowDragging;
+ set
+ {
+ if (value == _isRemoteDesktopWindowDragging)
+ return;
+
+ _isRemoteDesktopWindowDragging = value;
+ OnPropertyChanged();
+ }
+ }
+
private int _powerShellTabCount;
public int PowerShellTabCount
{
@@ -157,12 +161,24 @@ public int PowerShellTabCount
if (value == _powerShellTabCount)
return;
- Debug.WriteLine("PowerShell current tabs: " + value);
-
_powerShellTabCount = value;
OnPropertyChanged();
}
}
+
+ private bool _isPowerShellWindowDragging;
+ public bool IsPowerShellWindowDragging
+ {
+ get => _isPowerShellWindowDragging;
+ set
+ {
+ if (value == _isPowerShellWindowDragging)
+ return;
+
+ _isPowerShellWindowDragging = value;
+ OnPropertyChanged();
+ }
+ }
private int _puTTYTabCount;
public int PuTTYTabCount
@@ -173,13 +189,25 @@ public int PuTTYTabCount
if (value == _puTTYTabCount)
return;
- Debug.WriteLine("PuTTY current tabs: " + value);
-
_puTTYTabCount = value;
OnPropertyChanged();
}
}
+ private bool _isPuTTYWindowDragging;
+ public bool IsPuTTYWindowDragging
+ {
+ get => _isPuTTYWindowDragging;
+ set
+ {
+ if (value == _isPuTTYWindowDragging)
+ return;
+
+ _isPuTTYWindowDragging = value;
+ OnPropertyChanged();
+ }
+ }
+
private int _awsSessionManagerTabCount;
public int AWSSessionManagerTabCount
{
@@ -189,13 +217,25 @@ public int AWSSessionManagerTabCount
if (value == _awsSessionManagerTabCount)
return;
- Debug.WriteLine("AWS SSM current tabs: " + value);
-
_awsSessionManagerTabCount = value;
OnPropertyChanged();
}
}
+ private bool _isAWSSessionManagerWindowDragging;
+ public bool IsAWSSessionManagerWindowDragging
+ {
+ get => _isAWSSessionManagerWindowDragging;
+ set
+ {
+ if (value == _isAWSSessionManagerWindowDragging)
+ return;
+
+ _isAWSSessionManagerWindowDragging = value;
+ OnPropertyChanged();
+ }
+ }
+
private int _tigerVNCTabCount;
public int TigerVNCTabCount
{
@@ -205,13 +245,25 @@ public int TigerVNCTabCount
if (value == _tigerVNCTabCount)
return;
- Debug.WriteLine("TigerVNC current tabs: " + value);
-
_tigerVNCTabCount = value;
OnPropertyChanged();
}
}
+ private bool _isTigerVNCWindowDragging;
+ public bool IsTigerVNCWindowDragging
+ {
+ get => _isTigerVNCWindowDragging;
+ set
+ {
+ if (value == _isTigerVNCWindowDragging)
+ return;
+
+ _isTigerVNCWindowDragging = value;
+ OnPropertyChanged();
+ }
+ }
+
private int _webConsoleTabCount;
public int WebConsoleTabCount
{
@@ -221,13 +273,25 @@ public int WebConsoleTabCount
if (value == _webConsoleTabCount)
return;
- Debug.WriteLine("WebConsole current tabs: " + value);
-
_webConsoleTabCount = value;
OnPropertyChanged();
}
}
+ private bool _isWebConsoleWindowDragging;
+ public bool IsWebConsoleWindowDragging
+ {
+ get => _isWebConsoleWindowDragging;
+ set
+ {
+ if (value == _isWebConsoleWindowDragging)
+ return;
+
+ _isWebConsoleWindowDragging = value;
+ OnPropertyChanged();
+ }
+ }
+
private int _snmpTabCount;
public int SNMPTabCount
{
@@ -237,8 +301,6 @@ public int SNMPTabCount
if (value == _snmpTabCount)
return;
- Debug.WriteLine("SNMP current tabs: " + value);
-
_snmpTabCount = value;
OnPropertyChanged();
}
@@ -253,8 +315,6 @@ public int SNTPLookupTabCount
if (value == _sntpLookupTabCount)
return;
- Debug.WriteLine("SNTP Lookup current tabs: " + value);
-
_sntpLookupTabCount = value;
OnPropertyChanged();
}
@@ -269,8 +329,6 @@ public int WhoisTabCount
if (value == _whoisTabCount)
return;
- Debug.WriteLine("Whois current tabs: " + value);
-
_whoisTabCount = value;
OnPropertyChanged();
}
@@ -285,8 +343,6 @@ public int IPGeolocationTabCount
if (value == _ipGeolocationTabCount)
return;
- Debug.WriteLine("IP Geolocation current tabs: " + value);
-
_ipGeolocationTabCount = value;
OnPropertyChanged();
}
diff --git a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml
index de05cfa939..bb0f5ef0ff 100644
--- a/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml
+++ b/Source/NETworkManager/Controls/AWSSessionManagerControl.xaml
@@ -8,6 +8,7 @@
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:local="clr-namespace:NETworkManager.Controls"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
mah:DialogParticipation.Register="{Binding}"
mc:Ignorable="d" Loaded="UserControl_Loaded"
d:DataContext="{d:DesignInstance local:AWSSessionManagerControl}">
@@ -19,10 +20,19 @@
-
+
+
+
+
-
())
((IDragablzTabItem)tabItem.View).CloseTab();
}
+
+ // Reset the dragging state
+ switch (ApplicationName)
+ {
+ case ApplicationName.RemoteDesktop:
+ ConfigurationManager.Current.IsRemoteDesktopWindowDragging = false;
+ break;
+ case ApplicationName.PowerShell:
+ ConfigurationManager.Current.IsPowerShellWindowDragging = false;
+ break;
+ case ApplicationName.PuTTY:
+ ConfigurationManager.Current.IsPuTTYWindowDragging = false;
+ break;
+ case ApplicationName.AWSSessionManager:
+ ConfigurationManager.Current.IsAWSSessionManagerWindowDragging = false;
+ break;
+ case ApplicationName.TigerVNC:
+ ConfigurationManager.Current.IsTigerVNCWindowDragging = false;
+ break;
+ case ApplicationName.WebConsole:
+ ConfigurationManager.Current.IsWebConsoleWindowDragging = false;
+ break;
+ }
}
+ private void TabsContainer_OnIsDraggingWindowChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+
+ // Set the dragging state
+ switch (ApplicationName)
+ {
+ case ApplicationName.RemoteDesktop:
+ ConfigurationManager.Current.IsRemoteDesktopWindowDragging = e.NewValue;
+ break;
+ case ApplicationName.PowerShell:
+ ConfigurationManager.Current.IsPowerShellWindowDragging = e.NewValue;
+ break;
+ case ApplicationName.PuTTY:
+ ConfigurationManager.Current.IsPuTTYWindowDragging = e.NewValue;
+ break;
+ case ApplicationName.AWSSessionManager:
+ ConfigurationManager.Current.IsAWSSessionManagerWindowDragging = e.NewValue;
+ break;
+ case ApplicationName.TigerVNC:
+ ConfigurationManager.Current.IsTigerVNCWindowDragging = e.NewValue;
+ break;
+ case ApplicationName.WebConsole:
+ ConfigurationManager.Current.IsWebConsoleWindowDragging = e.NewValue;
+ break;
+
+ }
+ }
+
#endregion
#region PropertyChangedEventHandler
diff --git a/Source/NETworkManager/Controls/PowerShellControl.xaml b/Source/NETworkManager/Controls/PowerShellControl.xaml
index a35afddc9c..4a28e00ac8 100644
--- a/Source/NETworkManager/Controls/PowerShellControl.xaml
+++ b/Source/NETworkManager/Controls/PowerShellControl.xaml
@@ -8,6 +8,7 @@
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:local="clr-namespace:NETworkManager.Controls"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
mah:DialogParticipation.Register="{Binding}"
mc:Ignorable="d" Loaded="UserControl_Loaded"
d:DataContext="{d:DesignInstance local:PowerShellControl}">
@@ -19,9 +20,19 @@
-
+
+
+
+
@@ -19,9 +20,19 @@
-
+
+
+
+
@@ -18,10 +19,14 @@
+ MaxHeight="{Binding RdpClientHeight, Mode=OneWay}"
+ Background="{DynamicResource ResourceKey=MahApps.Brushes.Window.Background}">
+
@@ -171,6 +171,9 @@