Skip to content

Commit 39d6956

Browse files
committed
Feature: Hosts editor
1 parent bfdb012 commit 39d6956

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

Source/GlobalAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
[assembly: AssemblyTrademark("")]
77
[assembly: AssemblyCulture("")]
88

9-
[assembly: AssemblyVersion("2025.1.18.0")]
10-
[assembly: AssemblyFileVersion("2025.1.18.0")]
9+
[assembly: AssemblyVersion("2025.3.16.0")]
10+
[assembly: AssemblyFileVersion("2025.3.16.0")]

Source/NETworkManager.Localization/Resources/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,4 +3879,7 @@ Right-click for more options.</value>
38793879
<data name="ProfileFile" xml:space="preserve">
38803880
<value>Profile file</value>
38813881
</data>
3882+
<data name="ApplicationName_HostsEditor" xml:space="preserve">
3883+
<value>Hosts Editor</value>
3884+
</data>
38823885
</root>

Source/NETworkManager.Models/ApplicationManager.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
1+
using MahApps.Metro.IconPacks;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Windows.Controls;
5-
using MahApps.Metro.IconPacks;
66

77
namespace NETworkManager.Models;
88

@@ -92,6 +92,9 @@ public static Canvas GetIcon(ApplicationName name)
9292
case ApplicationName.SNTPLookup:
9393
canvas.Children.Add(new PackIconMaterial { Kind = PackIconMaterialKind.ClockCheckOutline });
9494
break;
95+
case ApplicationName.HostsEditor:
96+
canvas.Children.Add(new PackIconMaterial { Kind = PackIconMaterialKind.FileEditOutline });
97+
break;
9598
case ApplicationName.DiscoveryProtocol:
9699
canvas.Children.Add(new PackIconMaterial { Kind = PackIconMaterialKind.SwapHorizontal });
97100
break;

Source/NETworkManager.Models/ApplicationName.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public enum ApplicationName
9090
/// </summary>
9191
SNTPLookup,
9292

93+
/// <summary>
94+
/// Hosts editor application.
95+
/// </summary>
96+
HostsEditor,
97+
9398
/// <summary>
9499
/// Discovery protocol application.
95100
/// </summary>

Source/NETworkManager.Settings/SettingsManager.cs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
using System;
2-
using System.Collections.ObjectModel;
1+
using log4net;
2+
using NETworkManager.Models;
3+
using NETworkManager.Models.Network;
4+
using System;
35
using System.IO;
46
using System.Linq;
57
using System.Xml.Serialization;
6-
using log4net;
7-
using NETworkManager.Controls;
8-
using NETworkManager.Models;
9-
using NETworkManager.Models.Network;
10-
using NETworkManager.Models.PowerShell;
118

129
namespace NETworkManager.Settings;
1310

@@ -189,7 +186,7 @@ public static void Upgrade(Version fromVersion, Version toVersion)
189186
if (fromVersion < new Version(2023, 11, 28, 0))
190187
UpgradeTo_2023_11_28_0();
191188

192-
189+
193190
// 2024.11.11.0
194191
if (fromVersion < new Version(2024, 11, 11, 0))
195192
UpgradeTo_2024_11_11_0();
@@ -205,7 +202,7 @@ public static void Upgrade(Version fromVersion, Version toVersion)
205202
Log.Info("Settings upgrade finished!");
206203
}
207204

208-
/// <summary>
205+
/// <summary>
209206
/// Method to apply changes for version 2023.3.7.0.
210207
/// </summary>
211208
private static void UpgradeTo_2023_3_7_0()
@@ -217,14 +214,14 @@ private static void UpgradeTo_2023_3_7_0()
217214
Current.General_ApplicationList.Add(ApplicationManager.GetDefaultList()
218215
.First(x => x.Name == ApplicationName.SNTPLookup));
219216
Current.SNTPLookup_SNTPServers =
220-
new ObservableCollection<ServerConnectionInfoProfile>(SNTPServer.GetDefaultList());
217+
[.. SNTPServer.GetDefaultList()];
221218

222219
// Add IP Scanner custom commands
223220
foreach (var customCommand in from customCommand in IPScannerCustomCommand.GetDefaultList()
224-
let customCommandFound =
225-
Current.IPScanner_CustomCommands.FirstOrDefault(x => x.Name == customCommand.Name)
226-
where customCommandFound == null
227-
select customCommand)
221+
let customCommandFound =
222+
Current.IPScanner_CustomCommands.FirstOrDefault(x => x.Name == customCommand.Name)
223+
where customCommandFound == null
224+
select customCommand)
228225
{
229226
Log.Info($"Add \"{customCommand.Name}\" to \"IPScanner_CustomCommands\"...");
230227
Current.IPScanner_CustomCommands.Add(customCommand);
@@ -251,7 +248,7 @@ private static void UpgradeTo_2023_3_7_0()
251248
// Add new DNS lookup profiles
252249
Log.Info("Init \"DNSLookup_DNSServers_v2\" with default DNS servers...");
253250
Current.DNSLookup_DNSServers =
254-
new ObservableCollection<DNSServerConnectionInfoProfile>(DNSServer.GetDefaultList());
251+
[.. DNSServer.GetDefaultList()];
255252
}
256253

257254
/// <summary>
@@ -263,7 +260,7 @@ private static void UpgradeTo_2023_4_26_0()
263260

264261
// Add SNMP OID profiles
265262
Log.Info("Add SNMP OID profiles...");
266-
Current.SNMP_OidProfiles = new ObservableCollection<SNMPOIDProfileInfo>(SNMPOIDProfile.GetDefaultList());
263+
Current.SNMP_OidProfiles = [.. SNMPOIDProfile.GetDefaultList()];
267264
}
268265

269266
/// <summary>
@@ -297,9 +294,9 @@ private static void UpgradeTo_2023_11_28_0()
297294
// Add DNS lookup profiles after refactoring
298295
Log.Info("Init \"DNSLookup_DNSServers\" with default DNS servers...");
299296
Current.DNSLookup_DNSServers =
300-
new ObservableCollection<DNSServerConnectionInfoProfile>(DNSServer.GetDefaultList());
297+
[.. DNSServer.GetDefaultList()];
301298
}
302-
299+
303300
/// <summary>
304301
/// Method to apply changes for version 2024.11.11.0.
305302
/// </summary>
@@ -309,7 +306,7 @@ private static void UpgradeTo_2024_11_11_0()
309306

310307
Log.Info("Reset ApplicationList to default...");
311308
Current.General_ApplicationList =
312-
new ObservableSetCollection<ApplicationInfo>(ApplicationManager.GetDefaultList());
309+
[.. ApplicationManager.GetDefaultList()];
313310
}
314311

315312
/// <summary>
@@ -319,6 +316,13 @@ private static void UpgradeTo_2024_11_11_0()
319316
private static void UpgradeToLatest(Version version)
320317
{
321318
Log.Info($"Apply upgrade to {version}...");
319+
320+
// Add Hosts editor application
321+
Log.Info("Add new app \"Hosts Editor\"...");
322+
323+
Current.General_ApplicationList.Insert(
324+
ApplicationManager.GetDefaultList().ToList().FindIndex(x => x.Name == ApplicationName.HostsEditor),
325+
ApplicationManager.GetDefaultList().First(x => x.Name == ApplicationName.HostsEditor));
322326
}
323327

324328
#endregion

0 commit comments

Comments
 (0)