Numpad 1-9 hotkeys toggle Nth participant's ISO
Some checks failed
CI / build-and-test (push) Failing after 31s

Fast keyboard-driven ISO routing for operators with one hand on the keyboard during a show. Both NumPad1..9 and top-row 1..9 bind to ToggleByIndexCommand which resolves against the filtered+sorted ParticipantsView — index matches what's on screen, not the underlying storage order.

Press a digit again to toggle off. Plays nice with sort modes: LoudestFirst means '1' is always whoever's loudest right now; Alphabetical lets you build muscle memory for recurring guests.

Implementation:

- New generic RelayCommand<T> in RelayCommand.cs so XAML CommandParameter strings convert to the action's T (int / string / etc.).

- ToggleByIndexCommand on MainViewModel iterates ParticipantsView, finds the Nth ParticipantViewModel, fires its ToggleIsoCommand if CanExecute.

- 18 KeyBindings (9 NumPad + 9 D1-D9) in MainWindow.xaml's Window.InputBindings.

- F1 help cheat sheet updated to mention the new range.
This commit is contained in:
Zac Gaetano 2026-05-10 21:26:37 -04:00
parent 10a0826fb3
commit 9db0875f9e
4 changed files with 88 additions and 2 deletions

View file

@ -120,12 +120,19 @@
Text="Ctrl + R"
Style="{StaticResource Wd.Text.Mono}"
Foreground="{DynamicResource Wd.Accent.Cyan}"
Margin="0,0,16,0"/>
Margin="0,0,16,6"/>
<TextBlock Grid.Row="3" Grid.Column="1"
Text="Refresh NDI discovery (rebuild finder)"
Style="{StaticResource Wd.Text.Body}"
FontSize="12"/>
FontSize="12"
Margin="0,0,0,6"/>
</Grid>
<TextBlock Margin="0,12,0,0"
Style="{StaticResource Wd.Text.Body}"
FontSize="12"
Foreground="{DynamicResource Wd.Text.Secondary}"
TextWrapping="Wrap"
Text="Numpad 1-9 (or top-row 1-9) toggles the Nth visible participant's ISO. Sort + filter aware — the index matches what you see in the DataGrid, not the underlying storage order."/>
</StackPanel>
</Border>

View file

@ -54,6 +54,26 @@
<KeyBinding Key="M" Modifiers="Ctrl" Command="{Binding DropRecordingMarkerCommand}"/>
<KeyBinding Key="S" Modifiers="Ctrl+Shift" Command="{Binding StopAllIsosCommand}"/>
<KeyBinding Key="R" Modifiers="Ctrl" Command="{Binding RefreshDiscoveryCommand}"/>
<!-- NumPad 1-9 toggles ISO for the Nth visible participant (sort + filter aware).
Top-row digits 1-9 mirror this so laptop operators without a numpad still get them. -->
<KeyBinding Key="NumPad1" Command="{Binding ToggleByIndexCommand}" CommandParameter="1"/>
<KeyBinding Key="NumPad2" Command="{Binding ToggleByIndexCommand}" CommandParameter="2"/>
<KeyBinding Key="NumPad3" Command="{Binding ToggleByIndexCommand}" CommandParameter="3"/>
<KeyBinding Key="NumPad4" Command="{Binding ToggleByIndexCommand}" CommandParameter="4"/>
<KeyBinding Key="NumPad5" Command="{Binding ToggleByIndexCommand}" CommandParameter="5"/>
<KeyBinding Key="NumPad6" Command="{Binding ToggleByIndexCommand}" CommandParameter="6"/>
<KeyBinding Key="NumPad7" Command="{Binding ToggleByIndexCommand}" CommandParameter="7"/>
<KeyBinding Key="NumPad8" Command="{Binding ToggleByIndexCommand}" CommandParameter="8"/>
<KeyBinding Key="NumPad9" Command="{Binding ToggleByIndexCommand}" CommandParameter="9"/>
<KeyBinding Key="D1" Command="{Binding ToggleByIndexCommand}" CommandParameter="1"/>
<KeyBinding Key="D2" Command="{Binding ToggleByIndexCommand}" CommandParameter="2"/>
<KeyBinding Key="D3" Command="{Binding ToggleByIndexCommand}" CommandParameter="3"/>
<KeyBinding Key="D4" Command="{Binding ToggleByIndexCommand}" CommandParameter="4"/>
<KeyBinding Key="D5" Command="{Binding ToggleByIndexCommand}" CommandParameter="5"/>
<KeyBinding Key="D6" Command="{Binding ToggleByIndexCommand}" CommandParameter="6"/>
<KeyBinding Key="D7" Command="{Binding ToggleByIndexCommand}" CommandParameter="7"/>
<KeyBinding Key="D8" Command="{Binding ToggleByIndexCommand}" CommandParameter="8"/>
<KeyBinding Key="D9" Command="{Binding ToggleByIndexCommand}" CommandParameter="9"/>
</Window.InputBindings>
<Grid>

View file

@ -181,6 +181,14 @@ public sealed class MainViewModel : ObservableObject, IDisposable
/// <summary>Save a PNG snapshot of every enabled participant's current frame.</summary>
public RelayCommand SnapshotAllCommand { get; }
/// <summary>
/// Toggle the ISO for the Nth visible participant (1-based, matches the
/// numpad layout). Used by the NumPad1..NumPad9 hotkeys; resolves
/// against ParticipantsView so the index matches what the operator
/// sees in the current sort + filter.
/// </summary>
public RelayCommand<string> ToggleByIndexCommand { get; }
/// <summary>
/// Two-way bound to the quick-join input. Whatever the operator pastes
/// gets handed to <see cref="TeamsLauncher.TryJoinMeeting"/> when the
@ -412,6 +420,25 @@ public sealed class MainViewModel : ObservableObject, IDisposable
SnapshotAllCommand = new RelayCommand(SnapshotAll, () => Participants.Any(p => p.IsEnabled));
ToggleByIndexCommand = new RelayCommand<string>(s =>
{
// Numpad / digit hotkeys pass "1".."9" as a string. Resolve
// against the filtered/sorted view so the index matches what
// the operator sees on screen, not the underlying storage order.
if (!int.TryParse(s, out var idx) || idx < 1 || idx > 9) return;
var i = 0;
foreach (var item in ParticipantsView)
{
if (item is not ParticipantViewModel p) continue;
if (++i == idx)
{
if (p.ToggleIsoCommand.CanExecute(null))
p.ToggleIsoCommand.Execute(null);
break;
}
}
});
JoinMeetingCommand = new RelayCommand(() =>
{
// Trim + handle the operator pasting whitespace around the URL.

View file

@ -23,6 +23,38 @@ public sealed class RelayCommand : ICommand
public void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// Synchronous command that accepts a typed parameter. Used by hotkeys
/// that need to pass an index (e.g. NumPad1..NumPad9 → 1..9). The
/// parameter is converted from object via Convert.ChangeType so XAML
/// CommandParameter="1" works for int T.
/// </summary>
public sealed class RelayCommand<T> : ICommand
{
private readonly Action<T> _execute;
private readonly Func<T, bool>? _canExecute;
public RelayCommand(Action<T> execute, Func<T, bool>? canExecute = null)
{
_execute = execute;
_canExecute = canExecute;
}
public bool CanExecute(object? parameter) => _canExecute?.Invoke(Convert<T>(parameter)) ?? true;
public void Execute(object? parameter) => _execute(Convert<T>(parameter));
public event EventHandler? CanExecuteChanged;
public void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
private static TValue Convert<TValue>(object? value)
{
if (value is null) return default!;
if (value is TValue typed) return typed;
try { return (TValue)System.Convert.ChangeType(value, typeof(TValue)); }
catch { return default!; }
}
}
/// <summary>
/// Async command that suppresses re-entrancy while running.
/// </summary>