Skip to content

Commit 084d503

Browse files
BornToBeRootclaude
andcommitted
Feature: Run command dialog with arguments, profiles and suggestions
- The run command (Ctrl+Shift+P) opens a dialog instead of the flyout: type e.g. "ping 10.0.0.1", "dns borntoberoot.net 1.1.1.1 aaaa" or "rdp @server01" and press Enter. Esc closes the dialog. - Suggestions: recent commands, applications (with aliases like ping, dns, rdp, ssh), profiles of the application (@name) and type values. Up/Down select, Tab completes, Enter runs the selection (the input as typed is preselected). - The target is validated with the validators of the application's input fields before the application is opened. - Only visible applications are offered. - Run command history (setting RunCommand_History). - Removed the flyout and the unused RunCommandComboBox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f7d89fb commit 084d503

11 files changed

Lines changed: 1156 additions & 335 deletions

File tree

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

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

‎Source/NETworkManager.Localization/Resources/Strings.resx‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4857,4 +4857,34 @@ Cloudflare may log your IP address and network information. See Cloudflare's pri
48574857
<data name="Resource_PublicSuffixList_Description" xml:space="preserve">
48584858
<value>List of public suffixes (e.g. "co.uk") from publicsuffix.org (MPL-2.0), which is used to get the registered domain of a hostname for RDAP queries.</value>
48594859
</data>
4860+
<data name="ProfileXNotFound" xml:space="preserve">
4861+
<value>Profile "{0}" not found!</value>
4862+
</data>
4863+
<data name="SeveralProfilesAreNamedXSelectOne" xml:space="preserve">
4864+
<value>Several profiles are named "{0}", select one!</value>
4865+
</data>
4866+
<data name="EnterACommand" xml:space="preserve">
4867+
<value>Enter a command!</value>
4868+
</data>
4869+
<data name="UnknownCommandX" xml:space="preserve">
4870+
<value>Unknown command "{0}"!</value>
4871+
</data>
4872+
<data name="CommandXDoesNotAcceptArguments" xml:space="preserve">
4873+
<value>The command "{0}" does not accept arguments!</value>
4874+
</data>
4875+
<data name="CommandXDoesNotSupportProfiles" xml:space="preserve">
4876+
<value>The command "{0}" does not support profiles!</value>
4877+
</data>
4878+
<data name="EnterTheNameOfAProfileAfterAt" xml:space="preserve">
4879+
<value>Enter the name of a profile after "@"!</value>
4880+
</data>
4881+
<data name="UnknownArgumentX" xml:space="preserve">
4882+
<value>Unknown argument "{0}"!</value>
4883+
</data>
4884+
<data name="RunCommand" xml:space="preserve">
4885+
<value>Run command</value>
4886+
</data>
4887+
<data name="Recent" xml:space="preserve">
4888+
<value>Recent</value>
4889+
</data>
48604890
</root>

‎Source/NETworkManager.Profiles/ProfileInfo.cs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//using System.Collections.Generic;
22
using NETworkManager.Controls;
3+
using NETworkManager.Models;
34
using NETworkManager.Models.Network;
45
using NETworkManager.Models.PowerShell;
56
using NETworkManager.Models.PuTTY;
@@ -504,4 +505,33 @@ public ProfileInfo(ProfileInfo profile)
504505
public bool IPGeolocation_Enabled { get; set; }
505506
public bool IPGeolocation_InheritHost { get; set; } = true;
506507
public string IPGeolocation_Host { get; set; }
508+
509+
/// <summary>
510+
/// Checks if the profile is enabled for an application.
511+
/// </summary>
512+
/// <param name="application">Application to check.</param>
513+
/// <returns>True if the profile is enabled for the application.</returns>
514+
public bool IsEnabled(ApplicationName application)
515+
{
516+
return application switch
517+
{
518+
ApplicationName.NetworkInterface => NetworkInterface_Enabled,
519+
ApplicationName.IPScanner => IPScanner_Enabled,
520+
ApplicationName.PortScanner => PortScanner_Enabled,
521+
ApplicationName.PingMonitor => PingMonitor_Enabled,
522+
ApplicationName.Traceroute => Traceroute_Enabled,
523+
ApplicationName.DNSLookup => DNSLookup_Enabled,
524+
ApplicationName.RemoteDesktop => RemoteDesktop_Enabled,
525+
ApplicationName.PowerShell => PowerShell_Enabled,
526+
ApplicationName.PuTTY => PuTTY_Enabled,
527+
ApplicationName.TigerVNC => TigerVNC_Enabled,
528+
ApplicationName.WebConsole => WebConsole_Enabled,
529+
ApplicationName.SNMP => SNMP_Enabled,
530+
ApplicationName.WakeOnLAN => WakeOnLAN_Enabled,
531+
ApplicationName.RDAP => RDAP_Enabled,
532+
ApplicationName.Whois => Whois_Enabled,
533+
ApplicationName.IPGeolocation => IPGeolocation_Enabled,
534+
_ => false
535+
};
536+
}
507537
}

‎Source/NETworkManager.Settings/SettingsInfo.cs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,22 @@ public bool ExpandApplicationView
808808
}
809809
}
810810

811+
// Run command
812+
813+
public ObservableCollection<string> RunCommand_History
814+
{
815+
get;
816+
set
817+
{
818+
if (value == field)
819+
return;
820+
821+
UpdateCollectionChanged(field, value);
822+
field = value;
823+
OnPropertyChanged();
824+
}
825+
} = [];
826+
811827
#endregion
812828

813829
#region Dashboard
@@ -4056,6 +4072,9 @@ public SettingsInfo()
40564072
// General
40574073
General_ApplicationList.CollectionChanged += CollectionChanged;
40584074

4075+
// Run command
4076+
RunCommand_History.CollectionChanged += CollectionChanged;
4077+
40594078
// Network
40604079
Network_CustomDNSServers.CollectionChanged += CollectionChanged;
40614080

‎Source/NETworkManager/MainWindow.xaml‎

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
<mah:MetroWindow.RightWindowCommands>
9191
<mah:WindowCommands ShowSeparators="False" IsEnabled="{Binding Source={x:Static Member=settings:ConfigurationManager.Current}, Path=IsChildWindowOpen, Converter={StaticResource ResourceKey=BooleanReverseConverter}}">
9292
<Button Command="{Binding Path=OpenRunCommand}"
93-
Visibility="{Binding Path=FlyoutRunCommandIsOpen, Converter={StaticResource ResourceKey=BooleanReverseToVisibilityCollapsedConverter}}"
9493
ToolTip="{x:Static Member=localization:Strings.RunCommandDotsWithHotKey}"
9594
Cursor="Hand"
9695
Focusable="False">
@@ -265,112 +264,6 @@
265264
</Button>
266265
</mah:WindowCommands>
267266
</mah:MetroWindow.RightWindowCommands>
268-
<mah:MetroWindow.Flyouts>
269-
<mah:FlyoutsControl>
270-
<mah:Flyout IsKeyboardFocusWithinChanged="FlyoutRunCommand_IsKeyboardFocusWithinChanged"
271-
IsOpen="{Binding FlyoutRunCommandIsOpen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
272-
AreAnimationsEnabled="False"
273-
Visibility="{Binding FlyoutRunCommandIsOpen, Converter={StaticResource BooleanToVisibilityConverter}}"
274-
Position="Top"
275-
TitleVisibility="Collapsed"
276-
CloseButtonVisibility="Collapsed"
277-
IsModal="False"
278-
Width="600" MaxHeight="400"
279-
BorderBrush="{DynamicResource MahApps.Brushes.Gray8}"
280-
BorderThickness="1"
281-
Theme="Adapt">
282-
<mah:Flyout.InputBindings>
283-
<KeyBinding Command="{Binding RunCommandCloseCommand}" Key="Escape" />
284-
<KeyBinding Command="{Binding RunCommandDoCommand}" Key="Enter" />
285-
</mah:Flyout.InputBindings>
286-
<Grid Margin="10">
287-
<Grid.RowDefinitions>
288-
<RowDefinition Height="Auto" />
289-
<RowDefinition Height="10" />
290-
<RowDefinition Height="*" />
291-
</Grid.RowDefinitions>
292-
<Grid Grid.Column="0" Grid.Row="0">
293-
<Grid.ColumnDefinitions>
294-
<ColumnDefinition Width="Auto" />
295-
<ColumnDefinition Width="*" />
296-
</Grid.ColumnDefinitions>
297-
<Rectangle Grid.Column="0" Grid.Row="0"
298-
Margin="5,0"
299-
Width="20" Height="20"
300-
HorizontalAlignment="Right"
301-
Fill="{DynamicResource MahApps.Brushes.Gray8}">
302-
<Rectangle.OpacityMask>
303-
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=ChevronRight}" />
304-
</Rectangle.OpacityMask>
305-
</Rectangle>
306-
<TextBox Grid.Column="1" Grid.Row="0"
307-
FontSize="18"
308-
FontFamily="Consolas"
309-
Text="{Binding RunCommandSearch, UpdateSourceTrigger=PropertyChanged}"
310-
mah:TextBoxHelper.Watermark="{x:Static localization:Strings.RunCommandDots}">
311-
<TextBox.Style>
312-
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource DefaultTextBox}">
313-
<Setter Property="mah:TextBoxHelper.ClearTextButton" Value="True" />
314-
<Setter Property="BorderThickness" Value="0,0,0,1" />
315-
</Style>
316-
</TextBox.Style>
317-
</TextBox>
318-
</Grid>
319-
<ListView Grid.Column="0" Grid.Row="2"
320-
ItemsSource="{Binding RunCommands}"
321-
SelectedItem="{Binding SelectedRunCommand, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
322-
SelectionMode="Single"
323-
PreviewMouseLeftButtonUp="ListViewRunCommand_OnPreviewMouseLeftButtonUp"
324-
Style="{StaticResource DefaultListBox}">
325-
<ListView.ItemTemplate>
326-
<DataTemplate DataType="{x:Type networkManager:RunCommandInfo}">
327-
<Border BorderThickness="1">
328-
<Grid Margin="5">
329-
<Grid.ColumnDefinitions>
330-
<ColumnDefinition Width="*" />
331-
</Grid.ColumnDefinitions>
332-
<Grid.RowDefinitions>
333-
<RowDefinition Height="Auto" />
334-
<RowDefinition Height="Auto" />
335-
</Grid.RowDefinitions>
336-
<TextBlock Grid.Column="0" Grid.Row="0"
337-
Text="{Binding TranslatedName}"
338-
Style="{StaticResource BoldTextBlock}" />
339-
<TextBlock Grid.Column="0" Grid.Row="1"
340-
Style="{StaticResource AccentTextBlock}"
341-
FontFamily="Consolas"
342-
Margin="0,5,0,0">
343-
<TextBlock.Text>
344-
<MultiBinding StringFormat="{}{0} {1}">
345-
<Binding Path="Command" />
346-
<Binding Path="ExampleArguments" />
347-
</MultiBinding>
348-
</TextBlock.Text>
349-
</TextBlock>
350-
</Grid>
351-
</Border>
352-
</DataTemplate>
353-
</ListView.ItemTemplate>
354-
</ListView>
355-
<TextBlock Grid.Column="0" Grid.Row="2" Margin="32,0,0,0">
356-
<TextBlock.Style>
357-
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource DefaultTextBlock}">
358-
<Setter Property="Visibility" Value="Collapsed" />
359-
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Gray3}" />
360-
<Style.Triggers>
361-
<DataTrigger Binding="{Binding RunCommands.Count}" Value="0">
362-
<Setter Property="Visibility" Value="Visible" />
363-
<Setter Property="Text"
364-
Value="{x:Static localization:Strings.NoMatchingCommands}" />
365-
</DataTrigger>
366-
</Style.Triggers>
367-
</Style>
368-
</TextBlock.Style>
369-
</TextBlock>
370-
</Grid>
371-
</mah:Flyout>
372-
</mah:FlyoutsControl>
373-
</mah:MetroWindow.Flyouts>
374267
<Grid>
375268
<Grid>
376269
<Grid.Style>

0 commit comments

Comments
 (0)