Skip to content

Commit afe7567

Browse files
committed
IPScanner - Dialog (add/edit/copy as/delete) added
1 parent 14d7d19 commit afe7567

16 files changed

Lines changed: 425 additions & 42 deletions

Source/NETworkManager/Models/Settings/IPScannerProfileInfo.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ public class IPScannerProfileInfo
44
{
55
public string Name { get; set; }
66
public string IPRange { get; set; }
7+
public string Group { get; set; }
78

89
public IPScannerProfileInfo()
910
{
1011

1112
}
1213

13-
public IPScannerProfileInfo(string name, string ipRange)
14+
public IPScannerProfileInfo(string name, string ipRange, string group)
1415
{
1516
Name = name;
1617
IPRange = ipRange;
18+
Group = group;
1719
}
1820
}
1921
}

Source/NETworkManager/NETworkManager.csproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@
187187
<Compile Include="Models\RemoteDesktop\RemoteDesktopSessionInfo.cs" />
188188
<Compile Include="Models\Settings\RemoteDesktopSessionManager.cs" />
189189
<Compile Include="Models\Settings\RemoteDesktopSessionInfo.cs" />
190+
<Compile Include="ViewModels\Dialogs\IPScannerProfileViewModel.cs" />
190191
<Compile Include="ViewModels\Dialogs\RemoteDesktopSessionViewModel.cs" />
191-
<Compile Include="ViewModels\Dialogs\ConnectRemoteDesktopSessionViewModel.cs" />
192+
<Compile Include="ViewModels\Dialogs\RemoteDesktopSessionConnectViewModel.cs" />
192193
<Compile Include="Models\Network\DNSLookup.cs" />
193194
<Compile Include="Models\Network\DNSLookupCompleteArgs.cs" />
194195
<Compile Include="Models\Network\DNSLookupOptions.cs" />
@@ -233,11 +234,14 @@
233234
<Compile Include="Controls\DragablzTabHostWindow.xaml.cs">
234235
<DependentUpon>DragablzTabHostWindow.xaml</DependentUpon>
235236
</Compile>
237+
<Compile Include="Views\Dialogs\IPScannerProfileDialog.xaml.cs">
238+
<DependentUpon>IPScannerProfileDialog.xaml</DependentUpon>
239+
</Compile>
236240
<Compile Include="Views\Dialogs\RemoteDesktopSessionDialog.xaml.cs">
237241
<DependentUpon>RemoteDesktopSessionDialog.xaml</DependentUpon>
238242
</Compile>
239-
<Compile Include="Views\Dialogs\ConnectRemoteDesktopSessionDialog.xaml.cs">
240-
<DependentUpon>ConnectRemoteDesktopSessionDialog.xaml</DependentUpon>
243+
<Compile Include="Views\Dialogs\RemoteDesktopSessionConnectDialog.xaml.cs">
244+
<DependentUpon>RemoteDesktopSessionConnectDialog.xaml</DependentUpon>
241245
</Compile>
242246
<Compile Include="Views\Settings\SettingsApplicationRemoteDesktopView.xaml.cs">
243247
<DependentUpon>SettingsApplicationRemoteDesktopView.xaml</DependentUpon>
@@ -359,11 +363,15 @@
359363
<Generator>MSBuild:Compile</Generator>
360364
<SubType>Designer</SubType>
361365
</Page>
366+
<Page Include="Views\Dialogs\IPScannerProfileDialog.xaml">
367+
<Generator>MSBuild:Compile</Generator>
368+
<SubType>Designer</SubType>
369+
</Page>
362370
<Page Include="Views\Dialogs\RemoteDesktopSessionDialog.xaml">
363371
<Generator>MSBuild:Compile</Generator>
364372
<SubType>Designer</SubType>
365373
</Page>
366-
<Page Include="Views\Dialogs\ConnectRemoteDesktopSessionDialog.xaml">
374+
<Page Include="Views\Dialogs\RemoteDesktopSessionConnectDialog.xaml">
367375
<SubType>Designer</SubType>
368376
<Generator>MSBuild:Compile</Generator>
369377
</Page>

Source/NETworkManager/Resources/Localization/Resources.de-DE.xaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
<system:String x:Key="String_Header_SelectAProfile">Profil auswählen...</system:String>
5656
<system:String x:Key="String_Header_Profiles">Profile</system:String>
5757
<system:String x:Key="String_Header_AddProfile">Profil hinzufügen</system:String>
58+
<system:String x:Key="String_Header_EditProfile">Profil bearbeiten</system:String>
59+
<system:String x:Key="String_Header_CopyProfile">Profil kopieren</system:String>
5860
<system:String x:Key="String_Header_AddClient">Client hinzufügen</system:String>
5961
<system:String x:Key="String_Header_Libraries">Bibliotheken</system:String>
6062
<system:String x:Key="String_Header_License">Lizenz</system:String>
@@ -64,9 +66,10 @@
6466
<system:String x:Key="String_Header_Subnet">Subnetz</system:String>
6567
<system:String x:Key="String_Header_IPv4Calculator">IPv4-Rechner</system:String>
6668
<system:String x:Key="String_Header_IPv4Splitter">IPv4-Splitter</system:String>
67-
<system:String x:Key="String_Header_ConnectRemoteDesktopConnection">Remote Desktop Sitzung verbinden</system:String>
68-
<system:String x:Key="String_Header_AddRemoteDesktopConnection">Remote Desktop Sitzung hinzufügen</system:String>
69-
<system:String x:Key="String_Header_EditRemoteDesktopConnection">Remote Desktop Sitzung bearbeiten</system:String>
69+
<system:String x:Key="String_Header_Connect">Verbinden</system:String>
70+
<system:String x:Key="String_Header_AddSession">Sitzung hinzufügen</system:String>
71+
<system:String x:Key="String_Header_EditSession">Sitzung bearbeiten</system:String>
72+
<system:String x:Key="String_Header_CopySession">Sitzung kopieren</system:String>
7073
<system:String x:Key="String_Header_Sessions">Sitzungen</system:String>
7174
<system:String x:Key="String_Header_RemoteDesktop">Remote Desktop</system:String>
7275

@@ -259,7 +262,8 @@
259262
<system:String x:Key="String_Default">Standard</system:String>
260263
<system:String x:Key="String_CopyAs">Kopieren als</system:String>
261264
<system:String x:Key="String_IPScannerProfiles">IP-Scanner Profile</system:String>
262-
265+
<system:String x:Key="String_IPRange">IP-Bereich</system:String>
266+
263267
<!-- ToolTip -->
264268
<system:String x:Key="String_ToolTip_Settings">Einstellungen</system:String>
265269
<system:String x:Key="String_ToolTip_Expand">Erweitern</system:String>

Source/NETworkManager/Resources/Localization/Resources.en-US.xaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
<system:String x:Key="String_Header_SelectAProfile">Select a profile...</system:String>
5656
<system:String x:Key="String_Header_Profiles">Profiles</system:String>
5757
<system:String x:Key="String_Header_AddProfile">Add profile</system:String>
58+
<system:String x:Key="String_Header_EditProfile">Edit profile</system:String>
59+
<system:String x:Key="String_Header_CopyProfile">Copy profile</system:String>
5860
<system:String x:Key="String_Header_AddClient">Add client</system:String>
5961
<system:String x:Key="String_Header_Libraries">Libraries</system:String>
6062
<system:String x:Key="String_Header_License">License</system:String>
@@ -64,9 +66,10 @@
6466
<system:String x:Key="String_Header_Subnet">Subnet</system:String>
6567
<system:String x:Key="String_Header_IPv4Calculator">IPv4-Calculator</system:String>
6668
<system:String x:Key="String_Header_IPv4Splitter">IPv4-Splitter</system:String>
67-
<system:String x:Key="String_Header_ConnectRemoteDesktopConnection">Connect remote desktop session</system:String>
68-
<system:String x:Key="String_Header_AddRemoteDesktopConnection">Add remote desktop session</system:String>
69-
<system:String x:Key="String_Header_EditRemoteDesktopConnection">Edit remote desktop session</system:String>
69+
<system:String x:Key="String_Header_Connect">Connect</system:String>
70+
<system:String x:Key="String_Header_AddSession">Add session</system:String>
71+
<system:String x:Key="String_Header_EditSession">Edit session</system:String>
72+
<system:String x:Key="String_Header_CopySession">Copy session</system:String>
7073
<system:String x:Key="String_Header_Sessions">Sessions</system:String>
7174
<system:String x:Key="String_Header_RemoteDesktop">Remote Desktop</system:String>
7275

@@ -259,6 +262,7 @@
259262
<system:String x:Key="String_Default">Default</system:String>
260263
<system:String x:Key="String_CopyAs">Copy as</system:String>
261264
<system:String x:Key="String_IPScannerProfiles">IP-Scanner profiles</system:String>
265+
<system:String x:Key="String_IPRange">IP range</system:String>
262266

263267
<!-- ToolTip -->
264268
<system:String x:Key="String_ToolTip_Settings">Settings</system:String>

Source/NETworkManager/ViewModels/Applications/IPScannerViewModel.cs

Lines changed: 117 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
using System.ComponentModel;
1414
using MahApps.Metro.Controls.Dialogs;
1515
using System.Windows.Data;
16+
using NETworkManager.ViewModels.Dialogs;
17+
using NETworkManager.Views.Dialogs;
1618

1719
namespace NETworkManager.ViewModels.Applications
1820
{
@@ -259,6 +261,22 @@ public ICollectionView IPScannerProfiles
259261
get { return _ipScannerProfiles; }
260262
}
261263

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+
262280
private IPScannerProfileInfo _selectedProfile = new IPScannerProfileInfo();
263281
public IPScannerProfileInfo SelectedProfile
264282
{
@@ -305,6 +323,7 @@ public IPScannerViewModel(IDialogCoordinator instance)
305323
IPScannerProfileManager.Load();
306324

307325
_ipScannerProfiles = CollectionViewSource.GetDefaultView(IPScannerProfileManager.Profiles);
326+
_ipScannerProfiles.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
308327
_ipScannerProfiles.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
309328

310329
LoadSettings();
@@ -365,24 +384,112 @@ public ICommand AddProfileCommand
365384
}
366385

367386
private async void AddProfileAction()
387+
{
388+
CustomDialog customDialog = new CustomDialog()
389+
{
390+
Title = Application.Current.Resources["String_Header_AddProfile"] as string
391+
};
392+
393+
IPScannerProfileViewModel ipScannerProfileViewModel = new IPScannerProfileViewModel(instance =>
394+
{
395+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
396+
397+
IPScannerProfileInfo ipScannerProfileInfo = new IPScannerProfileInfo
398+
{
399+
Name = instance.Name,
400+
IPRange = instance.IPRange,
401+
Group = instance.Group
402+
};
403+
404+
IPScannerProfileManager.AddProfile(ipScannerProfileInfo);
405+
}, instance =>
406+
{
407+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
408+
}, IPScannerProfileGroups, new IPScannerProfileInfo() { IPRange = IPRange });
409+
410+
customDialog.Content = new IPScannerProfileDialog
411+
{
412+
DataContext = ipScannerProfileViewModel
413+
};
414+
415+
await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
416+
}
417+
418+
419+
public ICommand EditProfileCommand
368420
{
369-
MetroDialogSettings settings = AppearanceManager.MetroDialog;
421+
get { return new RelayCommand(p => EditProfileAction()); }
422+
}
370423

371-
settings.AffirmativeButtonText = Application.Current.Resources["String_Button_Add"] as string;
372-
settings.NegativeButtonText = Application.Current.Resources["String_Button_Cancel"] as string;
424+
private async void EditProfileAction()
425+
{
426+
CustomDialog customDialog = new CustomDialog()
427+
{
428+
Title = Application.Current.Resources["String_Header_EditProfile"] as string
429+
};
430+
431+
IPScannerProfileViewModel ipScannerProfileViewModel = new IPScannerProfileViewModel(instance =>
432+
{
433+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
373434

374-
string name = await dialogCoordinator.ShowInputAsync(this, Application.Current.Resources["String_Header_AddProfile"] as string, Application.Current.Resources["String_EnterNameForProfile"] as string, settings);
435+
IPScannerProfileManager.RemoveProfile(SelectedProfile);
375436

376-
if (string.IsNullOrEmpty(name))
377-
return;
437+
IPScannerProfileInfo ipScannerProfileInfo = new IPScannerProfileInfo
438+
{
439+
Name = instance.Name,
440+
IPRange = instance.IPRange,
441+
Group = instance.Group
442+
};
443+
444+
IPScannerProfileManager.AddProfile(ipScannerProfileInfo);
445+
}, instance =>
446+
{
447+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
448+
}, IPScannerProfileGroups, SelectedProfile);
449+
450+
customDialog.Content = new IPScannerProfileDialog
451+
{
452+
DataContext = ipScannerProfileViewModel
453+
};
454+
455+
await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
456+
}
457+
458+
public ICommand CopyAsProfileCommand
459+
{
460+
get { return new RelayCommand(p => CopyAsProfileAction()); }
461+
}
462+
463+
private async void CopyAsProfileAction()
464+
{
465+
CustomDialog customDialog = new CustomDialog()
466+
{
467+
Title = Application.Current.Resources["String_Header_CopyProfile"] as string
468+
};
469+
470+
IPScannerProfileViewModel ipScannerProfileViewModel = new IPScannerProfileViewModel(instance =>
471+
{
472+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
473+
474+
IPScannerProfileInfo ipScannerProfileInfo = new IPScannerProfileInfo
475+
{
476+
Name = instance.Name,
477+
IPRange = instance.IPRange,
478+
Group = instance.Group
479+
};
480+
481+
IPScannerProfileManager.AddProfile(ipScannerProfileInfo);
482+
}, instance =>
483+
{
484+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
485+
}, IPScannerProfileGroups, SelectedProfile);
378486

379-
IPScannerProfileInfo profile = new IPScannerProfileInfo
487+
customDialog.Content = new IPScannerProfileDialog
380488
{
381-
Name = name,
382-
IPRange = IPRange
489+
DataContext = ipScannerProfileViewModel
383490
};
384491

385-
IPScannerProfileManager.AddProfile(profile);
492+
await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
386493
}
387494

388495
public ICommand DeleteProfileCommand

Source/NETworkManager/ViewModels/Applications/RemoteDesktopViewModel.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Windows.Input;
66
using NETworkManager.Views.Dialogs;
77
using System.Windows;
8-
using NETworkManager.ViewModels.Network;
8+
using NETworkManager.ViewModels.Dialogs;
99
using NETworkManager.Models.Settings;
1010
using System.ComponentModel;
1111
using System.Windows.Data;
@@ -50,10 +50,10 @@ public List<string> RemoteDesktopSessionGroups
5050
{
5151
List<string> list = new List<string>();
5252

53-
foreach (RemoteDesktopSessionInfo info in RemoteDesktopSessionManager.Sessions)
53+
foreach (RemoteDesktopSessionInfo session in RemoteDesktopSessionManager.Sessions)
5454
{
55-
if (!list.Contains(info.Group))
56-
list.Add(info.Group);
55+
if (!list.Contains(session.Group))
56+
list.Add(session.Group);
5757
}
5858

5959
return list;
@@ -144,10 +144,10 @@ private async void ConnectRemoteDesktopSessionAction()
144144
{
145145
CustomDialog customDialog = new CustomDialog()
146146
{
147-
Title = Application.Current.Resources["String_Header_ConnectRemoteDesktopConnection"] as string
147+
Title = Application.Current.Resources["String_Header_Connect"] as string
148148
};
149149

150-
ConnectRemoteDesktopSessionViewModel connectRemoteDesktopSessionViewModel = new ConnectRemoteDesktopSessionViewModel(instance =>
150+
RemoteDesktopSessionConnectViewModel connectRemoteDesktopSessionViewModel = new RemoteDesktopSessionConnectViewModel(instance =>
151151
{
152152
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
153153
ConfigurationManager.Current.FixAirspace = false;
@@ -164,7 +164,7 @@ private async void ConnectRemoteDesktopSessionAction()
164164
ConfigurationManager.Current.FixAirspace = false;
165165
});
166166

167-
customDialog.Content = new ConnectRemoteDesktopSessionDialog
167+
customDialog.Content = new RemoteDesktopSessionConnectDialog
168168
{
169169
DataContext = connectRemoteDesktopSessionViewModel
170170
};
@@ -182,7 +182,7 @@ private async void AddSessionAction()
182182
{
183183
CustomDialog customDialog = new CustomDialog()
184184
{
185-
Title = Application.Current.Resources["String_Header_AddRemoteDesktopConnection"] as string
185+
Title = Application.Current.Resources["String_Header_AddSession"] as string
186186
};
187187

188188
RemoteDesktopSessionViewModel remoteDesktopSessionViewModel = new RemoteDesktopSessionViewModel(instance =>
@@ -237,7 +237,7 @@ private async void EditSessionAction()
237237
{
238238
CustomDialog customDialog = new CustomDialog()
239239
{
240-
Title = Application.Current.Resources["String_Header_EditRemoteDesktopConnection"] as string
240+
Title = Application.Current.Resources["String_Header_EditSession"] as string
241241
};
242242

243243
RemoteDesktopSessionViewModel remoteDesktopSessionViewModel = new RemoteDesktopSessionViewModel(instance =>
@@ -279,7 +279,7 @@ private async void CopyAsSessionAction()
279279
{
280280
CustomDialog customDialog = new CustomDialog()
281281
{
282-
Title = Application.Current.Resources["String_Header_AssRemoteDesktopConnection"] as string
282+
Title = Application.Current.Resources["String_Header_CopySession"] as string
283283
};
284284

285285
RemoteDesktopSessionViewModel remoteDesktopSessionViewModel = new RemoteDesktopSessionViewModel(instance =>

0 commit comments

Comments
 (0)