diff --git a/Source/NETworkManager.Controls/GroupExpander.cs b/Source/NETworkManager.Controls/GroupExpander.cs new file mode 100644 index 0000000000..3bfd0c1f44 --- /dev/null +++ b/Source/NETworkManager.Controls/GroupExpander.cs @@ -0,0 +1,88 @@ +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; + +namespace NETworkManager.Controls +{ + public class GroupExpander : Expander + { + public static readonly DependencyProperty StateStoreProperty = + DependencyProperty.Register( + "StateStore", + typeof(GroupExpanderStateStore), + typeof(GroupExpander), + new PropertyMetadata(null, OnStateStoreChanged)); + + public GroupExpanderStateStore StateStore + { + get => (GroupExpanderStateStore)GetValue(StateStoreProperty); + set => SetValue(StateStoreProperty, value); + } + + public static readonly DependencyProperty GroupNameProperty = + DependencyProperty.Register( + nameof(GroupName), + typeof(string), + typeof(GroupExpander), + new PropertyMetadata(null, OnGroupNameChanged)); + + public string GroupName + { + get => (string)GetValue(GroupNameProperty); + set => SetValue(GroupNameProperty, value); + } + + static GroupExpander() + { + IsExpandedProperty.OverrideMetadata( + typeof(GroupExpander), + new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsExpandedChanged)); + } + + private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var expander = (GroupExpander)d; + + if (expander.StateStore != null && expander.GroupName != null) + expander.StateStore[expander.GroupName] = (bool)e.NewValue; + } + + private static void OnStateStoreChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var expander = (GroupExpander)d; + + if (e.OldValue is GroupExpanderStateStore oldStore) + oldStore.PropertyChanged -= expander.StateStore_PropertyChanged; + + if (e.NewValue is GroupExpanderStateStore newStore) + newStore.PropertyChanged += expander.StateStore_PropertyChanged; + + expander.UpdateIsExpanded(); + } + + private void StateStore_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == $"Item[{GroupName}]") + UpdateIsExpanded(); + } + + private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var expander = (GroupExpander)d; + + expander.UpdateIsExpanded(); + } + + private void UpdateIsExpanded() + { + if (StateStore == null || GroupName == null) + return; + + // Prevent recursive updates + if (IsExpanded == StateStore[GroupName]) + return; + + IsExpanded = StateStore[GroupName]; + } + } +} diff --git a/Source/NETworkManager.Controls/GroupExpanderStateStore.cs b/Source/NETworkManager.Controls/GroupExpanderStateStore.cs new file mode 100644 index 0000000000..76eea8e940 --- /dev/null +++ b/Source/NETworkManager.Controls/GroupExpanderStateStore.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; + +namespace NETworkManager.Controls +{ + public class GroupExpanderStateStore : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged(string propertyName) => + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + + /// + /// Stores the expansion state of each group by its name. + /// + private readonly Dictionary _states = []; + + /// + /// The indexer to get or set the expansion state of a group by its name. + /// + /// Name of the group. + /// True if expanded, false if collapsed. + public bool this[string groupName] + { + get + { + // Default to expanded if not set + if (!_states.TryGetValue(groupName, out var val)) + _states[groupName] = val = true; + + return val; + } + set + { + if (_states.TryGetValue(groupName, out var existing) && existing == value) + return; + + Debug.WriteLine("GroupExpanderStateStore: Setting state of '{0}' to {1}", groupName, value); + + _states[groupName] = value; + OnPropertyChanged($"Item[{groupName}]"); + } + } + } +} diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index d9a51c4ec2..2e8f0b1750 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -1815,6 +1815,15 @@ public static string Cobalt { } } + /// + /// Looks up a localized string similar to Collapse all. + /// + public static string CollapseAll { + get { + return ResourceManager.GetString("CollapseAll", resourceCulture); + } + } + /// /// Looks up a localized string similar to Color depth (bit). /// @@ -3908,6 +3917,15 @@ public static string Expand { } } + /// + /// Looks up a localized string similar to Expand all. + /// + public static string ExpandAll { + get { + return ResourceManager.GetString("ExpandAll", resourceCulture); + } + } + /// /// Looks up a localized string similar to Expand and open search.... /// diff --git a/Source/NETworkManager.Localization/Resources/Strings.cs-CZ.resx b/Source/NETworkManager.Localization/Resources/Strings.cs-CZ.resx index fbfddc38b9..540ffbd449 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.cs-CZ.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.cs-CZ.resx @@ -3987,4 +3987,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.de-DE.resx b/Source/NETworkManager.Localization/Resources/Strings.de-DE.resx index 62cf7720c3..bece07d9e8 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.de-DE.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.de-DE.resx @@ -3987,4 +3987,10 @@ Rechtsklick für weitere Optionen. Gruppe hinzufügen... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.es-ES.resx b/Source/NETworkManager.Localization/Resources/Strings.es-ES.resx index 24d7c841a4..323c1367c3 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.es-ES.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.es-ES.resx @@ -3984,4 +3984,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.fr-FR.resx b/Source/NETworkManager.Localization/Resources/Strings.fr-FR.resx index b02a816e4e..36ca0fa322 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.fr-FR.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.fr-FR.resx @@ -3987,4 +3987,10 @@ Clic droit pour plus d'options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.hu-HU.resx b/Source/NETworkManager.Localization/Resources/Strings.hu-HU.resx index 96d9c6b9ad..f9ef6c7375 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.hu-HU.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.hu-HU.resx @@ -3987,4 +3987,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.it-IT.resx b/Source/NETworkManager.Localization/Resources/Strings.it-IT.resx index 7cb92c58ec..aaf22ce669 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.it-IT.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.it-IT.resx @@ -4090,4 +4090,10 @@ Per maggiori dettagli consulta il file registro. Aggiungi gruppo... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.ja-JP.resx b/Source/NETworkManager.Localization/Resources/Strings.ja-JP.resx index 656b3cd6bd..b66bfd975e 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.ja-JP.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.ja-JP.resx @@ -3987,4 +3987,10 @@ Open Windows Settings > Privacy & security > Location, enable access f Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.ko-KR.resx b/Source/NETworkManager.Localization/Resources/Strings.ko-KR.resx index c3ab7bc31d..37fc3d4c2f 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.ko-KR.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.ko-KR.resx @@ -3984,4 +3984,10 @@ Open Windows Settings > Privacy & security > Location, enable access f Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.nl-NL.resx b/Source/NETworkManager.Localization/Resources/Strings.nl-NL.resx index 8caecd07c8..5a86d649a4 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.nl-NL.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.nl-NL.resx @@ -3984,4 +3984,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.pl-PL.resx b/Source/NETworkManager.Localization/Resources/Strings.pl-PL.resx index b48f8faa4a..91d02537be 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.pl-PL.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.pl-PL.resx @@ -3984,4 +3984,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.pt-BR.resx b/Source/NETworkManager.Localization/Resources/Strings.pt-BR.resx index ec4524a9eb..99ca72c65a 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.pt-BR.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.pt-BR.resx @@ -3987,4 +3987,10 @@ Clique direito para mais opções. Adicionar grupo... + + Exportar tudo + + + Fechar todos + diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 4918688508..d88ec26a51 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -3987,4 +3987,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + \ No newline at end of file diff --git a/Source/NETworkManager.Localization/Resources/Strings.ru-RU.resx b/Source/NETworkManager.Localization/Resources/Strings.ru-RU.resx index e4df8dfc98..40c758fe1c 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.ru-RU.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.ru-RU.resx @@ -3987,4 +3987,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.sl-SI.resx b/Source/NETworkManager.Localization/Resources/Strings.sl-SI.resx index 481f3c0fa2..f64d2cea6a 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.sl-SI.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.sl-SI.resx @@ -3969,4 +3969,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.sv-SE.resx b/Source/NETworkManager.Localization/Resources/Strings.sv-SE.resx index f26c13516e..581a022777 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.sv-SE.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.sv-SE.resx @@ -3984,4 +3984,10 @@ Right-click for more options. Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.zh-CN.resx b/Source/NETworkManager.Localization/Resources/Strings.zh-CN.resx index b213211d8b..3c08f1faae 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.zh-CN.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.zh-CN.resx @@ -3988,4 +3988,10 @@ Open Windows Settings > Privacy & security > Location, enable access f Add group... + + Expand all + + + Collapse all + diff --git a/Source/NETworkManager.Localization/Resources/Strings.zh-TW.resx b/Source/NETworkManager.Localization/Resources/Strings.zh-TW.resx index 33cb3bf341..8fd247f67c 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.zh-TW.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.zh-TW.resx @@ -3960,30 +3960,36 @@ $$hostname$$ --> 主機名稱 刪除瀏覽資料時發生錯誤。歡迎在 GitHub 上回報此問題。 - production + 生產 - Add tag + 新增標籤 - Apply filter + 套用篩選 - Filter profiles... + 篩選設定檔... - Filter by tags + 依標籤篩選 - No tags found! + 找不到標籤! - Match + 匹配 - Any + 任何 - Add group... + 新增群組... + + + 擴展全部 + + + 全部摺疊 diff --git a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs index 1d369db70a..dbeee6c554 100644 --- a/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs @@ -308,6 +308,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -625,6 +628,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ICommand OpenDocumentationCommand { get { return new RelayCommand(_ => OpenDocumentationAction()); } @@ -1011,6 +1028,12 @@ private static void AddRegionToHistory(string region) SettingsManager.Current.General_HistoryListEntries)); } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs index 3c7b12e7e0..7b63265134 100644 --- a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs @@ -196,6 +196,9 @@ public bool IsProfileFilterSet } } + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; + private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -399,6 +402,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ItemActionCallback CloseItemCommand => CloseItemAction; private static void CloseItemAction(ItemActionCallbackArgs args) @@ -410,6 +427,12 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #region Methods + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs index b39b193476..d2f329b14b 100644 --- a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs @@ -197,6 +197,9 @@ public bool IsProfileFilterSet } } + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; + private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -399,6 +402,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ItemActionCallback CloseItemCommand => CloseItemAction; private static void CloseItemAction(ItemActionCallbackArgs args) @@ -410,6 +427,12 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #region Methods + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs index db2a104203..07120ee799 100644 --- a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs @@ -196,6 +196,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -398,6 +401,20 @@ private void ClearProfileFilterAction() IsProfileFilterSet = false; ProfileFilterIsOpen = false; } + + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } public ItemActionCallback CloseItemCommand => CloseItemAction; @@ -410,6 +427,12 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #region Methods + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs b/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs index b840fd4d8a..983ff95040 100644 --- a/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs @@ -27,6 +27,7 @@ using System.Windows.Data; using System.Windows.Input; using System.Windows.Threading; +using NETworkManager.Controls; using NetworkInterface = NETworkManager.Models.Network.NetworkInterface; namespace NETworkManager.ViewModels; @@ -583,6 +584,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -904,6 +908,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + #region Additional commands private bool AdditionalCommands_CanExecute(object parameter) @@ -1330,6 +1348,12 @@ private async Task RemoveIPv4Address(string ipAddress) } } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs b/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs index 4f9bf0beb3..0211001a9c 100644 --- a/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs @@ -1,5 +1,6 @@ using MahApps.Metro.Controls; using MahApps.Metro.Controls.Dialogs; +using NETworkManager.Controls; using NETworkManager.Localization.Resources; using NETworkManager.Models; using NETworkManager.Models.Network; @@ -279,6 +280,9 @@ public bool IsProfileFilterSet } } + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; + private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -506,6 +510,19 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } #endregion #region Methods @@ -643,6 +660,12 @@ private void AddHostToHistory(string host) list.ForEach(x => SettingsManager.Current.PingMonitor_HostHistory.Add(x)); } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs index b683443960..6788d1174a 100644 --- a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs @@ -195,6 +195,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -398,6 +401,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ItemActionCallback CloseItemCommand => CloseItemAction; private static void CloseItemAction(ItemActionCallbackArgs args) @@ -409,6 +426,12 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #region Methods + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs index fc94374bbc..e8b95e1c10 100644 --- a/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs @@ -234,6 +234,9 @@ public bool IsProfileFilterSet } } + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; + private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -515,6 +518,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction()); private static void OpenSettingsAction() @@ -652,6 +669,12 @@ private static void AddHostToHistory(string host) SettingsManager.Current.General_HistoryListEntries)); } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs index 4d780b46db..2c37057a90 100644 --- a/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs @@ -239,6 +239,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -529,6 +532,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction()); private static void OpenSettingsAction() @@ -737,6 +754,12 @@ private static void AddProfileToHistory(string profile) SettingsManager.Current.General_HistoryListEntries)); } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs index ad417fe316..66da810e9c 100644 --- a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs @@ -203,6 +203,9 @@ public bool IsProfileFilterSet } } + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; + private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -488,6 +491,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ItemActionCallback CloseItemCommand => CloseItemAction; private static void CloseItemAction(ItemActionCallbackArgs args) @@ -637,6 +654,12 @@ private static void AddHostToHistory(string host) SettingsManager.Current.General_HistoryListEntries)); } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs b/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs index 1fe8fb132c..8768d89d97 100644 --- a/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/SNMPHostViewModel.cs @@ -199,6 +199,9 @@ public bool IsProfileFilterSet } } + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; + private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -397,6 +400,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ItemActionCallback CloseItemCommand => CloseItemAction; private static void CloseItemAction(ItemActionCallbackArgs args) @@ -407,6 +424,11 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #endregion #region Methods + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } private void ResizeProfile(bool dueToChangedSize) { diff --git a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs index 27471c5594..53e378092e 100644 --- a/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/TigerVNCHostViewModel.cs @@ -218,6 +218,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -452,6 +455,20 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } + public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction()); private static void OpenSettingsAction() @@ -564,6 +581,12 @@ private static void AddPortToHistory(int port) SettingsManager.Current.General_HistoryListEntries)); } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs index 5d05fddd36..cf61a4d12c 100644 --- a/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/TracerouteHostViewModel.cs @@ -196,6 +196,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -398,6 +401,20 @@ private void ClearProfileFilterAction() IsProfileFilterSet = false; ProfileFilterIsOpen = false; } + + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } public ItemActionCallback CloseItemCommand => CloseItemAction; @@ -410,6 +427,12 @@ private void CloseItemAction(ItemActionCallbackArgs args) #region Methods + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs b/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs index 4d313b02f9..a3393740ff 100644 --- a/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs +++ b/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs @@ -17,6 +17,7 @@ using System.Windows.Data; using System.Windows.Input; using System.Windows.Threading; +using NETworkManager.Controls; namespace NETworkManager.ViewModels; @@ -248,6 +249,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -457,6 +461,19 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } #endregion #region Methods @@ -513,6 +530,12 @@ private void AddBroadcastToHistory(string broadcast) list.ForEach(x => SettingsManager.Current.WakeOnLan_BroadcastHistory.Add(x)); } + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs index 82ffe79d8b..2594332b32 100644 --- a/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/WebConsoleHostViewModel.cs @@ -224,6 +224,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -449,6 +452,20 @@ private void ClearProfileFilterAction() IsProfileFilterSet = false; ProfileFilterIsOpen = false; } + + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction()); @@ -532,6 +549,12 @@ private static void AddUrlToHistory(string url) ListHelper.Modify(SettingsManager.Current.WebConsole_UrlHistory.ToList(), url, SettingsManager.Current.General_HistoryListEntries)); } + + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } private void ResizeProfile(bool dueToChangedSize) { diff --git a/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs b/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs index c76753c989..90e970efdf 100644 --- a/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/WhoisHostViewModel.cs @@ -196,6 +196,9 @@ public bool IsProfileFilterSet OnPropertyChanged(); } } + + private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; private double _tempProfileWidth; @@ -398,6 +401,20 @@ private void ClearProfileFilterAction() IsProfileFilterSet = false; ProfileFilterIsOpen = false; } + + public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + + private void ExpandAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(true); + } + + public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + + private void CollapseAllProfileGroupsAction() + { + SetIsExpandedForAllProfileGroups(false); + } public ItemActionCallback CloseItemCommand => CloseItemAction; @@ -409,7 +426,12 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #endregion #region Methods - + private void SetIsExpandedForAllProfileGroups(bool isExpanded) + { + foreach (var group in Profiles.Groups.Cast()) + GroupExpanderStateStore[group.Name.ToString()] = isExpanded; + } + private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; diff --git a/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml b/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml index db59e98b0f..8c15b314fc 100644 --- a/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml +++ b/Source/NETworkManager/Views/AWSSessionManagerHostView.xaml @@ -7,15 +7,17 @@ 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" + xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls" xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro" xmlns:viewModels="clr-namespace:NETworkManager.ViewModels" xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization" xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings" xmlns:interactivity="http://schemas.microsoft.com/xaml/behaviors" xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" - xmlns:controls="clr-namespace:NETworkManager.Controls" + xmlns:internalControls="clr-namespace:NETworkManager.Controls" xmlns:profiles="clr-namespace:NETworkManager.Profiles;assembly=NETworkManager.Profiles" + xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF" + xmlns:networkManager="clr-namespace:NETworkManager" dialogs:DialogParticipation.Register="{Binding}" Loaded="UserControl_Loaded" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:AWSSessionManagerHostViewModel}"> @@ -25,7 +27,6 @@ - @@ -58,7 +59,7 @@ - + @@ -605,8 +606,10 @@ - + @@ -614,7 +617,40 @@ - + + + + + + + + + + + + + + + + + + + + + + - + @@ -859,7 +895,7 @@