Search by regex, modal Enter fixes
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.GuiApp.ViewModels;
|
||||
|
||||
namespace FileTime.GuiApp.Converters;
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
mc:Ignorable="d"
|
||||
x:Class="FileTime.GuiApp.Views.CommandPalette"
|
||||
x:CompileBindings="True"
|
||||
xmlns:vm="clr-namespace:FileTime.App.CommandPalette.ViewModels;assembly=FileTime.App.CommandPalette.Abstractions"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="clr-namespace:FileTime.App.CommandPalette.ViewModels;assembly=FileTime.App.CommandPalette.Abstractions"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<UserControl.Styles>
|
||||
<StyleInclude Source="avares://FileTime.GuiApp/Resources/Styles.axaml" />
|
||||
</UserControl.Styles>
|
||||
<Grid RowDefinitions="Auto,*"
|
||||
x:DataType="vm:ICommandPaletteViewModel">
|
||||
<Grid RowDefinitions="Auto,*" x:DataType="vm:ICommandPaletteViewModel">
|
||||
<TextBox
|
||||
KeyDown="Search_OnKeyDown"
|
||||
KeyUp="Search_OnKeyUp"
|
||||
Text="{Binding SearchText, Mode=TwoWay}"
|
||||
x:Name="SearchTextBox" />
|
||||
<ListBox
|
||||
@@ -25,9 +25,12 @@
|
||||
SelectedItem="{Binding SelectedItem}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:ICommandPaletteEntryViewModel">
|
||||
<Grid Margin="5" ColumnDefinitions="*, Auto">
|
||||
<Grid ColumnDefinitions="*, Auto" Margin="5">
|
||||
<TextBlock Text="{Binding Title}" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Shortcuts}" Margin="0,0,10,0" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="0,0,10,0"
|
||||
Text="{Binding Shortcuts}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
@@ -26,6 +26,7 @@ public partial class CommandPalette : UserControl
|
||||
|
||||
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
if (DataContext is not ICommandPaletteViewModel viewModel) return;
|
||||
|
||||
if (e.Key == Key.Escape)
|
||||
@@ -38,4 +39,11 @@ public partial class CommandPalette : UserControl
|
||||
viewModel.HandleKeyDown(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void Search_OnKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
if (DataContext is not ICommandPaletteViewModel viewModel) return;
|
||||
viewModel.HandleKeyUp(e);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<TextBox
|
||||
KeyDown="Search_OnKeyDown"
|
||||
KeyUp="Search_OnKeyUp"
|
||||
Text="{Binding SearchText, Mode=TwoWay}"
|
||||
x:Name="SearchTextBox" />
|
||||
<ListBox
|
||||
|
||||
@@ -24,8 +24,10 @@ public partial class FrequencyNavigation : UserControl
|
||||
|
||||
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
|
||||
if (DataContext is not IFrequencyNavigationViewModel viewModel) return;
|
||||
|
||||
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
viewModel.Close();
|
||||
@@ -35,4 +37,11 @@ public partial class FrequencyNavigation : UserControl
|
||||
viewModel.HandleKeyDown(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void Search_OnKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
if (DataContext is not IFrequencyNavigationViewModel viewModel) return;
|
||||
viewModel.HandleKeyUp(e);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public partial class MainWindow : Window, IUiAccessor
|
||||
inputViewModel => _inputViewModel = inputViewModel
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
_logger?.LogInformation(
|
||||
$"{nameof(MainWindow)} opened, starting {nameof(MainWindowViewModel)} initialization...");
|
||||
ViewModel = DI.ServiceProvider.GetRequiredService<MainWindowViewModel>();
|
||||
@@ -111,7 +111,7 @@ public partial class MainWindow : Window, IUiAccessor
|
||||
&& sender is StyledElement control)
|
||||
{
|
||||
FullName? path = null;
|
||||
if (control.DataContext is IHaveFullPath {Path: { }} hasFullPath)
|
||||
if (control.DataContext is IHaveFullPath { Path: { } } hasFullPath)
|
||||
{
|
||||
path = hasFullPath.Path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user