diff --git a/src/Models/ResetMode.cs b/src/Models/ResetMode.cs index 735533c2..312302a8 100644 --- a/src/Models/ResetMode.cs +++ b/src/Models/ResetMode.cs @@ -6,23 +6,25 @@ namespace SourceGit.Models { public static readonly ResetMode[] Supported = [ - new ResetMode("Soft", "Keep all changes. Stage differences", "--soft", Brushes.Green), - new ResetMode("Mixed", "Keep all changes. Unstage differences", "--mixed", Brushes.Orange), - new ResetMode("Merge", "Reset while keeping unmerged changes", "--merge", Brushes.Purple), - new ResetMode("Keep", "Reset while keeping local modifications", "--keep", Brushes.Purple), - new ResetMode("Hard", "Discard all changes", "--hard", Brushes.Red), + new ResetMode("Soft", "Keep all changes. Stage differences", "--soft", 'S', Brushes.Green), + new ResetMode("Mixed", "Keep all changes. Unstage differences", "--mixed", 'M',Brushes.Orange), + new ResetMode("Merge", "Reset while keeping unmerged changes", "--merge", 'G',Brushes.Purple), + new ResetMode("Keep", "Reset while keeping local modifications", "--keep", 'K',Brushes.Purple), + new ResetMode("Hard", "Discard all changes", "--hard", 'H',Brushes.Red), ]; public string Name { get; set; } public string Desc { get; set; } public string Arg { get; set; } + public char Key { get; set; } public IBrush Color { get; set; } - public ResetMode(string n, string d, string a, IBrush b) + public ResetMode(string n, string d, string a, char k, IBrush b) { Name = n; Desc = d; Arg = a; + Key = k; Color = b; } } diff --git a/src/Views/Reset.axaml b/src/Views/Reset.axaml index c703ac1d..5c3025e9 100644 --- a/src/Views/Reset.axaml +++ b/src/Views/Reset.axaml @@ -7,6 +7,7 @@ xmlns:c="using:SourceGit.Converters" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.Reset" + Loaded="Control_OnLoaded" x:DataType="vm:Reset"> - - - + + + diff --git a/src/Views/Reset.axaml.cs b/src/Views/Reset.axaml.cs index cc4b9b58..cefcf426 100644 --- a/src/Views/Reset.axaml.cs +++ b/src/Views/Reset.axaml.cs @@ -1,4 +1,8 @@ +using System.Linq; using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Interactivity; +using SourceGit.Models; namespace SourceGit.Views { @@ -8,5 +12,28 @@ namespace SourceGit.Views { InitializeComponent(); } + + private void InputElement_OnKeyDown(object sender, KeyEventArgs e) + { + var key = e.Key.ToString().ToLower(); + foreach (var item in ResetMode.ItemsSource) + { + if (item.GetType() == typeof(ResetMode)) + { + var resetMode = (ResetMode)item; + if (resetMode.Key.ToString().ToLower() == key) + { + ResetMode.SelectedValue = resetMode; + return; + } + + } + } + } + + private void Control_OnLoaded(object sender, RoutedEventArgs e) + { + ResetMode.Focus(); + } } }