Skip to content

Commit 2a96065

Browse files
committed
Code cleanup / improved
1 parent 7c84e9a commit 2a96065

8 files changed

Lines changed: 67 additions & 79 deletions

File tree

Source/NETworkManager/Models/Settings/IPScannerProfileManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ public static string GetProfilesFilePath()
1717
return Path.Combine(SettingsManager.GetSettingsLocation(), ProfilesFileName);
1818
}
1919

20+
public static List<string> GetProfileGroups()
21+
{
22+
List<string> list = new List<string>();
23+
24+
foreach (IPScannerProfileInfo profile in Profiles)
25+
{
26+
if (!list.Contains(profile.Group))
27+
list.Add(profile.Group);
28+
}
29+
30+
return list;
31+
}
32+
2033
public static void Load(bool deserialize = true)
2134
{
2235
Profiles = new ObservableCollection<IPScannerProfileInfo>();

Source/NETworkManager/Models/Settings/PortScannerProfileManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ public static string GetProfilesFilePath()
1818
return Path.Combine(SettingsManager.GetSettingsLocation(), ProfilesFileName);
1919
}
2020

21+
public static List<string> GetProfileGroups()
22+
{
23+
List<string> list = new List<string>();
24+
25+
foreach (PortScannerProfileInfo profile in Profiles)
26+
{
27+
if (!list.Contains(profile.Group))
28+
list.Add(profile.Group);
29+
}
30+
31+
return list;
32+
}
33+
2134
public static void Load(bool deserialize = true)
2235
{
2336
Profiles = new ObservableCollection<PortScannerProfileInfo>();

Source/NETworkManager/Models/Settings/RemoteDesktopSessionManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ public static string GetSessionsFilePath()
1717
return Path.Combine(SettingsManager.GetSettingsLocation(), SessionsFileName);
1818
}
1919

20+
public static List<string> GetSessionGroups()
21+
{
22+
List<string> list = new List<string>();
23+
24+
foreach (RemoteDesktopSessionInfo session in Sessions)
25+
{
26+
if (!list.Contains(session.Group))
27+
list.Add(session.Group);
28+
}
29+
30+
return list;
31+
}
32+
2033
public static void Load(bool deserialize = true)
2134
{
2235
Sessions = new ObservableCollection<RemoteDesktopSessionInfo>();

Source/NETworkManager/Models/Settings/WakeOnLANClientManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ public static string GetClientsFilePath()
1717
return Path.Combine(SettingsManager.GetSettingsLocation(), ClientsFileName);
1818
}
1919

20+
public static List<string> GetClientGroups()
21+
{
22+
List<string> list = new List<string>();
23+
24+
foreach (WakeOnLANClientInfo client in Clients)
25+
{
26+
if (!list.Contains(client.Group))
27+
list.Add(client.Group);
28+
}
29+
30+
return list;
31+
}
32+
2033
public static void Load(bool deserialize = true)
2134
{
2235
Clients = new ObservableCollection<WakeOnLANClientInfo>();

Source/NETworkManager/ViewModels/Applications/IPScannerViewModel.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,7 @@ public ICollectionView IPScannerProfiles
260260
{
261261
get { return _ipScannerProfiles; }
262262
}
263-
264-
public List<string> IPScannerProfileGroups
265-
{
266-
get
267-
{
268-
List<string> list = new List<string>();
269-
270-
foreach (IPScannerProfileInfo profile in IPScannerProfileManager.Profiles)
271-
{
272-
if (!list.Contains(profile.Group))
273-
list.Add(profile.Group);
274-
}
275-
276-
return list;
277-
}
278-
}
279-
263+
280264
private IPScannerProfileInfo _selectedProfile = new IPScannerProfileInfo();
281265
public IPScannerProfileInfo SelectedProfile
282266
{
@@ -405,7 +389,7 @@ private async void AddProfileAction()
405389
}, instance =>
406390
{
407391
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
408-
}, IPScannerProfileGroups, new IPScannerProfileInfo() { IPRange = IPRange });
392+
}, IPScannerProfileManager.GetProfileGroups(), new IPScannerProfileInfo() { IPRange = IPRange });
409393

410394
customDialog.Content = new IPScannerProfileDialog
411395
{
@@ -444,7 +428,7 @@ private async void EditProfileAction()
444428
}, instance =>
445429
{
446430
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
447-
}, IPScannerProfileGroups, SelectedProfile);
431+
}, IPScannerProfileManager.GetProfileGroups(), SelectedProfile);
448432

449433
customDialog.Content = new IPScannerProfileDialog
450434
{
@@ -481,7 +465,7 @@ private async void CopyAsProfileAction()
481465
}, instance =>
482466
{
483467
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
484-
}, IPScannerProfileGroups, SelectedProfile);
468+
}, IPScannerProfileManager.GetProfileGroups(), SelectedProfile);
485469

486470
customDialog.Content = new IPScannerProfileDialog
487471
{

Source/NETworkManager/ViewModels/Applications/PortScannerViewModel.cs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -283,22 +283,6 @@ public ICollectionView PortScannerProfiles
283283
get { return _portScannerProfiles; }
284284
}
285285

286-
public List<string> PortScannerProfileGroups
287-
{
288-
get
289-
{
290-
List<string> list = new List<string>();
291-
292-
foreach (PortScannerProfileInfo profile in PortScannerProfileManager.Profiles)
293-
{
294-
if (!list.Contains(profile.Group))
295-
list.Add(profile.Group);
296-
}
297-
298-
return list;
299-
}
300-
}
301-
302286
private PortScannerProfileInfo _selectedProfile = new PortScannerProfileInfo();
303287
public PortScannerProfileInfo SelectedProfile
304288
{
@@ -422,7 +406,7 @@ private async void AddProfileAction()
422406
}, instance =>
423407
{
424408
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
425-
}, PortScannerProfileGroups, new PortScannerProfileInfo() { HostnameOrIPAddress = HostnameOrIPAddress, Ports = Ports });
409+
}, PortScannerProfileManager.GetProfileGroups(), new PortScannerProfileInfo() { HostnameOrIPAddress = HostnameOrIPAddress, Ports = Ports });
426410

427411
customDialog.Content = new PortScannerProfileDialog
428412
{
@@ -462,7 +446,7 @@ private async void EditProfileAction()
462446
}, instance =>
463447
{
464448
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
465-
}, PortScannerProfileGroups, SelectedProfile);
449+
}, PortScannerProfileManager.GetProfileGroups(), SelectedProfile);
466450

467451
customDialog.Content = new PortScannerProfileDialog
468452
{
@@ -500,7 +484,7 @@ private async void CopyAsProfileAction()
500484
}, instance =>
501485
{
502486
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
503-
}, PortScannerProfileGroups, SelectedProfile);
487+
}, PortScannerProfileManager.GetProfileGroups(), SelectedProfile);
504488

505489
customDialog.Content = new PortScannerProfileDialog
506490
{

Source/NETworkManager/ViewModels/Applications/RemoteDesktopViewModel.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,7 @@ public ICollectionView RemoteDesktopSessions
4343
{
4444
get { return _remoteDesktopSessions; }
4545
}
46-
47-
public List<string> RemoteDesktopSessionGroups
48-
{
49-
get
50-
{
51-
List<string> list = new List<string>();
52-
53-
foreach (RemoteDesktopSessionInfo session in RemoteDesktopSessionManager.Sessions)
54-
{
55-
if (!list.Contains(session.Group))
56-
list.Add(session.Group);
57-
}
58-
59-
return list;
60-
}
61-
}
62-
46+
6347
private RemoteDesktopSessionInfo _selectedSession = new RemoteDesktopSessionInfo();
6448
public RemoteDesktopSessionInfo SelectedSession
6549
{
@@ -202,7 +186,7 @@ private async void AddSessionAction()
202186
{
203187
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
204188
ConfigurationManager.Current.FixAirspace = false;
205-
}, RemoteDesktopSessionGroups);
189+
}, RemoteDesktopSessionManager.GetSessionGroups());
206190

207191
customDialog.Content = new RemoteDesktopSessionDialog
208192
{
@@ -259,7 +243,7 @@ private async void EditSessionAction()
259243
{
260244
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
261245
ConfigurationManager.Current.FixAirspace = false;
262-
}, RemoteDesktopSessionGroups, SelectedSession);
246+
}, RemoteDesktopSessionManager.GetSessionGroups(), SelectedSession);
263247

264248
customDialog.Content = new RemoteDesktopSessionDialog
265249
{
@@ -299,7 +283,7 @@ private async void CopyAsSessionAction()
299283
{
300284
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
301285
ConfigurationManager.Current.FixAirspace = false;
302-
}, RemoteDesktopSessionGroups, SelectedSession);
286+
}, RemoteDesktopSessionManager.GetSessionGroups(), SelectedSession);
303287

304288
customDialog.Content = new RemoteDesktopSessionDialog
305289
{

Source/NETworkManager/ViewModels/Applications/WakeOnLanViewModel.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,6 @@ public ICollectionView WakeOnLANClients
141141
get { return _wakeOnLANClients; }
142142
}
143143

144-
public List<string> WakeOnLANClientGroups
145-
{
146-
get
147-
{
148-
List<string> list = new List<string>();
149-
150-
foreach (WakeOnLANClientInfo client in WakeOnLANClientManager.Clients)
151-
{
152-
if (!list.Contains(client.Group))
153-
list.Add(client.Group);
154-
}
155-
156-
return list;
157-
}
158-
}
159-
160144
private WakeOnLANClientInfo _selectedClient;
161145
public WakeOnLANClientInfo SelectedClient
162146
{
@@ -166,7 +150,7 @@ public WakeOnLANClientInfo SelectedClient
166150
if (value == _selectedClient)
167151
return;
168152

169-
if(value != null)
153+
if (value != null)
170154
{
171155
MACAddress = value.MACAddress;
172156
Broadcast = value.Broadcast;
@@ -293,7 +277,7 @@ private async void AddClientAction()
293277
}, instance =>
294278
{
295279
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
296-
}, WakeOnLANClientGroups, new WakeOnLANClientInfo() { MACAddress = MACAddress, Broadcast = Broadcast, Port = Port });
280+
}, WakeOnLANClientManager.GetClientGroups(), new WakeOnLANClientInfo() { MACAddress = MACAddress, Broadcast = Broadcast, Port = Port });
297281

298282
customDialog.Content = new WakeOnLANClientDialog
299283
{
@@ -334,7 +318,7 @@ private async void EditClientAction()
334318
}, instance =>
335319
{
336320
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
337-
}, WakeOnLANClientGroups, SelectedClient);
321+
}, WakeOnLANClientManager.GetClientGroups(), SelectedClient);
338322

339323
customDialog.Content = new WakeOnLANClientDialog
340324
{
@@ -373,7 +357,7 @@ private async void CopyAsProfileAction()
373357
}, instance =>
374358
{
375359
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
376-
}, WakeOnLANClientGroups, SelectedClient);
360+
}, WakeOnLANClientManager.GetClientGroups(), SelectedClient);
377361

378362
customDialog.Content = new WakeOnLANClientDialog
379363
{

0 commit comments

Comments
 (0)