Skip to content

Commit f4ae048

Browse files
authored
Rename groups (#78)
* Trying to get group name... * Update * Rename groups added * Rename groups added
1 parent 79feef0 commit f4ae048

24 files changed

+722
-154
lines changed

Source/NETworkManager/Models/Settings/IPScannerProfileManager.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Collections.ObjectModel;
34
using System.IO;
45
using System.Xml.Serialization;
@@ -105,5 +106,21 @@ public static void RemoveProfile(IPScannerProfileInfo profile)
105106
{
106107
Profiles.Remove(profile);
107108
}
109+
110+
public static void RenameGroup(string oldGroup, string group)
111+
{
112+
// Go through all groups
113+
for(int i=0; i < Profiles.Count; i++ )
114+
{
115+
// Find specific group
116+
if (Profiles[i].Group == oldGroup)
117+
{
118+
// Rename the group
119+
Profiles[i].Group = group;
120+
121+
ProfilesChanged = true;
122+
}
123+
}
124+
}
108125
}
109126
}

Source/NETworkManager/Models/Settings/NetworkInterfaceProfileManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,21 @@ public static void RemoveProfile(NetworkInterfaceProfileInfo profile)
106106
{
107107
Profiles.Remove(profile);
108108
}
109+
110+
public static void RenameGroup(string oldGroup, string group)
111+
{
112+
// Go through all groups
113+
for (int i = 0; i < Profiles.Count; i++)
114+
{
115+
// Find specific group
116+
if (Profiles[i].Group == oldGroup)
117+
{
118+
// Rename the group
119+
Profiles[i].Group = group;
120+
121+
ProfilesChanged = true;
122+
}
123+
}
124+
}
109125
}
110126
}

Source/NETworkManager/Models/Settings/PortScannerProfileManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,21 @@ public static void RemoveProfile(PortScannerProfileInfo profile)
133133
{
134134
Profiles.Remove(profile);
135135
}
136+
137+
public static void RenameGroup(string oldGroup, string group)
138+
{
139+
// Go through all groups
140+
for (int i = 0; i < Profiles.Count; i++)
141+
{
142+
// Find specific group
143+
if (Profiles[i].Group == oldGroup)
144+
{
145+
// Rename the group
146+
Profiles[i].Group = group;
147+
148+
ProfilesChanged = true;
149+
}
150+
}
151+
}
136152
}
137153
}

Source/NETworkManager/Models/Settings/PuTTYSessionManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,21 @@ public static void RemoveSession(PuTTYSessionInfo session)
105105
{
106106
Sessions.Remove(session);
107107
}
108+
109+
public static void RenameGroup(string oldGroup, string group)
110+
{
111+
// Go through all groups
112+
for (int i = 0; i < Sessions.Count; i++)
113+
{
114+
// Find specific group
115+
if (Sessions[i].Group == oldGroup)
116+
{
117+
// Rename the group
118+
Sessions[i].Group = group;
119+
120+
SessionsChanged = true;
121+
}
122+
}
123+
}
108124
}
109125
}

Source/NETworkManager/Models/Settings/RemoteDesktopSessionManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,21 @@ public static void RemoveSession(RemoteDesktopSessionInfo session)
105105
{
106106
Sessions.Remove(session);
107107
}
108+
109+
public static void RenameGroup(string oldGroup, string group)
110+
{
111+
// Go through all groups
112+
for (int i = 0; i < Sessions.Count; i++)
113+
{
114+
// Find specific group
115+
if (Sessions[i].Group == oldGroup)
116+
{
117+
// Rename the group
118+
Sessions[i].Group = group;
119+
120+
SessionsChanged = true;
121+
}
122+
}
123+
}
108124
}
109125
}

Source/NETworkManager/Models/Settings/WakeOnLANClientManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,21 @@ public static void RemoveClient(WakeOnLANClientInfo client)
105105
{
106106
Clients.Remove(client);
107107
}
108+
109+
public static void RenameGroup(string oldGroup, string group)
110+
{
111+
// Go through all groups
112+
for (int i = 0; i < Clients.Count; i++)
113+
{
114+
// Find specific group
115+
if (Clients[i].Group == oldGroup)
116+
{
117+
// Rename the group
118+
Clients[i].Group = group;
119+
120+
ClientsChanged = true;
121+
}
122+
}
123+
}
108124
}
109125
}

Source/NETworkManager/NETworkManager.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
<Compile Include="ViewModels\Applications\SNMPViewModel.cs" />
273273
<Compile Include="ViewModels\Applications\HTTPHeadersViewModel.cs" />
274274
<Compile Include="ViewModels\Applications\ARPTableViewModel.cs" />
275+
<Compile Include="ViewModels\Dialogs\EditGroupViewModel.cs" />
275276
<Compile Include="ViewModels\Dialogs\CredentialsMasterPasswordViewModel.cs" />
276277
<Compile Include="ViewModels\Dialogs\CredentialViewModel.cs" />
277278
<Compile Include="ViewModels\Dialogs\CredentialsSetMasterPasswordViewModel.cs" />
@@ -352,6 +353,9 @@
352353
<Compile Include="Views\Dialogs\CredentialDialog.xaml.cs">
353354
<DependentUpon>CredentialDialog.xaml</DependentUpon>
354355
</Compile>
356+
<Compile Include="Views\Dialogs\EditGroupDialog.xaml.cs">
357+
<DependentUpon>EditGroupDialog.xaml</DependentUpon>
358+
</Compile>
355359
<Compile Include="Views\Dialogs\CredentialsMasterPasswordDialog.xaml.cs">
356360
<DependentUpon>CredentialsMasterPasswordDialog.xaml</DependentUpon>
357361
</Compile>
@@ -612,6 +616,10 @@
612616
<Generator>MSBuild:Compile</Generator>
613617
<SubType>Designer</SubType>
614618
</Page>
619+
<Page Include="Views\Dialogs\EditGroupDialog.xaml">
620+
<Generator>MSBuild:Compile</Generator>
621+
<SubType>Designer</SubType>
622+
</Page>
615623
<Page Include="Views\Dialogs\CredentialsMasterPasswordDialog.xaml">
616624
<Generator>MSBuild:Compile</Generator>
617625
<SubType>Designer</SubType>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
<system:String x:Key="String_Header_Data">Daten</system:String>
105105
<system:String x:Key="String_Header_IPScanner">IP-Scanner</system:String>
106106
<system:String x:Key="String_Header_PuTTY">PuTTY</system:String>
107-
107+
<system:String x:Key="String_Header_EditGroup">Gruppe bearbeiten</system:String>
108+
108109
<!-- Normal strings -->
109110
<system:String x:Key="String_ProductName">NETworkManager</system:String>
110111
<system:String x:Key="String_Slogan">Ein leistungsstarkes Tool zum Verwalten von Netzwerken und zur Behebung von Netzwerkproblemen!</system:String>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<system:String x:Key="String_Header_Data">Data</system:String>
105105
<system:String x:Key="String_Header_IPScanner">IP Scanner</system:String>
106106
<system:String x:Key="String_Header_PuTTY">PuTTY</system:String>
107+
<system:String x:Key="String_Header_EditGroup">Edit group</system:String>
107108

108109
<!-- Normal strings -->
109110
<system:String x:Key="String_ProductName">NETworkManager</system:String>

Source/NETworkManager/ViewModels/Applications/IPScannerViewModel.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using NETworkManager.ViewModels.Dialogs;
1717
using NETworkManager.Views.Dialogs;
1818
using System.Linq;
19+
using System.Windows.Controls;
1920

2021
namespace NETworkManager.ViewModels.Applications
2122
{
@@ -614,7 +615,6 @@ public ICommand DeleteProfileCommand
614615

615616
private async void DeleteProfileAction()
616617
{
617-
618618
CustomDialog customDialog = new CustomDialog()
619619
{
620620
Title = Application.Current.Resources["String_Header_DeleteProfile"] as string
@@ -637,6 +637,38 @@ private async void DeleteProfileAction()
637637

638638
await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
639639
}
640+
641+
public ICommand EditGroupCommand
642+
{
643+
get { return new RelayCommand(p => EditGroupAction(p)); }
644+
}
645+
646+
private async void EditGroupAction(object group)
647+
{
648+
CustomDialog customDialog = new CustomDialog()
649+
{
650+
Title = Application.Current.Resources["String_Header_EditGroup"] as string
651+
};
652+
653+
EditGroupViewModel editGroupViewModel = new EditGroupViewModel(instance =>
654+
{
655+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
656+
657+
IPScannerProfileManager.RenameGroup(instance.OldGroup, instance.Group);
658+
659+
_ipScannerProfiles.Refresh();
660+
}, instance =>
661+
{
662+
dialogCoordinator.HideMetroDialogAsync(this, customDialog);
663+
}, group.ToString());
664+
665+
customDialog.Content = new EditGroupDialog
666+
{
667+
DataContext = editGroupViewModel
668+
};
669+
670+
await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
671+
}
640672
#endregion
641673

642674
#region Methods

0 commit comments

Comments
 (0)