Skip to content

Commit 48576f6

Browse files
committed
Close #40, Close 39, dialogs improved, somen changes
1 parent bdf1e43 commit 48576f6

35 files changed

Lines changed: 686 additions & 433 deletions

Source/NETworkManager/App.xaml.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ private void Application_Startup(object sender, StartupEventArgs e)
2121
// Parse the command line arguments and store them in the current configuration
2222
CommandLineManager.Parse();
2323

24-
if (CommandLineManager.Current.Help)
25-
{
26-
StartupUri = new Uri("/Views/Help/HelpCommandLineWindow.xaml", UriKind.Relative);
27-
return;
28-
}
29-
3024
// If we have restart our application... wait until it has finished
3125
if (CommandLineManager.Current.RestartPid != 0)
3226
{
@@ -37,12 +31,26 @@ private void Application_Startup(object sender, StartupEventArgs e)
3731
if (process != null)
3832
process.WaitForExit();
3933
}
40-
34+
4135
// Detect the current configuration
4236
ConfigurationManager.Detect();
4337

38+
// Get assembly informations
39+
AssemblyManager.Load();
40+
4441
// Load settings
4542
SettingsManager.Load();
43+
44+
// Load localization (requires settings to be loaded first)
45+
LocalizationManager.Load();
46+
47+
if (CommandLineManager.Current.Help)
48+
{
49+
StartupUri = new Uri("/Views/Help/HelpCommandLineWindow.xaml", UriKind.Relative);
50+
return;
51+
}
52+
53+
// Load templates
4654
TemplateManager.LoadNetworkInterfaceConfigTemplates();
4755
TemplateManager.LoadWakeOnLANTemplates();
4856

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private void OnPropertyChanged(string propertyName)
3535
#endregion
3636

3737
#region Variables
38-
MetroDialogSettings dialogSettings = new MetroDialogSettings();
38+
3939

4040
NotifyIcon notifyIcon;
4141

@@ -218,12 +218,8 @@ public MainWindow()
218218
InitializeComponent();
219219
DataContext = this;
220220

221-
// Get assembly informations
222-
AssemblyManager.Load();
223221
Version = AssemblyManager.Current.AssemblyVersion.ToString();
224222

225-
// Load localization
226-
LocalizationManager.Load();
227223
LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(LocalizationManager.Culture.IetfLanguageTag)));
228224

229225
// Load appearance
@@ -235,12 +231,6 @@ public MainWindow()
235231
Opacity = SettingsManager.Current.Appearance_Opacity;
236232
}
237233

238-
// Dialog
239-
dialogSettings.CustomResourceDictionary = new ResourceDictionary
240-
{
241-
Source = new Uri("NETworkManager;component/Resources/Styles/MetroDialogStyles.xaml", UriKind.RelativeOrAbsolute)
242-
};
243-
244234
// Autostart & Window start
245235
if (CommandLineManager.Current.Autostart && SettingsManager.Current.Autostart_StartMinimizedInTray || SettingsManager.Current.TrayIcon_AlwaysShowIcon)
246236
InitNotifyIcon();
@@ -291,7 +281,7 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
291281
{
292282
e.Cancel = true;
293283

294-
MetroDialogSettings settings = dialogSettings;
284+
MetroDialogSettings settings = AppearanceManager.MetroDialog;
295285

296286
settings.AffirmativeButtonText = System.Windows.Application.Current.Resources["String_Button_Close"] as string;
297287
settings.NegativeButtonText = System.Windows.Application.Current.Resources["String_Button_Cancel"] as string;
@@ -645,7 +635,7 @@ private async void OpenSettingsAction()
645635
{
646636
ShowWindowAction();
647637

648-
MetroDialogSettings settings = dialogSettings;
638+
MetroDialogSettings settings = AppearanceManager.MetroDialog;
649639

650640
settings.AffirmativeButtonText = System.Windows.Application.Current.Resources["String_Button_RestartNow"] as string;
651641
settings.NegativeButtonText = System.Windows.Application.Current.Resources["String_Button_OK"] as string;

Source/NETworkManager/Models/Network/DNSLookup.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ public class DNSLookup
99
{
1010
#region Variables
1111
Resolver dnsResolver = new Resolver();
12-
13-
int resourceRecordsCount;
1412
#endregion
1513

1614
#region Events

Source/NETworkManager/Models/Settings/AppearanceManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using MahApps.Metro;
2+
using MahApps.Metro.Controls.Dialogs;
23
using System;
34
using System.Windows;
45

56
namespace NETworkManager.Models.Settings
67
{
78
public static class AppearanceManager
89
{
10+
public static MetroDialogSettings MetroDialog = new MetroDialogSettings();
11+
912
/// <summary>
1013
/// Load Appearance (AppTheme and Accent) from the user settings.
1114
/// </summary>
@@ -22,6 +25,11 @@ public static void Load()
2225

2326
if (!string.IsNullOrEmpty(accentName) && accentName != ThemeManager.DetectAppStyle().Item2.Name)
2427
ChangeAccent(accentName);
28+
29+
MetroDialog.CustomResourceDictionary = new ResourceDictionary
30+
{
31+
Source = new Uri("NETworkManager;component/Resources/Styles/MetroDialogStyles.xaml", UriKind.RelativeOrAbsolute)
32+
};
2533
}
2634

2735
/// <summary>

Source/NETworkManager/Models/Settings/AutostartManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void Enable()
3232
{
3333
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(RunKeyCurrentUser, true);
3434

35-
string command = string.Format("{0} {1}", ConfigurationManager.Current.ApplicationFullName, CommandLineManager.GetCommandLineParameter(CommandLineManager.ParameterAutostart));
35+
string command = string.Format("{0} {1}", ConfigurationManager.Current.ApplicationFullName, CommandLineManager.ParameterAutostart);
3636

3737
registryKey.SetValue(ConfigurationManager.Current.ApplicationName, command);
3838
registryKey.Close();

Source/NETworkManager/Models/Settings/CommandLineInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class CommandLineInfo
66
public bool Autostart { get; set; }
77
public bool ResetSettings { get; set; }
88
public int RestartPid { get; set; }
9+
public string WrongParameter { get; set; }
910

1011
public CommandLineInfo()
1112
{
Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
using NETworkManager.Views.Settings;
2-
using System;
3-
using System.Windows;
1+
using System;
42

53
namespace NETworkManager.Models.Settings
64
{
75
public static class CommandLineManager
86
{
97
public const string ParameterIdentifier = "--";
10-
public const string ParameterHelp = "help";
11-
public const string ParameterAutostart = "autostart";
12-
public const string ParameterResetSettings = "reset-settings";
13-
public const string ParameterRestartPid = "restart-pid:";
8+
public const char ParameterSplit = ':';
9+
10+
// Public + Help
11+
public const string ParameterHelp = ParameterIdentifier + "help";
12+
public const string ParameterResetSettings = ParameterIdentifier + "reset-settings";
13+
14+
// Internal use only
15+
public const string ParameterAutostart = ParameterIdentifier + "autostart";
16+
public const string ParameterRestartPid = ParameterIdentifier + "restart-pid";
1417

1518
public static CommandLineInfo Current { get; set; }
1619

@@ -22,46 +25,58 @@ public static void Parse()
2225
{
2326
Current = new CommandLineInfo();
2427

25-
// Get the command line args
28+
// Detect start parameters
2629
string[] parameters = Environment.GetCommandLineArgs();
2730

28-
char[] trimChars = ParameterIdentifier.ToCharArray();
29-
30-
// Detect start parameters
31-
foreach (string parameter in parameters)
31+
for (int i = 0; i < parameters.Length; i++)
3232
{
33-
if (parameter.StartsWith(ParameterIdentifier))
33+
string[] param = parameters[i].Split(ParameterSplit);
34+
35+
if (param[0].StartsWith(ParameterIdentifier))
3436
{
35-
string param = parameter.TrimStart(trimChars);
36-
if (param.Equals(ParameterHelp, StringComparison.InvariantCultureIgnoreCase))
37+
if (param[0].Equals(ParameterHelp, StringComparison.InvariantCultureIgnoreCase))
3738
{
3839
Current.Help = true;
3940
}// Autostart
40-
else if(param.Equals(ParameterAutostart, StringComparison.InvariantCultureIgnoreCase))
41+
else if (param[0].Equals(ParameterAutostart, StringComparison.InvariantCultureIgnoreCase))
4142
{
4243
Current.Autostart = true;
4344
} // Reset Settings
44-
else if (param.Equals(ParameterResetSettings, StringComparison.InvariantCultureIgnoreCase))
45+
else if (param[0].Equals(ParameterResetSettings, StringComparison.InvariantCultureIgnoreCase))
4546
{
4647
Current.ResetSettings = true;
4748
} // Restart
48-
else if (param.StartsWith(ParameterRestartPid, StringComparison.InvariantCultureIgnoreCase))
49+
else if (param[0].Equals(ParameterRestartPid, StringComparison.InvariantCultureIgnoreCase))
4950
{
50-
int.TryParse(param.Split(':')[1], out int restartPid);
51+
int.TryParse(param[1], out int restartPid);
5152

5253
Current.RestartPid = restartPid;
5354
}
5455
else
5556
{
57+
AddToWrongParameter(parameters[i]);
58+
59+
Current.Help = true;
60+
}
61+
}
62+
else
63+
{
64+
// Ignore the first parameter because it's the path of the .exe
65+
if (i != 0)
66+
{
67+
AddToWrongParameter(parameters[i]);
5668
Current.Help = true;
5769
}
5870
}
5971
}
6072
}
6173

62-
public static string GetCommandLineParameter(string parameter)
74+
private static void AddToWrongParameter(string parameter)
6375
{
64-
return string.Format("{0}{1}", ParameterIdentifier, parameter);
76+
if (!string.IsNullOrEmpty(Current.WrongParameter))
77+
Current.WrongParameter += Environment.NewLine;
78+
79+
Current.WrongParameter += parameter;
6580
}
6681
}
6782
}

Source/NETworkManager/NETworkManager.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
<Compile Include="Validators\IPAddressValidator.cs" />
173173
<Compile Include="Validators\OpacityTextboxValidator.cs" />
174174
<Compile Include="ViewModels\Applications\DNSLookupViewModel.cs" />
175+
<Compile Include="ViewModels\Help\HelpCommandLineViewModel.cs" />
175176
<Compile Include="ViewModels\Settings\SettingsApplicationDNSLookupViewModel.cs" />
176177
<Compile Include="ViewModels\Settings\SettingsApplicationWakeOnLANViewModel.cs" />
177178
<Compile Include="Views\Settings\SettingsApplicationDNSLookupView.xaml.cs">
@@ -644,9 +645,6 @@
644645
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
645646
</EmbeddedResource>
646647
</ItemGroup>
647-
<ItemGroup>
648-
<Resource Include="Resources\WindowsIcons-license.txt" />
649-
</ItemGroup>
650648
<ItemGroup>
651649
<Resource Include="Resources\Entypo.ttf" />
652650
<None Include="Resources\oui.txt">
@@ -658,13 +656,16 @@
658656
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
659657
</None>
660658
</ItemGroup>
661-
<ItemGroup>
662-
<Resource Include="Resources\Entypo-license.txt" />
663-
</ItemGroup>
664659
<ItemGroup>
665660
<Resource Include="3rdParty\Heijden.DNS\Records\totla.txt" />
666661
<Resource Include="3rdParty\Heijden.DNS\Root\named_root.txt" />
667662
</ItemGroup>
663+
<ItemGroup>
664+
<Resource Include="Resources\WindowsIcons-license.txt" />
665+
</ItemGroup>
666+
<ItemGroup>
667+
<Resource Include="Resources\Entypo-license.txt" />
668+
</ItemGroup>
668669
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
669670
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
670671
Other similar extension points exist, see Microsoft.Common.targets.

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<system:String x:Key="String_Header_HotKeys">HotKeys</system:String>
4444
<system:String x:Key="String_Header_DNSLookup">DNS Lookup</system:String>
4545
<system:String x:Key="String_Header_Route">Route</system:String>
46-
<system:String x:Key="String_Header_MaximumHopsReached">Maximale Hops erreicht</system:String>
4746
<system:String x:Key="String_Header_CanceledByUser">Vom Benutzer abgebrochen</system:String>
4847
<system:String x:Key="String_Header_DontFragment">Nicht fragmentieren</system:String>
4948
<system:String x:Key="String_Header_Import">Importieren</system:String>
@@ -64,8 +63,9 @@
6463
<system:String x:Key="String_Header_Update">Update</system:String>
6564
<system:String x:Key="String_Header_Transparency">Transparenz</system:String>
6665
<system:String x:Key="String_Header_WakeOnLAN">Wake on LAN</system:String>
67-
<system:String x:Key="String_Header_HelpCommandLine">Hilfe - Kommandozeile</system:String>
68-
66+
<system:String x:Key="String_Header_CommandLineArguments">Befehlszeilenargumente</system:String>
67+
<system:String x:Key="String_Header_WrongParameter">Falscher Parameter</system:String>
68+
6969
<!-- Normal strings -->
7070
<system:String x:Key="String_ProductName">NETworkManager</system:String>
7171
<system:String x:Key="String_ShowWindow">Fenster anzeigen</system:String>
@@ -174,8 +174,8 @@
174174
<system:String x:Key="String_ConfirmClose">Schließen bestätigen</system:String>
175175
<system:String x:Key="String_ConfirmCloseQuesiton">Sind Sie sicher, dass Sie die Anwendung beenden möchten?</system:String>
176176
<system:String x:Key="String_UntrayBringWindowToFront">Untray / Fenster in den Vordergrund bringen</system:String>
177-
<system:String x:Key="String_MaximumHopsReachedMessage">Traceroute wurde nach {0} Hops abgebrochen.</system:String>
178-
<system:String x:Key="String_CanceledByUserMessage">Der Vorgang wurde vom Benutzer abgebrochen!</system:String>
177+
<system:String x:Key="String_MaximumNumberOfHopsReached">Maximale Anzahl ({0}) an Hops/Router erreicht! </system:String>
178+
<system:String x:Key="String_CanceledByUser">Der Vorgang wurde vom Benutzer abgebrochen!</system:String>
179179
<system:String x:Key="String_NetworkInterfaceConfigTemplates">Netzwerkinterface Konfigurations Templates</system:String>
180180
<system:String x:Key="String_WakeOnLANTemplates">Wake on LAN Templates</system:String>
181181
<system:String x:Key="String_SelectedSettingsAreReset">Die ausgewählten Einstellungen werden zurückgesetzt. (Der Speicherpfad ist hiervon nicht betroffen.)</system:String>
@@ -221,7 +221,10 @@
221221
<system:String x:Key="String_NothingToDoCheckYourInput">Nichts zu tun. Überprüfen Sie Ihre Eingabe!</system:String>
222222
<system:String x:Key="String_Scanned">Gescannt</system:String>
223223
<system:String x:Key="String_Found">Found</system:String>
224-
224+
<system:String x:Key="String_TheApplicationCanBeStartedWithoutParameters">Die Anwendung kann ohne Parameter gestartet werden!</system:String>
225+
<system:String x:Key="String_TheFollwingParametersCanNotBeProcesses">Die folgenden Parameter können nicht verarbeitet werden:</system:String>
226+
<system:String x:Key="String_TheFollowingParametersAreAvailable">Folgende Parameter stehen zur Verfügung:</system:String>
227+
225228
<!-- Buttons -->
226229
<system:String x:Key="String_Button_Change">Wechseln</system:String>
227230
<system:String x:Key="String_Button_Default">Standard</system:String>
@@ -247,6 +250,10 @@
247250
<system:String x:Key="String_Button_Reset">Zurücksetzen</system:String>
248251
<system:String x:Key="String_Button_Continue">Weiter</system:String>
249252
<system:String x:Key="String_Button_Validate">Validieren</system:String>
253+
254+
<!-- Help -->
255+
<system:String x:Key="String_Help_ParameterHelp">Zeigt diesen Dialog an.</system:String>
256+
<system:String x:Key="String_Help_ParameterResetSettings">Setzt alle Einstellungen zurück.</system:String>
250257

251258
<!-- ContextMenuItem.Header -->
252259
<system:String x:Key="String_ContextMenu_Cut">Ausschneiden</system:String>

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
<system:String x:Key="String_Header_HotKeys">HotKeys</system:String>
4545
<system:String x:Key="String_Header_DNSLookup">DNS Lookup</system:String>
4646
<system:String x:Key="String_Header_Route">Route</system:String>
47-
<system:String x:Key="String_Header_MaximumHopsReached">Maximum hops reached</system:String>
4847
<system:String x:Key="String_Header_CanceledByUser">Canceled by user</system:String>
4948
<system:String x:Key="String_Header_DontFragment">Don't fragment</system:String>
5049
<system:String x:Key="String_Header_Import">Import</system:String>
@@ -65,8 +64,9 @@
6564
<system:String x:Key="String_Header_Update">Update</system:String>
6665
<system:String x:Key="String_Header_Transparency">Transparency</system:String>
6766
<system:String x:Key="String_Header_WakeOnLAN">Wake on LAN</system:String>
68-
<system:String x:Key="String_Header_HelpCommandLine">Help - Command Line</system:String>
69-
67+
<system:String x:Key="String_Header_CommandLineArguments">Command Line Arguments</system:String>
68+
<system:String x:Key="String_Header_WrongParameter">Wrong parameter</system:String>
69+
7070
<!-- Normal strings -->
7171
<system:String x:Key="String_ProductName">NETworkManager</system:String>
7272
<system:String x:Key="String_ShowWindow">Show window</system:String>
@@ -175,8 +175,8 @@
175175
<system:String x:Key="String_ConfirmClose">Confirm close</system:String>
176176
<system:String x:Key="String_ConfirmCloseQuesiton">Are you sure you want to close the application?</system:String>
177177
<system:String x:Key="String_UntrayBringWindowToFront">Untray / Bring window to front</system:String>
178-
<system:String x:Key="String_MaximumHopsReachedMessage">Traceroute was canceled after {0} hops.</system:String>
179-
<system:String x:Key="String_CanceledByUserMessage">The operation has been canceled by the user!</system:String>
178+
<system:String x:Key="String_MaximumNumberOfHopsReached">Maximum number ({0}) of hops/router reached!</system:String>
179+
<system:String x:Key="String_CanceledByUser">The operation has been canceled by the user!</system:String>
180180
<system:String x:Key="String_ApplicationSettings">Application settings</system:String>
181181
<system:String x:Key="String_NetworkInterfaceConfigTemplates">Network Interface config templates</system:String>
182182
<system:String x:Key="String_WakeOnLANTemplates">Wake on LAN templates</system:String>
@@ -223,7 +223,10 @@
223223
<system:String x:Key="String_NothingToDoCheckYourInput">Nothing to do. Check your input!</system:String>
224224
<system:String x:Key="String_Scanned">Scanned</system:String>
225225
<system:String x:Key="String_Found">Found</system:String>
226-
226+
<system:String x:Key="String_TheApplicationCanBeStartedWithoutParameters">The application can be started without parameters!</system:String>
227+
<system:String x:Key="String_TheFollwingParametersCanNotBeProcesses">The following parameters can not be processed:</system:String>
228+
<system:String x:Key="String_TheFollowingParametersAreAvailable">The following parameters are available:</system:String>
229+
227230
<!-- Buttons -->
228231
<system:String x:Key="String_Button_Change">Change</system:String>
229232
<system:String x:Key="String_Button_Default">Default</system:String>
@@ -249,7 +252,11 @@
249252
<system:String x:Key="String_Button_Continue">Continue</system:String>
250253
<system:String x:Key="String_Button_Validate">Validate</system:String>
251254
<system:String x:Key="String_Button_Lookup">Lookup</system:String>
252-
255+
256+
<!-- Help -->
257+
<system:String x:Key="String_Help_ParameterHelp">Displays this dialog.</system:String>
258+
<system:String x:Key="String_Help_ParameterResetSettings">Reset all settings.</system:String>
259+
253260
<!-- ContextMenuItem.Header -->
254261
<system:String x:Key="String_ContextMenu_Cut">Cut</system:String>
255262
<system:String x:Key="String_ContextMenu_Copy">Copy</system:String>

0 commit comments

Comments
 (0)