Improve desktop UX and accessibility
This commit is contained in:
@@ -36,6 +36,13 @@ public partial class MainWindow : Window
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandModifier && TryGetNavigationShortcut(e.Key, out var destination))
|
||||
{
|
||||
vm.NavigateToCommand.Execute(destination);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vm.IsCommandPaletteOpen) return;
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
@@ -54,6 +61,23 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetNavigationShortcut(Key key, out NavItem destination)
|
||||
{
|
||||
destination = key switch
|
||||
{
|
||||
Key.D1 or Key.NumPad1 => NavItem.Dashboard,
|
||||
Key.D2 or Key.NumPad2 => NavItem.Groups,
|
||||
Key.D3 or Key.NumPad3 => NavItem.Students,
|
||||
Key.D4 or Key.NumPad4 => NavItem.Exams,
|
||||
Key.D5 or Key.NumPad5 => NavItem.Planner,
|
||||
Key.D6 or Key.NumPad6 => NavItem.Workload,
|
||||
Key.D7 or Key.NumPad7 => NavItem.ClassTeacher,
|
||||
Key.D8 or Key.NumPad8 => NavItem.Settings,
|
||||
_ => default,
|
||||
};
|
||||
return key is >= Key.D1 and <= Key.D8 or >= Key.NumPad1 and <= Key.NumPad8;
|
||||
}
|
||||
|
||||
private void OnOpenCommandPaletteClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is MainWindowViewModel vm)
|
||||
|
||||
Reference in New Issue
Block a user