Skip to content

Commit e60aed9

Browse files
authored
Merge pull request #193 from BornToBeRoot/issue-191
Add custom command to ip scanner
2 parents b412b3d + 234e207 commit e60aed9

22 files changed

+900
-77
lines changed

Source/NETworkManager/Converters/ListToStringConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public sealed class ListToStringConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{
12-
return value == null ? string.Empty : string.Join(", ", (List<string>)value);
12+
return value == null ? string.Empty : string.Join("; ", (List<string>)value);
1313

1414
}
1515

Source/NETworkManager/Models/Settings/SettingsInfo.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,21 @@ public int IPScanner_ICMPTimeout
752752
}
753753
}
754754

755+
private ObservableCollection<CustomCommandInfo> _ipScanner_CustomCommands = new ObservableCollection<CustomCommandInfo>();
756+
public ObservableCollection<CustomCommandInfo> IPScanner_CustomCommands
757+
{
758+
get => _ipScanner_CustomCommands;
759+
set
760+
{
761+
if (value == _ipScanner_CustomCommands)
762+
return;
763+
764+
_ipScanner_CustomCommands = value;
765+
OnPropertyChanged();
766+
SettingsChanged = true;
767+
}
768+
}
769+
755770
private bool _ipScanner_ExpandStatistics = true;
756771
public bool IPScanner_ExpandStatistics
757772
{
@@ -3654,6 +3669,7 @@ public SettingsInfo()
36543669

36553670
// IP Scanner
36563671
IPScanner_HostHistory.CollectionChanged += CollectionChanged;
3672+
IPScanner_CustomCommands.CollectionChanged += CollectionChanged;
36573673

36583674
// Port Scanner
36593675
PortScanner_HostHistory.CollectionChanged += CollectionChanged;

Source/NETworkManager/NETworkManager.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@
312312
<Compile Include="StatusWindow.xaml.cs">
313313
<DependentUpon>StatusWindow.xaml</DependentUpon>
314314
</Compile>
315+
<Compile Include="Utilities\CustomCommand.cs" />
316+
<Compile Include="Utilities\CustomCommandInfo.cs" />
315317
<Compile Include="Utilities\CommonMethods.cs" />
316318
<Compile Include="Utilities\ArrayHelper.cs" />
317319
<Compile Include="Utilities\AutoRefreshTime.cs" />
@@ -359,6 +361,7 @@
359361
<Compile Include="Validators\MultipleIPAddressesValidator.cs" />
360362
<Compile Include="Validators\HttpAndHttpsUriValidator.cs" />
361363
<Compile Include="Validators\IPv4IPv6SubnetValidator.cs" />
364+
<Compile Include="ViewModels\CustomCommandViewModel.cs" />
362365
<Compile Include="ViewModels\FirstRunViewModel.cs" />
363366
<Compile Include="Models\Settings\IProfileManager.cs" />
364367
<Compile Include="ViewModels\NetworkInterfaceAddIPAddressViewModel.cs" />
@@ -426,6 +429,9 @@
426429
<DependentUpon>RemoteDesktopControl.xaml</DependentUpon>
427430
</Compile>
428431
<Compile Include="ViewModels\SettingsUpdateViewModel.cs" />
432+
<Compile Include="Views\CustomCommandDialog.xaml.cs">
433+
<DependentUpon>CustomCommandDialog.xaml</DependentUpon>
434+
</Compile>
429435
<Compile Include="Views\FirstRunDialog.xaml.cs">
430436
<DependentUpon>FirstRunDialog.xaml</DependentUpon>
431437
</Compile>
@@ -758,6 +764,10 @@
758764
<SubType>Designer</SubType>
759765
<Generator>MSBuild:Compile</Generator>
760766
</Page>
767+
<Page Include="Views\CustomCommandDialog.xaml">
768+
<Generator>MSBuild:Compile</Generator>
769+
<SubType>Designer</SubType>
770+
</Page>
761771
<Page Include="Views\FirstRunDialog.xaml">
762772
<Generator>MSBuild:Compile</Generator>
763773
<SubType>Designer</SubType>

Source/NETworkManager/Resources/Localization/StaticStrings.Designer.cs

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/NETworkManager/Resources/Localization/StaticStrings.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,13 @@
276276
<data name="ExamplePublicIPAddressAPI" xml:space="preserve">
277277
<value>https://api.ipify.org</value>
278278
</data>
279+
<data name="IExploreExe" xml:space="preserve">
280+
<value>iexplore.exe</value>
281+
</data>
282+
<data name="ExampleCustomCommandVariableHostname" xml:space="preserve">
283+
<value>https://$$HOSTNAME$$/</value>
284+
</data>
285+
<data name="InternetExplorer" xml:space="preserve">
286+
<value>Internet Explorer</value>
287+
</data>
279288
</root>

Source/NETworkManager/Resources/Localization/Strings.Designer.cs

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/NETworkManager/Resources/Localization/Strings.resx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,4 +2274,31 @@ is disabled!</value>
22742274
<data name="Gateway" xml:space="preserve">
22752275
<value>Gateway</value>
22762276
</data>
2277+
<data name="CustomCommands" xml:space="preserve">
2278+
<value>Custom commands</value>
2279+
</data>
2280+
<data name="AddCustomCommand" xml:space="preserve">
2281+
<value>Add custom command</value>
2282+
</data>
2283+
<data name="Arguments" xml:space="preserve">
2284+
<value>Arguments</value>
2285+
</data>
2286+
<data name="DeleteCustomCommand" xml:space="preserve">
2287+
<value>Delete custom command</value>
2288+
</data>
2289+
<data name="EditCustomCommand" xml:space="preserve">
2290+
<value>Edit custom command</value>
2291+
</data>
2292+
<data name="Program" xml:space="preserve">
2293+
<value>Program</value>
2294+
</data>
2295+
<data name="DeleteCustomCommandMessage" xml:space="preserve">
2296+
<value>The selected custom command will be deleted permanently.</value>
2297+
</data>
2298+
<data name="HelpMessage_CustomCommandVariables" xml:space="preserve">
2299+
<value>The following variables are available:
2300+
2301+
$$ipaddress$$ --&gt; IP adresse
2302+
$$hostname$$ --&gt; Hostname</value>
2303+
</data>
22772304
</root>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.Windows;
4+
5+
namespace NETworkManager.Utilities
6+
{
7+
public static class CustomCommand
8+
{
9+
public static void Run(CustomCommandInfo info)
10+
{
11+
try
12+
{
13+
if (string.IsNullOrEmpty(info.Arguments))
14+
Process.Start(info.FilePath);
15+
else
16+
Process.Start(info.FilePath, info.Arguments);
17+
}
18+
catch (Exception ex)
19+
{
20+
MessageBox.Show(ex.Message, "Error in Utilities.CustomCommand.Run()", MessageBoxButton.OK, MessageBoxImage.Error);
21+
}
22+
}
23+
}
24+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace NETworkManager.Utilities
4+
{
5+
public class CustomCommandInfo : ICloneable
6+
{
7+
public Guid ID { get; set; }
8+
9+
public string Name { get; set; }
10+
public string FilePath { get; set; }
11+
public string Arguments { get; set; }
12+
13+
public CustomCommandInfo()
14+
{
15+
ID = Guid.NewGuid();
16+
}
17+
18+
public CustomCommandInfo(Guid id,string name, string filePath)
19+
{
20+
ID = id;
21+
Name = name;
22+
FilePath = filePath;
23+
}
24+
25+
public CustomCommandInfo(Guid id, string name, string filePath, string arguments) : this(id, name, filePath)
26+
{
27+
Arguments = arguments;
28+
}
29+
30+
public object Clone()
31+
{
32+
return MemberwiseClone();
33+
}
34+
}
35+
}

Source/NETworkManager/ViewModels/CredentialViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public CredentialViewModel(Action<CredentialViewModel> saveCommand, Action<Crede
138138

139139
_isEdited = isEdited;
140140

141+
// Create new --> GUID
141142
_credentialInfo = credentialInfo ?? new CredentialInfo();
142143

143144
Id = _credentialInfo.ID;

0 commit comments

Comments
 (0)