From 6583f1c7910ea4c1ad6c88eb528191a8528f073e Mon Sep 17 00:00:00 2001 From: Thomas Hilscher Date: Sat, 25 Feb 2023 15:45:37 +0100 Subject: [PATCH] Added Control-F Search --- WGneu/Windows/MemberListWindow.xaml | 14 +++++++------- WGneu/Windows/MemberListWindow.xaml.cs | 12 ++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/WGneu/Windows/MemberListWindow.xaml b/WGneu/Windows/MemberListWindow.xaml index 43acb08..3a616ca 100644 --- a/WGneu/Windows/MemberListWindow.xaml +++ b/WGneu/Windows/MemberListWindow.xaml @@ -30,11 +30,11 @@ + Grid.ColumnSpan="3" Margin="10,7,10,0" VerticalAlignment="Top" FontSize="14" Padding="2,2,2,2"/> + Margin="10,39,10,47" FontSize="14" Grid.ColumnSpan="3"> @@ -64,11 +64,11 @@ + HorizontalAlignment="Left" Margin="10,26,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="183" Grid.ColumnSpan="2" FontSize="14"/> + HorizontalAlignment="Left" Margin="10,52,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="183" Grid.ColumnSpan="2" FontSize="14"/> + HorizontalAlignment="Left" Margin="10,78,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="183" Grid.ColumnSpan="2" FontSize="14"/> @@ -91,13 +91,13 @@ + HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" Grid.ColumnSpan="2" FontSize="14"/> + HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="120" Grid.ColumnSpan="2" FontSize="14"/> diff --git a/WGneu/Windows/MemberListWindow.xaml.cs b/WGneu/Windows/MemberListWindow.xaml.cs index 1b70c4d..4ee6d5d 100644 --- a/WGneu/Windows/MemberListWindow.xaml.cs +++ b/WGneu/Windows/MemberListWindow.xaml.cs @@ -26,6 +26,7 @@ namespace WGneu.Windows private bool isEditing = false; private bool isCreating = false; private List textFilter = new(); + private static RoutedCommand controlF = new RoutedCommand(); private readonly WgContext context = new(); public MemberListWindow() @@ -38,6 +39,8 @@ namespace WGneu.Windows RefreshMemberList(); BranchInput.ItemsSource = context.Branches.OrderBy(b => b.Name).ToList(); DefaultKgInput.ItemsSource = context.WbKgs.Select(k => k.Kg).OrderBy(k => k.Name).ToList(); + controlF.InputGestures.Add(new KeyGesture(Key.F, ModifierKeys.Control)); + CommandBindings.Add(new CommandBinding(controlF, FocusSearchInput)); } protected override void OnClosing(CancelEventArgs e) @@ -233,6 +236,15 @@ namespace WGneu.Windows RefreshMemberList(); } + private void FocusSearchInput(object sender, RoutedEventArgs e) + { + if (!isEditing) + { + SearchInput.Focus(); + SearchInput.SelectAll(); + } + } + private int NextMgNr() { int c = context.Members.Select(m => m.MgNr).Min();