Skip to content

Commit 0d99b78

Browse files
committed
Feature: Expander state
1 parent 73f9123 commit 0d99b78

15 files changed

+345
-1
lines changed

Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ public bool IsProfileFilterSet
308308
OnPropertyChanged();
309309
}
310310
}
311+
312+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
313+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
311314

312315
private bool _canProfileWidthChange = true;
313316
private double _tempProfileWidth;
@@ -625,6 +628,20 @@ private void ClearProfileFilterAction()
625628
ProfileFilterIsOpen = false;
626629
}
627630

631+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
632+
633+
private void ExpandAllProfileGroupsAction()
634+
{
635+
SetIsExpandedForAllProfileGroups(true);
636+
}
637+
638+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
639+
640+
private void CollapseAllProfileGroupsAction()
641+
{
642+
SetIsExpandedForAllProfileGroups(false);
643+
}
644+
628645
public ICommand OpenDocumentationCommand
629646
{
630647
get { return new RelayCommand(_ => OpenDocumentationAction()); }
@@ -1011,6 +1028,12 @@ private static void AddRegionToHistory(string region)
10111028
SettingsManager.Current.General_HistoryListEntries));
10121029
}
10131030

1031+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
1032+
{
1033+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
1034+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
1035+
}
1036+
10141037
private void ResizeProfile(bool dueToChangedSize)
10151038
{
10161039
_canProfileWidthChange = false;

Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ public bool IsProfileFilterSet
196196
}
197197
}
198198

199+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
200+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
201+
199202
private bool _canProfileWidthChange = true;
200203
private double _tempProfileWidth;
201204

@@ -399,6 +402,20 @@ private void ClearProfileFilterAction()
399402
ProfileFilterIsOpen = false;
400403
}
401404

405+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
406+
407+
private void ExpandAllProfileGroupsAction()
408+
{
409+
SetIsExpandedForAllProfileGroups(true);
410+
}
411+
412+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
413+
414+
private void CollapseAllProfileGroupsAction()
415+
{
416+
SetIsExpandedForAllProfileGroups(false);
417+
}
418+
402419
public ItemActionCallback CloseItemCommand => CloseItemAction;
403420

404421
private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
@@ -410,6 +427,12 @@ private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
410427

411428
#region Methods
412429

430+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
431+
{
432+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
433+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
434+
}
435+
413436
private void ResizeProfile(bool dueToChangedSize)
414437
{
415438
_canProfileWidthChange = false;

Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ public bool IsProfileFilterSet
197197
}
198198
}
199199

200+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
201+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
202+
200203
private bool _canProfileWidthChange = true;
201204
private double _tempProfileWidth;
202205

@@ -399,6 +402,20 @@ private void ClearProfileFilterAction()
399402
ProfileFilterIsOpen = false;
400403
}
401404

405+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
406+
407+
private void ExpandAllProfileGroupsAction()
408+
{
409+
SetIsExpandedForAllProfileGroups(true);
410+
}
411+
412+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
413+
414+
private void CollapseAllProfileGroupsAction()
415+
{
416+
SetIsExpandedForAllProfileGroups(false);
417+
}
418+
402419
public ItemActionCallback CloseItemCommand => CloseItemAction;
403420

404421
private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
@@ -410,6 +427,12 @@ private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
410427

411428
#region Methods
412429

430+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
431+
{
432+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
433+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
434+
}
435+
413436
private void ResizeProfile(bool dueToChangedSize)
414437
{
415438
_canProfileWidthChange = false;

Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ public bool IsProfileFilterSet
196196
OnPropertyChanged();
197197
}
198198
}
199+
200+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
201+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
199202

200203
private bool _canProfileWidthChange = true;
201204
private double _tempProfileWidth;
@@ -398,6 +401,20 @@ private void ClearProfileFilterAction()
398401
IsProfileFilterSet = false;
399402
ProfileFilterIsOpen = false;
400403
}
404+
405+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
406+
407+
private void ExpandAllProfileGroupsAction()
408+
{
409+
SetIsExpandedForAllProfileGroups(true);
410+
}
411+
412+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
413+
414+
private void CollapseAllProfileGroupsAction()
415+
{
416+
SetIsExpandedForAllProfileGroups(false);
417+
}
401418

402419
public ItemActionCallback CloseItemCommand => CloseItemAction;
403420

@@ -410,6 +427,12 @@ private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
410427

411428
#region Methods
412429

430+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
431+
{
432+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
433+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
434+
}
435+
413436
private void ResizeProfile(bool dueToChangedSize)
414437
{
415438
_canProfileWidthChange = false;

Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using System.Windows.Data;
2828
using System.Windows.Input;
2929
using System.Windows.Threading;
30+
using NETworkManager.Controls;
3031
using NetworkInterface = NETworkManager.Models.Network.NetworkInterface;
3132

3233
namespace NETworkManager.ViewModels;
@@ -583,6 +584,9 @@ public bool IsProfileFilterSet
583584
OnPropertyChanged();
584585
}
585586
}
587+
588+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
589+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
586590

587591
private bool _canProfileWidthChange = true;
588592
private double _tempProfileWidth;
@@ -904,6 +908,20 @@ private void ClearProfileFilterAction()
904908
ProfileFilterIsOpen = false;
905909
}
906910

911+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
912+
913+
private void ExpandAllProfileGroupsAction()
914+
{
915+
SetIsExpandedForAllProfileGroups(true);
916+
}
917+
918+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
919+
920+
private void CollapseAllProfileGroupsAction()
921+
{
922+
SetIsExpandedForAllProfileGroups(false);
923+
}
924+
907925
#region Additional commands
908926

909927
private bool AdditionalCommands_CanExecute(object parameter)
@@ -1330,6 +1348,12 @@ private async Task RemoveIPv4Address(string ipAddress)
13301348
}
13311349
}
13321350

1351+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
1352+
{
1353+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
1354+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
1355+
}
1356+
13331357
private void ResizeProfile(bool dueToChangedSize)
13341358
{
13351359
_canProfileWidthChange = false;

Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ public bool IsProfileFilterSet
195195
OnPropertyChanged();
196196
}
197197
}
198+
199+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
200+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
198201

199202
private bool _canProfileWidthChange = true;
200203
private double _tempProfileWidth;
@@ -398,6 +401,20 @@ private void ClearProfileFilterAction()
398401
ProfileFilterIsOpen = false;
399402
}
400403

404+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
405+
406+
private void ExpandAllProfileGroupsAction()
407+
{
408+
SetIsExpandedForAllProfileGroups(true);
409+
}
410+
411+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
412+
413+
private void CollapseAllProfileGroupsAction()
414+
{
415+
SetIsExpandedForAllProfileGroups(false);
416+
}
417+
401418
public ItemActionCallback CloseItemCommand => CloseItemAction;
402419

403420
private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
@@ -409,6 +426,12 @@ private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
409426

410427
#region Methods
411428

429+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
430+
{
431+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
432+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
433+
}
434+
412435
private void ResizeProfile(bool dueToChangedSize)
413436
{
414437
_canProfileWidthChange = false;

Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ public bool IsProfileFilterSet
234234
}
235235
}
236236

237+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
238+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
239+
237240
private bool _canProfileWidthChange = true;
238241
private double _tempProfileWidth;
239242

@@ -515,6 +518,20 @@ private void ClearProfileFilterAction()
515518
ProfileFilterIsOpen = false;
516519
}
517520

521+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
522+
523+
private void ExpandAllProfileGroupsAction()
524+
{
525+
SetIsExpandedForAllProfileGroups(true);
526+
}
527+
528+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
529+
530+
private void CollapseAllProfileGroupsAction()
531+
{
532+
SetIsExpandedForAllProfileGroups(false);
533+
}
534+
518535
public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction());
519536

520537
private static void OpenSettingsAction()
@@ -652,6 +669,12 @@ private static void AddHostToHistory(string host)
652669
SettingsManager.Current.General_HistoryListEntries));
653670
}
654671

672+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
673+
{
674+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
675+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
676+
}
677+
655678
private void ResizeProfile(bool dueToChangedSize)
656679
{
657680
_canProfileWidthChange = false;

Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ public bool IsProfileFilterSet
239239
OnPropertyChanged();
240240
}
241241
}
242+
243+
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
244+
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
242245

243246
private bool _canProfileWidthChange = true;
244247
private double _tempProfileWidth;
@@ -529,6 +532,20 @@ private void ClearProfileFilterAction()
529532
ProfileFilterIsOpen = false;
530533
}
531534

535+
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
536+
537+
private void ExpandAllProfileGroupsAction()
538+
{
539+
SetIsExpandedForAllProfileGroups(true);
540+
}
541+
542+
public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction());
543+
544+
private void CollapseAllProfileGroupsAction()
545+
{
546+
SetIsExpandedForAllProfileGroups(false);
547+
}
548+
532549
public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction());
533550

534551
private static void OpenSettingsAction()
@@ -737,6 +754,12 @@ private static void AddProfileToHistory(string profile)
737754
SettingsManager.Current.General_HistoryListEntries));
738755
}
739756

757+
private void SetIsExpandedForAllProfileGroups(bool isExpanded)
758+
{
759+
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
760+
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
761+
}
762+
740763
private void ResizeProfile(bool dueToChangedSize)
741764
{
742765
_canProfileWidthChange = false;

0 commit comments

Comments
 (0)