Skip to content

Commit 234e207

Browse files
committed
Add tooltip, refactor
1 parent 3e38697 commit 234e207

File tree

4 files changed

+54
-21
lines changed

4 files changed

+54
-21
lines changed

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

Lines changed: 12 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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,4 +2295,10 @@ is disabled!</value>
22952295
<data name="DeleteCustomCommandMessage" xml:space="preserve">
22962296
<value>The selected custom command will be deleted permanently.</value>
22972297
</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>
22982304
</root>

Source/NETworkManager/ViewModels/IPScannerViewModel.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -372,28 +372,9 @@ private void PerformDNSLookupHostnameAction()
372372

373373
private void CustomCommandAction(object guid)
374374
{
375-
Debug.WriteLine(guid.ToString());
376-
377-
if (guid is Guid id)
378-
{
379-
CustomCommandInfo info = (CustomCommandInfo)CustomCommands.FirstOrDefault(x => x.ID == id).Clone();
380-
381-
if (info == null)
382-
return; // ToDo: Log and error message
383-
384-
// Replace vars
385-
string hostname = !string.IsNullOrEmpty(SelectedHostResult.Hostname) ? SelectedHostResult.Hostname.TrimEnd('.') : "";
386-
string ipAddress = SelectedHostResult.PingInfo.IPAddress.ToString();
387-
388-
info.FilePath = Regex.Replace(info.FilePath, "\\$\\$hostname\\$\\$", hostname, RegexOptions.IgnoreCase);
389-
info.FilePath = Regex.Replace(info.FilePath, "\\$\\$ipaddress\\$\\$", ipAddress , RegexOptions.IgnoreCase);
390-
info.Arguments = Regex.Replace(info.Arguments, "\\$\\$hostname\\$\\$", hostname, RegexOptions.IgnoreCase);
391-
info.Arguments = Regex.Replace(info.Arguments, "\\$\\$ipaddress\\$\\$", ipAddress, RegexOptions.IgnoreCase);
392-
393-
CustomCommand.Run(info);
394-
}
375+
CustomCommand(guid);
395376
}
396-
377+
397378
public ICommand AddProfileSelectedHostCommand => new RelayCommand(p => AddProfileSelectedHostAction());
398379
private async void AddProfileSelectedHostAction()
399380
{
@@ -609,6 +590,28 @@ private void ScanFinished()
609590
IsScanRunning = false;
610591
}
611592

593+
private void CustomCommand(object guid)
594+
{
595+
if (guid is Guid id)
596+
{
597+
CustomCommandInfo info = (CustomCommandInfo)CustomCommands.FirstOrDefault(x => x.ID == id).Clone();
598+
599+
if (info == null)
600+
return; // ToDo: Log and error message
601+
602+
// Replace vars
603+
string hostname = !string.IsNullOrEmpty(SelectedHostResult.Hostname) ? SelectedHostResult.Hostname.TrimEnd('.') : "";
604+
string ipAddress = SelectedHostResult.PingInfo.IPAddress.ToString();
605+
606+
info.FilePath = Regex.Replace(info.FilePath, "\\$\\$hostname\\$\\$", hostname, RegexOptions.IgnoreCase);
607+
info.FilePath = Regex.Replace(info.FilePath, "\\$\\$ipaddress\\$\\$", ipAddress, RegexOptions.IgnoreCase);
608+
info.Arguments = Regex.Replace(info.Arguments, "\\$\\$hostname\\$\\$", hostname, RegexOptions.IgnoreCase);
609+
info.Arguments = Regex.Replace(info.Arguments, "\\$\\$ipaddress\\$\\$", ipAddress, RegexOptions.IgnoreCase);
610+
611+
Utilities.CustomCommand.Run(info);
612+
}
613+
}
614+
612615
private void AddHostToHistory(string ipRange)
613616
{
614617
// Create the new list

Source/NETworkManager/Views/CustomCommandDialog.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<ColumnDefinition Width="1*" />
2424
<ColumnDefinition Width="10" />
2525
<ColumnDefinition Width="1*" />
26+
<ColumnDefinition Width="10" />
27+
<ColumnDefinition Width="24" />
2628
</Grid.ColumnDefinitions>
2729
<Grid.RowDefinitions>
2830
<RowDefinition Height="Auto" />
@@ -74,8 +76,18 @@
7476
</Binding>
7577
</TextBox.Text>
7678
</TextBox>
79+
<Rectangle Grid.Column="4" Grid.Row="2" Width="24" Height="24" VerticalAlignment="Top" ToolTip="{x:Static localization:Strings.HelpMessage_CustomCommandVariables}" Style="{StaticResource HelpImageRectangle}">
80+
<Rectangle.Resources>
81+
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource HelpToolTip}" />
82+
</Rectangle.Resources>
83+
</Rectangle>
7784
<TextBlock Grid.Column="0" Grid.Row="4" Text="{x:Static localization:Strings.Arguments}" />
7885
<TextBox x:Name="TextBoxArguments" Grid.Column="2" Grid.Row="4" Text="{Binding Arguments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" mah:TextBoxHelper.Watermark="{x:Static localization:StaticStrings.ExampleCustomCommandVariableHostname}" />
86+
<Rectangle Grid.Column="4" Grid.Row="4" Width="24" Height="24" VerticalAlignment="Top" ToolTip="{x:Static localization:Strings.HelpMessage_CustomCommandVariables}" Style="{StaticResource HelpImageRectangle}">
87+
<Rectangle.Resources>
88+
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource HelpToolTip}" />
89+
</Rectangle.Resources>
90+
</Rectangle>
7991
</Grid>
8092
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
8193
<Button Content="{x:Static localization:Strings.Cancel}" Command="{Binding CancelCommand}" IsCancel="True" Style="{StaticResource DefaultButton}" />

0 commit comments

Comments
 (0)