Skip to content

Commit 6dbb0b1

Browse files
committed
Chore: Cleanup old dialogs
1 parent ec9569f commit 6dbb0b1

12 files changed

+32
-46
lines changed

Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class IPGeolocationHostViewModel : ViewModelBase, IProfileManager
2323
{
2424
#region Variables
2525

26-
private readonly IDialogCoordinator _dialogCoordinator;
2726
private readonly DispatcherTimer _searchDispatcherTimer = new();
2827

2928
public IInterTabClient InterTabClient { get; }
@@ -248,12 +247,10 @@ public GridLength ProfileWidth
248247

249248
#region Constructor
250249

251-
public IPGeolocationHostViewModel(IDialogCoordinator instance)
250+
public IPGeolocationHostViewModel()
252251
{
253252
_isLoading = true;
254-
255-
_dialogCoordinator = instance;
256-
253+
257254
InterTabClient = new DragablzInterTabClient(ApplicationName.IPGeolocation);
258255
InterTabPartition = nameof(ApplicationName.IPGeolocation);
259256

Source/NETworkManager/ViewModels/SNMPHostViewModel.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ namespace NETworkManager.ViewModels;
2424
public class SNMPHostViewModel : ViewModelBase, IProfileManager
2525
{
2626
#region Variables
27-
28-
private readonly IDialogCoordinator _dialogCoordinator;
2927
private readonly DispatcherTimer _searchDispatcherTimer = new();
3028

3129
public IInterTabClient InterTabClient { get; }
@@ -250,12 +248,10 @@ public GridLength ProfileWidth
250248

251249
#region Constructor, load settings
252250

253-
public SNMPHostViewModel(IDialogCoordinator instance)
251+
public SNMPHostViewModel()
254252
{
255253
_isLoading = true;
256254

257-
_dialogCoordinator = instance;
258-
259255
InterTabClient = new DragablzInterTabClient(ApplicationName.SNMP);
260256
InterTabPartition = nameof(ApplicationName.SNMP);
261257

Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class WakeOnLANViewModel : ViewModelBase, IProfileManager
2424
{
2525
#region Variables
2626

27-
private readonly IDialogCoordinator _dialogCoordinator;
2827
private readonly DispatcherTimer _searchDispatcherTimer = new();
2928

3029
private readonly bool _isLoading;
@@ -245,7 +244,7 @@ public bool IsProfileFilterSet
245244
OnPropertyChanged();
246245
}
247246
}
248-
247+
249248
private bool _canProfileWidthChange = true;
250249
private double _tempProfileWidth;
251250

@@ -300,12 +299,10 @@ public GridLength ProfileWidth
300299

301300
#region Constructor, load settings
302301

303-
public WakeOnLANViewModel(IDialogCoordinator instance)
302+
public WakeOnLANViewModel()
304303
{
305304
_isLoading = true;
306305

307-
_dialogCoordinator = instance;
308-
309306
MACAddressHistoryView =
310307
CollectionViewSource.GetDefaultView(SettingsManager.Current.WakeOnLan_MACAddressHistory);
311308
BroadcastHistoryView = CollectionViewSource.GetDefaultView(SettingsManager.Current.WakeOnLan_BroadcastHistory);
@@ -314,7 +311,8 @@ public WakeOnLANViewModel(IDialogCoordinator instance)
314311
CreateTags();
315312

316313
ProfileFilterTagsView = CollectionViewSource.GetDefaultView(ProfileFilterTags);
317-
ProfileFilterTagsView.SortDescriptions.Add(new SortDescription(nameof(ProfileFilterTagsInfo.Name), ListSortDirection.Ascending));
314+
ProfileFilterTagsView.SortDescriptions.Add(new SortDescription(nameof(ProfileFilterTagsInfo.Name),
315+
ListSortDirection.Ascending));
318316

319317
SetProfilesView(new ProfileFilterInfo());
320318

@@ -378,7 +376,8 @@ private void WakeUpProfileAction()
378376

379377
private void AddProfileAction()
380378
{
381-
ProfileDialogManager.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.WakeOnLAN)
379+
ProfileDialogManager
380+
.ShowAddProfileDialog(Application.Current.MainWindow, this, null, null, ApplicationName.WakeOnLAN)
382381
.ConfigureAwait(false);
383382
}
384383

@@ -391,14 +390,16 @@ private bool ModifyProfile_CanExecute(object obj)
391390

392391
private void EditProfileAction()
393392
{
394-
ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile).ConfigureAwait(false);
393+
ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile)
394+
.ConfigureAwait(false);
395395
}
396396

397397
public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute);
398398

399399
private void CopyAsProfileAction()
400400
{
401-
ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow, this, SelectedProfile).ConfigureAwait(false);
401+
ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow, this, SelectedProfile)
402+
.ConfigureAwait(false);
402403
}
403404

404405
public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute);
@@ -414,7 +415,8 @@ private void DeleteProfileAction()
414415

415416
private void EditGroupAction(object group)
416417
{
417-
ProfileDialogManager.ShowEditGroupDialog(Application.Current.MainWindow, this, ProfileManager.GetGroupByName($"{group}"))
418+
ProfileDialogManager
419+
.ShowEditGroupDialog(Application.Current.MainWindow, this, ProfileManager.GetGroupByName($"{group}"))
418420
.ConfigureAwait(false);
419421
}
420422

@@ -424,7 +426,7 @@ private void ClearSearchAction()
424426
{
425427
Search = string.Empty;
426428
}
427-
429+
428430
public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction());
429431

430432
private void OpenProfileFilterAction()
@@ -554,7 +556,8 @@ public void OnViewHide()
554556

555557
private void CreateTags()
556558
{
557-
var tags = ProfileManager.Groups.SelectMany(x => x.Profiles).Where(x => x.WakeOnLAN_Enabled).SelectMany(x => x.TagsCollection).Distinct().ToList();
559+
var tags = ProfileManager.Groups.SelectMany(x => x.Profiles).Where(x => x.WakeOnLAN_Enabled)
560+
.SelectMany(x => x.TagsCollection).Distinct().ToList();
558561

559562
var tagSet = new HashSet<string>(tags);
560563

@@ -571,19 +574,23 @@ private void CreateTags()
571574
ProfileFilterTags.Add(new ProfileFilterTagsInfo(false, tag));
572575
}
573576
}
574-
577+
575578
private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = null)
576579
{
577580
Profiles = new CollectionViewSource
578581
{
579582
Source = ProfileManager.Groups.SelectMany(x => x.Profiles).Where(x => x.WakeOnLAN_Enabled && (
580-
string.IsNullOrEmpty(filter.Search) || x.Name.IndexOf(filter.Search, StringComparison.Ordinal) > -1 || x.WakeOnLAN_MACAddress.IndexOf(filter.Search, StringComparison.Ordinal) > -1) && (
583+
string.IsNullOrEmpty(filter.Search) ||
584+
x.Name.IndexOf(filter.Search, StringComparison.Ordinal) > -1 ||
585+
x.WakeOnLAN_MACAddress.IndexOf(filter.Search, StringComparison.Ordinal) > -1) && (
581586
// If no tags are selected, show all profiles
582587
(!filter.Tags.Any()) ||
583588
// Any tag can match
584-
(filter.TagsFilterMatch == ProfileFilterTagsMatch.Any && filter.Tags.Any(tag => x.TagsCollection.Contains(tag))) ||
589+
(filter.TagsFilterMatch == ProfileFilterTagsMatch.Any &&
590+
filter.Tags.Any(tag => x.TagsCollection.Contains(tag))) ||
585591
// All tags must match
586-
(filter.TagsFilterMatch == ProfileFilterTagsMatch.All && filter.Tags.All(tag => x.TagsCollection.Contains(tag))))
592+
(filter.TagsFilterMatch == ProfileFilterTagsMatch.All &&
593+
filter.Tags.All(tag => x.TagsCollection.Contains(tag))))
587594
).OrderBy(x => x.Group).ThenBy(x => x.Name)
588595
}.View;
589596

@@ -619,7 +626,7 @@ private void RefreshProfiles()
619626
private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e)
620627
{
621628
CreateTags();
622-
629+
623630
RefreshProfiles();
624631
}
625632

Source/NETworkManager/ViewModels/WhoisHostViewModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class WhoisHostViewModel : ViewModelBase, IProfileManager
2323
{
2424
#region Variables
2525

26-
private readonly IDialogCoordinator _dialogCoordinator;
2726
private readonly DispatcherTimer _searchDispatcherTimer = new();
2827

2928
public IInterTabClient InterTabClient { get; }
@@ -248,12 +247,10 @@ public GridLength ProfileWidth
248247

249248
#region Constructor
250249

251-
public WhoisHostViewModel(IDialogCoordinator instance)
250+
public WhoisHostViewModel()
252251
{
253252
_isLoading = true;
254253

255-
_dialogCoordinator = instance;
256-
257254
InterTabClient = new DragablzInterTabClient(ApplicationName.Whois);
258255
InterTabPartition = nameof(ApplicationName.Whois);
259256

Source/NETworkManager/Views/IPGeolocationHostView.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
1010
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
1111
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
12-
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
1312
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
1413
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
1514
xmlns:profiles="clr-namespace:NETworkManager.Profiles;assembly=NETworkManager.Profiles"
16-
dialogs:DialogParticipation.Register="{Binding}"
1715
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:IPGeolocationHostViewModel}">
1816
<UserControl.Resources>
1917
<converters:BooleanReverseToVisibilityCollapsedConverter x:Key="BooleanReverseToVisibilityCollapsedConverter" />

Source/NETworkManager/Views/IPGeolocationHostView.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
using System.Windows;
22
using System.Windows.Controls;
33
using System.Windows.Input;
4-
using MahApps.Metro.Controls.Dialogs;
54
using NETworkManager.ViewModels;
65

76
namespace NETworkManager.Views;
87

98
public partial class IPGeolocationHostView
109
{
11-
private readonly IPGeolocationHostViewModel _viewModel = new(DialogCoordinator.Instance);
10+
private readonly IPGeolocationHostViewModel _viewModel = new();
1211

1312
public IPGeolocationHostView()
1413
{

Source/NETworkManager/Views/SNMPHostView.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
1212
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
1313
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
14-
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
1514
xmlns:profiles="clr-namespace:NETworkManager.Profiles;assembly=NETworkManager.Profiles"
16-
dialogs:DialogParticipation.Register="{Binding}"
1715
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:SNMPHostViewModel}">
1816
<UserControl.Resources>
1917
<converters:BooleanReverseToVisibilityCollapsedConverter x:Key="BooleanReverseToVisibilityCollapsedConverter" />

Source/NETworkManager/Views/SNMPHostView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace NETworkManager.Views;
88

99
public partial class SNMPHostView
1010
{
11-
private readonly SNMPHostViewModel _viewModel = new(DialogCoordinator.Instance);
11+
private readonly SNMPHostViewModel _viewModel = new();
1212

1313
public SNMPHostView()
1414
{

Source/NETworkManager/Views/WakeOnLANView.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
xmlns:mahAppsControls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
99
xmlns:validators="clr-namespace:NETworkManager.Validators;assembly=NETworkManager.Validators"
1010
xmlns:converters="clr-namespace:NETworkManager.Converters;assembly=NETworkManager.Converters"
11-
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
1211
xmlns:viewModels="clr-namespace:NETworkManager.ViewModels"
1312
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
1413
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
1514
xmlns:profiles="clr-namespace:NETworkManager.Profiles;assembly=NETworkManager.Profiles"
16-
dialogs:DialogParticipation.Register="{Binding}"
1715
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:WakeOnLANViewModel}">
1816
<UserControl.Resources>
1917
<converters:BooleanReverseConverter x:Key="BooleanReverseConverter" />

Source/NETworkManager/Views/WakeOnLANView.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System.Windows;
22
using System.Windows.Controls;
3-
using MahApps.Metro.Controls.Dialogs;
43
using NETworkManager.ViewModels;
54

65
namespace NETworkManager.Views;
76

87
public partial class WakeOnLANView
98
{
10-
private readonly WakeOnLANViewModel _viewModel = new(DialogCoordinator.Instance);
9+
private readonly WakeOnLANViewModel _viewModel = new();
1110

1211
public WakeOnLANView()
1312
{

0 commit comments

Comments
 (0)