Search by regex, modal Enter fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using FileTime.App.Core.ViewModels;
|
using Avalonia.Input;
|
||||||
|
using FileTime.App.Core.ViewModels;
|
||||||
using FileTime.App.FuzzyPanel;
|
using FileTime.App.FuzzyPanel;
|
||||||
|
|
||||||
namespace FileTime.App.CommandPalette.ViewModels;
|
namespace FileTime.App.CommandPalette.ViewModels;
|
||||||
@@ -7,4 +8,5 @@ public interface ICommandPaletteViewModel : IFuzzyPanelViewModel<ICommandPalette
|
|||||||
{
|
{
|
||||||
IObservable<bool> ShowWindow { get; }
|
IObservable<bool> ShowWindow { get; }
|
||||||
void Close();
|
void Close();
|
||||||
|
Task<bool> HandleKeyUp(KeyEventArgs keyEventArgs);
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ public class CommandPaletteViewModel : FuzzyPanelViewModel<ICommandPaletteEntryV
|
|||||||
IUserCommandHandlerService userCommandHandlerService,
|
IUserCommandHandlerService userCommandHandlerService,
|
||||||
IKeyboardConfigurationService keyboardConfigurationService,
|
IKeyboardConfigurationService keyboardConfigurationService,
|
||||||
ILogger<CommandPaletteViewModel> logger)
|
ILogger<CommandPaletteViewModel> logger)
|
||||||
|
: base((a, b) => a.Identifier == b.Identifier)
|
||||||
{
|
{
|
||||||
_commandPaletteService = commandPaletteService;
|
_commandPaletteService = commandPaletteService;
|
||||||
_identifiableUserCommandService = identifiableUserCommandService;
|
_identifiableUserCommandService = identifiableUserCommandService;
|
||||||
@@ -105,6 +106,13 @@ public class CommandPaletteViewModel : FuzzyPanelViewModel<ICommandPaletteEntryV
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> HandleKeyUp(KeyEventArgs keyEventArgs)
|
||||||
|
{
|
||||||
|
if (keyEventArgs.Handled) return false;
|
||||||
|
|
||||||
if (keyEventArgs.Key == Key.Enter)
|
if (keyEventArgs.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
if (SelectedItem is null) return false;
|
if (SelectedItem is null) return false;
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using FileTime.Core.Models;
|
||||||
|
|
||||||
|
namespace FileTime.App.Core.Exceptions;
|
||||||
|
|
||||||
|
public enum ItemNotFoundExceptionType
|
||||||
|
{
|
||||||
|
Raw,
|
||||||
|
FullName,
|
||||||
|
NativePath
|
||||||
|
}
|
||||||
|
public class ItemNotFoundException : Exception
|
||||||
|
{
|
||||||
|
public string Path { get; }
|
||||||
|
public ItemNotFoundExceptionType Type { get; } = ItemNotFoundExceptionType.Raw;
|
||||||
|
|
||||||
|
public ItemNotFoundException(string path)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemNotFoundException(FullName path)
|
||||||
|
{
|
||||||
|
Path = path.Path;
|
||||||
|
Type = ItemNotFoundExceptionType.FullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemNotFoundException(NativePath path)
|
||||||
|
{
|
||||||
|
Path = path.Path;
|
||||||
|
Type = ItemNotFoundExceptionType.NativePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Reactive.Subjects;
|
using System.Reactive.Subjects;
|
||||||
using FileTime.App.Core.Models;
|
using FileTime.App.Core.Models;
|
||||||
using FileTime.Core.Interactions;
|
using FileTime.Core.Interactions;
|
||||||
|
using FileTime.Core.Models;
|
||||||
|
|
||||||
namespace FileTime.App.Core.Interactions;
|
namespace FileTime.App.Core.Interactions;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using FileTime.App.Core.Models;
|
using FileTime.App.Core.Models;
|
||||||
|
using FileTime.Core.Models;
|
||||||
|
|
||||||
namespace FileTime.App.Core.Services;
|
namespace FileTime.App.Core.Services;
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,14 @@ public class SearchCommand : IUserCommand
|
|||||||
public sealed class IdentifiableSearchCommand : SearchCommand, IIdentifiableUserCommand
|
public sealed class IdentifiableSearchCommand : SearchCommand, IIdentifiableUserCommand
|
||||||
{
|
{
|
||||||
public const string SearchByNameContainsCommandName = "search_name_contains";
|
public const string SearchByNameContainsCommandName = "search_name_contains";
|
||||||
|
public const string SearchByRegexCommandName = "search_name_regex";
|
||||||
|
|
||||||
public static readonly IdentifiableSearchCommand SearchByNameContains =
|
public static readonly IdentifiableSearchCommand SearchByNameContains =
|
||||||
new(null, SearchType.NameContains, SearchByNameContainsCommandName, "Search by name");
|
new(null, SearchType.NameContains, SearchByNameContainsCommandName, "Search by name");
|
||||||
|
|
||||||
|
public static readonly IdentifiableSearchCommand SearchByRegex =
|
||||||
|
new(null, SearchType.NameRegex, SearchByRegexCommandName, "Search by name (Regex)");
|
||||||
|
|
||||||
private IdentifiableSearchCommand(
|
private IdentifiableSearchCommand(
|
||||||
string? searchText,
|
string? searchText,
|
||||||
SearchType searchType,
|
SearchType searchType,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public interface IAppState
|
|||||||
ReadOnlyObservableCollection<ITabViewModel> Tabs { get; }
|
ReadOnlyObservableCollection<ITabViewModel> Tabs { get; }
|
||||||
IObservable<ITabViewModel?> SelectedTab { get; }
|
IObservable<ITabViewModel?> SelectedTab { get; }
|
||||||
IObservable<string?> SearchText { get; }
|
IObservable<string?> SearchText { get; }
|
||||||
IObservable<ViewMode> ViewMode { get; }
|
IDeclarativeProperty<ViewMode> ViewMode { get; }
|
||||||
DeclarativeProperty<string?> RapidTravelText { get; }
|
DeclarativeProperty<string?> RapidTravelText { get; }
|
||||||
ITabViewModel? CurrentSelectedTab { get; }
|
ITabViewModel? CurrentSelectedTab { get; }
|
||||||
ITimelineViewModel TimelineViewModel { get; }
|
ITimelineViewModel TimelineViewModel { get; }
|
||||||
@@ -18,6 +18,6 @@ public interface IAppState
|
|||||||
void AddTab(ITabViewModel tabViewModel);
|
void AddTab(ITabViewModel tabViewModel);
|
||||||
void RemoveTab(ITabViewModel tabViewModel);
|
void RemoveTab(ITabViewModel tabViewModel);
|
||||||
void SetSearchText(string? searchText);
|
void SetSearchText(string? searchText);
|
||||||
void SwitchViewMode(ViewMode newViewMode);
|
Task SwitchViewModeAsync(ViewMode newViewMode);
|
||||||
void SetSelectedTab(ITabViewModel tabToSelect);
|
void SetSelectedTab(ITabViewModel tabToSelect);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using DeclarativeProperty;
|
using DeclarativeProperty;
|
||||||
using FileTime.App.Core.Models;
|
|
||||||
using FileTime.App.Core.Models.Enums;
|
using FileTime.App.Core.Models.Enums;
|
||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
using InitableService;
|
using InitableService;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using FileTime.App.Core.Models;
|
using FileTime.App.Core.Models;
|
||||||
|
using FileTime.Core.Models;
|
||||||
|
|
||||||
namespace FileTime.App.Core.Services;
|
namespace FileTime.App.Core.Services;
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ public class ItemNameConverterService : IItemNameConverterService
|
|||||||
{
|
{
|
||||||
var nameLeft = name;
|
var nameLeft = name;
|
||||||
|
|
||||||
while (nameLeft.ToLower().IndexOf(searchText, StringComparison.Ordinal) is int rapidTextStart && rapidTextStart != -1)
|
while (nameLeft.ToLower().IndexOf(searchText, StringComparison.Ordinal) is var rapidTextStart && rapidTextStart != -1)
|
||||||
{
|
{
|
||||||
var before = rapidTextStart > 0 ? nameLeft.Substring(0, rapidTextStart) : null;
|
var before = rapidTextStart > 0 ? nameLeft.Substring(0, rapidTextStart) : null;
|
||||||
var rapidTravel = nameLeft.Substring(rapidTextStart, searchText.Length);
|
var rapidTravel = nameLeft.Substring(rapidTextStart, searchText.Length);
|
||||||
|
|||||||
@@ -310,13 +310,13 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
|||||||
|
|
||||||
private Task EnterRapidTravel()
|
private Task EnterRapidTravel()
|
||||||
{
|
{
|
||||||
_appState.SwitchViewMode(ViewMode.RapidTravel);
|
_appState.SwitchViewModeAsync(ViewMode.RapidTravel);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task ExitRapidTravel()
|
private Task ExitRapidTravel()
|
||||||
{
|
{
|
||||||
_appState.SwitchViewMode(ViewMode.Default);
|
_appState.SwitchViewModeAsync(ViewMode.Default);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,10 +106,10 @@ public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
|
|||||||
//TODO proper error message
|
//TODO proper error message
|
||||||
if (string.IsNullOrWhiteSpace(searchQuery)) return;
|
if (string.IsNullOrWhiteSpace(searchQuery)) return;
|
||||||
|
|
||||||
var searchMatcher = searchCommand.SearchType switch
|
ISearchMatcher searchMatcher = searchCommand.SearchType switch
|
||||||
{
|
{
|
||||||
SearchType.NameContains => new NameContainsMatcher(_itemNameConverterService, searchQuery),
|
SearchType.NameContains => new NameContainsMatcher(_itemNameConverterService, searchQuery),
|
||||||
//SearchType.NameRegex => new NameRegexMatcher(searchQuery),
|
SearchType.NameRegex => new RegexMatcher(searchQuery),
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
|||||||
AddUserCommand(SortItemsCommand.OrderByDateCommand);
|
AddUserCommand(SortItemsCommand.OrderByDateCommand);
|
||||||
AddUserCommand(SortItemsCommand.OrderByDateDescCommand);
|
AddUserCommand(SortItemsCommand.OrderByDateDescCommand);
|
||||||
AddUserCommand(IdentifiableSearchCommand.SearchByNameContains);
|
AddUserCommand(IdentifiableSearchCommand.SearchByNameContains);
|
||||||
|
AddUserCommand(IdentifiableSearchCommand.SearchByRegex);
|
||||||
AddUserCommand(SwitchToTabCommand.SwitchToLastTab);
|
AddUserCommand(SwitchToTabCommand.SwitchToLastTab);
|
||||||
AddUserCommand(SwitchToTabCommand.SwitchToTab1);
|
AddUserCommand(SwitchToTabCommand.SwitchToTab1);
|
||||||
AddUserCommand(SwitchToTabCommand.SwitchToTab2);
|
AddUserCommand(SwitchToTabCommand.SwitchToTab2);
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ public abstract partial class AppStateBase : IAppState
|
|||||||
{
|
{
|
||||||
private readonly BehaviorSubject<string?> _searchText = new(null);
|
private readonly BehaviorSubject<string?> _searchText = new(null);
|
||||||
private readonly BehaviorSubject<ITabViewModel?> _selectedTab = new(null);
|
private readonly BehaviorSubject<ITabViewModel?> _selectedTab = new(null);
|
||||||
private readonly BehaviorSubject<ViewMode> _viewMode = new(Models.Enums.ViewMode.Default);
|
private readonly DeclarativeProperty<ViewMode> _viewMode = new(Models.Enums.ViewMode.Default);
|
||||||
private readonly SourceList<ITabViewModel> _tabs = new();
|
private readonly SourceList<ITabViewModel> _tabs = new();
|
||||||
|
|
||||||
public IObservable<ViewMode> ViewMode { get; private set; }
|
public IDeclarativeProperty<ViewMode> ViewMode { get; private set; }
|
||||||
|
|
||||||
public ReadOnlyObservableCollection<ITabViewModel> Tabs { get; private set; }
|
public ReadOnlyObservableCollection<ITabViewModel> Tabs { get; private set; }
|
||||||
public IObservable<string?> SearchText { get; private set; }
|
public IObservable<string?> SearchText { get; private set; }
|
||||||
@@ -31,7 +31,7 @@ public abstract partial class AppStateBase : IAppState
|
|||||||
partial void OnInitialize()
|
partial void OnInitialize()
|
||||||
{
|
{
|
||||||
RapidTravelText = new("");
|
RapidTravelText = new("");
|
||||||
ViewMode = _viewMode.AsObservable();
|
ViewMode = _viewMode;
|
||||||
|
|
||||||
var tabsObservable = _tabs.Connect();
|
var tabsObservable = _tabs.Connect();
|
||||||
|
|
||||||
@@ -70,10 +70,7 @@ public abstract partial class AppStateBase : IAppState
|
|||||||
|
|
||||||
public void SetSearchText(string? searchText) => _searchText.OnNext(searchText);
|
public void SetSearchText(string? searchText) => _searchText.OnNext(searchText);
|
||||||
|
|
||||||
public void SwitchViewMode(ViewMode newViewMode)
|
public async Task SwitchViewModeAsync(ViewMode newViewMode) => await _viewMode.SetValue(newViewMode);
|
||||||
{
|
|
||||||
_viewMode.OnNext(newViewMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSelectedTab(ITabViewModel tabToSelect) => _selectedTab.OnNext(tabToSelect);
|
public void SetSelectedTab(ITabViewModel tabToSelect) => _selectedTab.OnNext(tabToSelect);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,5 @@ public partial class ContainerSizeContainerViewModel : ItemViewModel, IContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Init(IContainer item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
public void Init(IContainer item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||||
{
|
=> Init((IItem)item, parentTab, itemViewModelType);
|
||||||
Init((IItem)item, parentTab, itemViewModelType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,5 @@ public partial class ElementViewModel : ItemViewModel, IElementViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Init(IElement item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
public void Init(IElement item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||||
{
|
=> Init((IItem)item, parentTab, itemViewModelType);
|
||||||
Init((IItem)item, parentTab, itemViewModelType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -96,6 +96,7 @@ public partial class ElementPreviewViewModel : IItemPreviewViewModel, IAsyncInit
|
|||||||
var encodingsWithPartialResult = binaryCharacter.Where(e => !string.IsNullOrWhiteSpace(e.Value.PartialResult)).ToList();
|
var encodingsWithPartialResult = binaryCharacter.Where(e => !string.IsNullOrWhiteSpace(e.Value.PartialResult)).ToList();
|
||||||
if (encodingsWithPartialResult.Count > 0)
|
if (encodingsWithPartialResult.Count > 0)
|
||||||
{
|
{
|
||||||
|
stringBuilder.AppendLine();
|
||||||
stringBuilder.AppendLine("The following partial texts could be read by encodings:");
|
stringBuilder.AppendLine("The following partial texts could be read by encodings:");
|
||||||
foreach (var binaryByEncoding in encodingsWithPartialResult)
|
foreach (var binaryByEncoding in encodingsWithPartialResult)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ using System.ComponentModel;
|
|||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using DeclarativeProperty;
|
using DeclarativeProperty;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using FileTime.App.Core.Models;
|
|
||||||
using FileTime.App.Core.Models.Enums;
|
using FileTime.App.Core.Models.Enums;
|
||||||
using FileTime.App.Core.Services;
|
using FileTime.App.Core.Services;
|
||||||
|
using FileTime.Core.Behaviors;
|
||||||
using FileTime.Core.Helper;
|
using FileTime.Core.Helper;
|
||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
using MoreLinq;
|
using MoreLinq;
|
||||||
@@ -37,7 +37,10 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
|
|
||||||
public IDeclarativeProperty<IReadOnlyList<ItemNamePart>>? DisplayName { get; private set; }
|
public IDeclarativeProperty<IReadOnlyList<ItemNamePart>>? DisplayName { get; private set; }
|
||||||
|
|
||||||
public void Init(IItem item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
public void Init(
|
||||||
|
IItem item,
|
||||||
|
ITabViewModel parentTab,
|
||||||
|
ItemViewModelType itemViewModelType)
|
||||||
{
|
{
|
||||||
_parentTab = parentTab;
|
_parentTab = parentTab;
|
||||||
|
|
||||||
@@ -51,7 +54,12 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
|
|
||||||
var displayName = itemViewModelType switch
|
var displayName = itemViewModelType switch
|
||||||
{
|
{
|
||||||
ItemViewModelType.Main => _appState.RapidTravelText.Map(s => (IReadOnlyList<ItemNamePart>) _itemNameConverterService.GetDisplayName(item.DisplayName, s)),
|
ItemViewModelType.Main => _appState.RapidTravelText.Map(async (s, _) =>
|
||||||
|
_appState.ViewMode.Value != Models.Enums.ViewMode.RapidTravel
|
||||||
|
&& _appState.CurrentSelectedTab?.CurrentLocation.Value?.Provider is IItemNameConverterProvider nameConverterProvider
|
||||||
|
? (IReadOnlyList<ItemNamePart>) await nameConverterProvider.GetItemNamePartsAsync(item)
|
||||||
|
: _itemNameConverterService.GetDisplayName(item.DisplayName, s)
|
||||||
|
),
|
||||||
_ => new DeclarativeProperty<IReadOnlyList<ItemNamePart>>(new List<ItemNamePart> {new(item.DisplayName)}),
|
_ => new DeclarativeProperty<IReadOnlyList<ItemNamePart>>(new List<ItemNamePart> {new(item.DisplayName)}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Avalonia.Input;
|
||||||
using FileTime.App.Core.ViewModels;
|
using FileTime.App.Core.ViewModels;
|
||||||
using FileTime.App.FuzzyPanel;
|
using FileTime.App.FuzzyPanel;
|
||||||
|
|
||||||
@@ -7,4 +8,5 @@ public interface IFrequencyNavigationViewModel : IFuzzyPanelViewModel<string>, I
|
|||||||
{
|
{
|
||||||
IObservable<bool> ShowWindow { get; }
|
IObservable<bool> ShowWindow { get; }
|
||||||
void Close();
|
void Close();
|
||||||
|
Task<bool> HandleKeyUp(KeyEventArgs keyEventArgs);
|
||||||
}
|
}
|
||||||
@@ -30,11 +30,9 @@ public class FrequencyNavigationViewModel : FuzzyPanelViewModel<string>, IFreque
|
|||||||
public void Close()
|
public void Close()
|
||||||
=> _frequencyNavigationService.CloseNavigationWindow();
|
=> _frequencyNavigationService.CloseNavigationWindow();
|
||||||
|
|
||||||
public override async Task<bool> HandleKeyDown(KeyEventArgs keyEventArgs)
|
public async Task<bool> HandleKeyUp(KeyEventArgs keyEventArgs)
|
||||||
{
|
{
|
||||||
var handled = await base.HandleKeyDown(keyEventArgs);
|
if (keyEventArgs.Handled) return false;
|
||||||
|
|
||||||
if (handled) return true;
|
|
||||||
|
|
||||||
if (keyEventArgs.Key == Key.Enter)
|
if (keyEventArgs.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
@@ -49,6 +47,23 @@ public class FrequencyNavigationViewModel : FuzzyPanelViewModel<string>, IFreque
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<bool> HandleKeyDown(KeyEventArgs keyEventArgs)
|
||||||
|
{
|
||||||
|
if (keyEventArgs.Handled) return false;
|
||||||
|
var handled = await base.HandleKeyDown(keyEventArgs);
|
||||||
|
|
||||||
|
if (handled) return true;
|
||||||
|
|
||||||
|
if (keyEventArgs.Key == Key.Escape)
|
||||||
|
{
|
||||||
|
keyEventArgs.Handled = true;
|
||||||
|
Close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void UpdateFilteredMatches() =>
|
public override void UpdateFilteredMatches() =>
|
||||||
FilteredMatches = new List<string>(_frequencyNavigationService.GetMatchingContainers(SearchText));
|
FilteredMatches = new List<string>(_frequencyNavigationService.GetMatchingContainers(SearchText));
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,18 @@ namespace FileTime.App.FuzzyPanel;
|
|||||||
|
|
||||||
public abstract partial class FuzzyPanelViewModel<TItem> : IFuzzyPanelViewModel<TItem> where TItem : class
|
public abstract partial class FuzzyPanelViewModel<TItem> : IFuzzyPanelViewModel<TItem> where TItem : class
|
||||||
{
|
{
|
||||||
|
private readonly Func<TItem, TItem, bool> _itemEquality;
|
||||||
private string _searchText = String.Empty;
|
private string _searchText = String.Empty;
|
||||||
|
|
||||||
[Notify(set: Setter.Protected)] private IObservable<bool> _showWindow;
|
[Notify(set: Setter.Protected)] private IObservable<bool> _showWindow;
|
||||||
[Notify(set: Setter.Protected)] private List<TItem> _filteredMatches;
|
[Notify(set: Setter.Protected)] private List<TItem> _filteredMatches;
|
||||||
[Notify(set: Setter.Protected)] private TItem? _selectedItem;
|
[Notify(set: Setter.Protected)] private TItem? _selectedItem;
|
||||||
|
|
||||||
|
protected FuzzyPanelViewModel(Func<TItem, TItem, bool>? itemEquality = null)
|
||||||
|
{
|
||||||
|
_itemEquality = itemEquality ?? ((a, b) => a == b);
|
||||||
|
}
|
||||||
|
|
||||||
public string SearchText
|
public string SearchText
|
||||||
{
|
{
|
||||||
get => _searchText;
|
get => _searchText;
|
||||||
@@ -42,7 +48,9 @@ public abstract partial class FuzzyPanelViewModel<TItem> : IFuzzyPanelViewModel<
|
|||||||
{
|
{
|
||||||
if (keyEventArgs.Key == Key.Down)
|
if (keyEventArgs.Key == Key.Down)
|
||||||
{
|
{
|
||||||
var nextItem = FilteredMatches.SkipWhile(i => i != SelectedItem).Skip(1).FirstOrDefault();
|
var nextItem = SelectedItem is null
|
||||||
|
? FilteredMatches.FirstOrDefault()
|
||||||
|
: FilteredMatches.SkipWhile(i => !_itemEquality(i, SelectedItem)).Skip(1).FirstOrDefault();
|
||||||
|
|
||||||
if (nextItem is not null)
|
if (nextItem is not null)
|
||||||
{
|
{
|
||||||
@@ -54,7 +62,9 @@ public abstract partial class FuzzyPanelViewModel<TItem> : IFuzzyPanelViewModel<
|
|||||||
}
|
}
|
||||||
else if (keyEventArgs.Key == Key.Up)
|
else if (keyEventArgs.Key == Key.Up)
|
||||||
{
|
{
|
||||||
var previousItem = FilteredMatches.TakeWhile(i => i != SelectedItem).LastOrDefault();
|
var previousItem = SelectedItem is null
|
||||||
|
? FilteredMatches.LastOrDefault()
|
||||||
|
: FilteredMatches.TakeWhile(i => !_itemEquality(i, SelectedItem)).LastOrDefault();
|
||||||
|
|
||||||
if (previousItem is not null)
|
if (previousItem is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ namespace FileTime.App.Search;
|
|||||||
public interface ISearchTask
|
public interface ISearchTask
|
||||||
{
|
{
|
||||||
IContainer SearchContainer { get; }
|
IContainer SearchContainer { get; }
|
||||||
|
IReadOnlyDictionary<FullName, FullName> RealFullNames { get; }
|
||||||
Task StartAsync();
|
Task StartAsync();
|
||||||
}
|
}
|
||||||
61
src/AppCommon/FileTime.App.Search/RegexMatcher.cs
Normal file
61
src/AppCommon/FileTime.App.Search/RegexMatcher.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using FileTime.App.Core.Models;
|
||||||
|
using FileTime.Core.Models;
|
||||||
|
|
||||||
|
namespace FileTime.App.Search;
|
||||||
|
|
||||||
|
public class RegexMatcher : ISearchMatcher
|
||||||
|
{
|
||||||
|
private readonly Regex _regex;
|
||||||
|
|
||||||
|
public RegexMatcher(string pattern)
|
||||||
|
{
|
||||||
|
_regex = new Regex(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<bool> IsItemMatchAsync(IItem item)
|
||||||
|
=> Task.FromResult(_regex.IsMatch(item.DisplayName));
|
||||||
|
|
||||||
|
public List<ItemNamePart> GetDisplayName(IItem item)
|
||||||
|
{
|
||||||
|
var displayName = item.DisplayName;
|
||||||
|
|
||||||
|
var match = _regex.Match(item.DisplayName);
|
||||||
|
var splitPoints = new List<int>(match.Groups.Count * 2);
|
||||||
|
if (match.Groups.Count == 0)
|
||||||
|
{
|
||||||
|
return new List<ItemNamePart>
|
||||||
|
{
|
||||||
|
new(displayName)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var areEvensSpecial = match.Groups[0].Index == 0;
|
||||||
|
var isSpecialMatchNumber = areEvensSpecial ? 0 : 1;
|
||||||
|
|
||||||
|
foreach (Group group in match.Groups)
|
||||||
|
{
|
||||||
|
splitPoints.Add(group.Index);
|
||||||
|
splitPoints.Add(group.Index + group.Value.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (splitPoints[0] != 0)
|
||||||
|
splitPoints.Insert(0, 0);
|
||||||
|
|
||||||
|
var itemNameParts = new List<ItemNamePart>();
|
||||||
|
for (var i = 0; i < splitPoints.Count; i++)
|
||||||
|
{
|
||||||
|
var index = splitPoints[i];
|
||||||
|
var nextIndex = i == splitPoints.Count - 1
|
||||||
|
? displayName.Length
|
||||||
|
: splitPoints[i + 1];
|
||||||
|
|
||||||
|
if (nextIndex == index) continue;
|
||||||
|
|
||||||
|
var text = displayName.Substring(index, nextIndex - index);
|
||||||
|
itemNameParts.Add(new ItemNamePart(text, i % 2 == isSpecialMatchNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemNameParts;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using FileTime.App.Core.Exceptions;
|
||||||
|
using FileTime.Core.Behaviors;
|
||||||
using FileTime.Core.ContentAccess;
|
using FileTime.Core.ContentAccess;
|
||||||
using FileTime.Core.Enums;
|
using FileTime.Core.Enums;
|
||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
@@ -5,7 +7,7 @@ using FileTime.Core.Timeline;
|
|||||||
|
|
||||||
namespace FileTime.App.Search;
|
namespace FileTime.App.Search;
|
||||||
|
|
||||||
public class SearchContentProvider : ContentProviderBase, ISearchContentProvider
|
public class SearchContentProvider : ContentProviderBase, ISearchContentProvider, IItemNameConverterProvider
|
||||||
{
|
{
|
||||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||||
private readonly List<SearchTask> _searchTasks = new();
|
private readonly List<SearchTask> _searchTasks = new();
|
||||||
@@ -17,6 +19,40 @@ public class SearchContentProvider : ContentProviderBase, ISearchContentProvider
|
|||||||
_timelessContentProvider = timelessContentProvider;
|
_timelessContentProvider = timelessContentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<IItem> GetItemByFullNameAsync(
|
||||||
|
FullName fullName,
|
||||||
|
PointInTime pointInTime,
|
||||||
|
bool forceResolve = false,
|
||||||
|
AbsolutePathType forceResolvePathType = AbsolutePathType.Unknown,
|
||||||
|
ItemInitializationSettings itemInitializationSettings = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (fullName.Path == ContentProviderName)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
if (_searchTasks
|
||||||
|
.FirstOrDefault(t => t.SearchContainer.FullName == fullName) is { } searchTask)
|
||||||
|
{
|
||||||
|
return searchTask.SearchContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_searchTasks.FirstOrDefault(t => t.RealFullNames.ContainsKey(fullName)) is { } searchTask2)
|
||||||
|
{
|
||||||
|
var realFullName = searchTask2.RealFullNames[fullName];
|
||||||
|
var item = await _timelessContentProvider.GetItemByFullNameAsync(
|
||||||
|
realFullName,
|
||||||
|
pointInTime,
|
||||||
|
forceResolve,
|
||||||
|
forceResolvePathType,
|
||||||
|
itemInitializationSettings
|
||||||
|
);
|
||||||
|
item = item.WithParent(new AbsolutePath(_timelessContentProvider, searchTask2.SearchContainer));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ItemNotFoundException(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
public override Task<IItem> GetItemByNativePathAsync(
|
public override Task<IItem> GetItemByNativePathAsync(
|
||||||
NativePath nativePath,
|
NativePath nativePath,
|
||||||
PointInTime pointInTime,
|
PointInTime pointInTime,
|
||||||
@@ -71,4 +107,23 @@ public class SearchContentProvider : ContentProviderBase, ISearchContentProvider
|
|||||||
Items.Remove(searchItem);
|
Items.Remove(searchItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ItemNamePart>> GetItemNamePartsAsync(IItem item)
|
||||||
|
{
|
||||||
|
var currentItem = item;
|
||||||
|
SearchTask? searchTask = null;
|
||||||
|
|
||||||
|
while (searchTask is null && currentItem is not null)
|
||||||
|
{
|
||||||
|
searchTask = currentItem.GetExtension<SearchExtension>()?.SearchTask;
|
||||||
|
|
||||||
|
currentItem = currentItem.Parent is null
|
||||||
|
? null
|
||||||
|
: await currentItem.Parent.ResolveAsync(itemInitializationSettings: new ItemInitializationSettings {SkipChildInitialization = true});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchTask is null) return new List<ItemNamePart> {new(item.DisplayName)};
|
||||||
|
|
||||||
|
return searchTask.Matcher.GetDisplayName(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
3
src/AppCommon/FileTime.App.Search/SearchExtension.cs
Normal file
3
src/AppCommon/FileTime.App.Search/SearchExtension.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace FileTime.App.Search;
|
||||||
|
|
||||||
|
public record SearchExtension(SearchTask SearchTask);
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using DynamicData;
|
|
||||||
using FileTime.Core.ContentAccess;
|
|
||||||
using FileTime.Core.Enums;
|
using FileTime.Core.Enums;
|
||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
using FileTime.Core.Timeline;
|
using FileTime.Core.Timeline;
|
||||||
@@ -18,8 +16,11 @@ public class SearchTask : ISearchTask
|
|||||||
private readonly SemaphoreSlim _searchingLock = new(1, 1);
|
private readonly SemaphoreSlim _searchingLock = new(1, 1);
|
||||||
private bool _isSearching;
|
private bool _isSearching;
|
||||||
private static int _searchId = 1;
|
private static int _searchId = 1;
|
||||||
|
private readonly Dictionary<FullName, FullName> _realFullNames = new();
|
||||||
|
public IReadOnlyDictionary<FullName, FullName> RealFullNames { get; }
|
||||||
|
|
||||||
public IContainer SearchContainer => _container;
|
public IContainer SearchContainer => _container;
|
||||||
|
public ISearchMatcher Matcher => _matcher;
|
||||||
|
|
||||||
public SearchTask(
|
public SearchTask(
|
||||||
IContainer baseContainer,
|
IContainer baseContainer,
|
||||||
@@ -33,6 +34,12 @@ public class SearchTask : ISearchTask
|
|||||||
_baseContainer = baseContainer;
|
_baseContainer = baseContainer;
|
||||||
_timelessContentProvider = timelessContentProvider;
|
_timelessContentProvider = timelessContentProvider;
|
||||||
_matcher = matcher;
|
_matcher = matcher;
|
||||||
|
RealFullNames = _realFullNames.AsReadOnly();
|
||||||
|
|
||||||
|
var extensions = new ExtensionCollection
|
||||||
|
{
|
||||||
|
new SearchExtension(this)
|
||||||
|
};
|
||||||
_container = new Container(
|
_container = new Container(
|
||||||
baseContainer.Name,
|
baseContainer.Name,
|
||||||
baseContainer.DisplayName,
|
baseContainer.DisplayName,
|
||||||
@@ -49,7 +56,7 @@ public class SearchTask : ISearchTask
|
|||||||
false,
|
false,
|
||||||
PointInTime.Present,
|
PointInTime.Present,
|
||||||
_exceptions,
|
_exceptions,
|
||||||
new ReadOnlyExtensionCollection(new ExtensionCollection()),
|
new ReadOnlyExtensionCollection(extensions),
|
||||||
_items
|
_items
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -89,14 +96,17 @@ public class SearchTask : ISearchTask
|
|||||||
|
|
||||||
foreach (var itemPath in items)
|
foreach (var itemPath in items)
|
||||||
{
|
{
|
||||||
var item = await itemPath.ResolveAsync(
|
var item = await itemPath.ResolveAsync();
|
||||||
itemInitializationSettings: new ItemInitializationSettings
|
|
||||||
{
|
|
||||||
Parent = new AbsolutePath(_timelessContentProvider, _container)
|
|
||||||
});
|
|
||||||
if (await _matcher.IsItemMatchAsync(item))
|
if (await _matcher.IsItemMatchAsync(item))
|
||||||
{
|
{
|
||||||
_items.Add(itemPath);
|
var childName = _container.FullName.GetChild(itemPath.Path.GetName());
|
||||||
|
_realFullNames.Add(childName, itemPath.Path);
|
||||||
|
_items.Add(new AbsolutePath(
|
||||||
|
_timelessContentProvider,
|
||||||
|
PointInTime.Present,
|
||||||
|
childName,
|
||||||
|
AbsolutePathType.Container
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is IContainer childContainer)
|
if (item is IContainer childContainer)
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using FileTime.Core.Models;
|
||||||
|
|
||||||
|
namespace FileTime.Core.Behaviors;
|
||||||
|
|
||||||
|
public interface IItemNameConverterProvider
|
||||||
|
{
|
||||||
|
Task<IEnumerable<ItemNamePart>> GetItemNamePartsAsync(IItem item);
|
||||||
|
}
|
||||||
@@ -26,4 +26,6 @@ public interface IItem
|
|||||||
ReadOnlyExtensionCollection Extensions { get; }
|
ReadOnlyExtensionCollection Extensions { get; }
|
||||||
|
|
||||||
T? GetExtension<T>() => (T?)Extensions.FirstOrDefault(i => i is T);
|
T? GetExtension<T>() => (T?)Extensions.FirstOrDefault(i => i is T);
|
||||||
|
|
||||||
|
IItem WithParent(AbsolutePath parent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace FileTime.App.Core.Models;
|
namespace FileTime.Core.Models;
|
||||||
|
|
||||||
public record ItemNamePart(string Text, bool IsSpecial = false);
|
public record ItemNamePart(string Text, bool IsSpecial = false);
|
||||||
@@ -90,4 +90,5 @@ public abstract class ContentProviderBase : IContentProvider
|
|||||||
|
|
||||||
public abstract bool CanHandlePath(NativePath path);
|
public abstract bool CanHandlePath(NativePath path);
|
||||||
public bool CanHandlePath(FullName path) => CanHandlePath(GetNativePath(path));
|
public bool CanHandlePath(FullName path) => CanHandlePath(GetNativePath(path));
|
||||||
|
public IItem WithParent(AbsolutePath parent) => this;
|
||||||
}
|
}
|
||||||
@@ -84,4 +84,5 @@ public class RootContentProvider : IRootContentProvider
|
|||||||
public bool CanHandlePath(NativePath path) => throw new NotImplementedException();
|
public bool CanHandlePath(NativePath path) => throw new NotImplementedException();
|
||||||
|
|
||||||
public bool CanHandlePath(FullName path) => throw new NotImplementedException();
|
public bool CanHandlePath(FullName path) => throw new NotImplementedException();
|
||||||
|
public IItem WithParent(AbsolutePath parent) => this;
|
||||||
}
|
}
|
||||||
@@ -45,15 +45,19 @@ public record Container(
|
|||||||
_isLoading.OnNext(true);
|
_isLoading.OnNext(true);
|
||||||
IsLoaded = false;
|
IsLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopLoading()
|
public void StopLoading()
|
||||||
{
|
{
|
||||||
_isLoading.OnNext(false);
|
_isLoading.OnNext(false);
|
||||||
IsLoaded = true;
|
IsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CancelLoading()
|
public void CancelLoading()
|
||||||
{
|
{
|
||||||
_loadingCancellationTokenSource.Cancel();
|
_loadingCancellationTokenSource.Cancel();
|
||||||
_isLoading.OnNext(false);
|
_isLoading.OnNext(false);
|
||||||
IsLoaded = true;
|
IsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IItem WithParent(AbsolutePath parent) => this with {Parent = parent};
|
||||||
}
|
}
|
||||||
@@ -24,4 +24,6 @@ public record Element(
|
|||||||
ReadOnlyExtensionCollection Extensions) : IElement
|
ReadOnlyExtensionCollection Extensions) : IElement
|
||||||
{
|
{
|
||||||
public AbsolutePathType Type => AbsolutePathType.Element;
|
public AbsolutePathType Type => AbsolutePathType.Element;
|
||||||
|
|
||||||
|
public IItem WithParent(AbsolutePath parent) => this with { Parent = parent };
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ using System.Globalization;
|
|||||||
using Avalonia.Data.Converters;
|
using Avalonia.Data.Converters;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using FileTime.App.Core.Models;
|
using FileTime.App.Core.Models;
|
||||||
|
using FileTime.Core.Models;
|
||||||
using FileTime.GuiApp.ViewModels;
|
using FileTime.GuiApp.ViewModels;
|
||||||
|
|
||||||
namespace FileTime.GuiApp.Converters;
|
namespace FileTime.GuiApp.Converters;
|
||||||
|
|||||||
@@ -4,18 +4,18 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
x:Class="FileTime.GuiApp.Views.CommandPalette"
|
x:Class="FileTime.GuiApp.Views.CommandPalette"
|
||||||
x:CompileBindings="True"
|
x:CompileBindings="True"
|
||||||
xmlns:vm="clr-namespace:FileTime.App.CommandPalette.ViewModels;assembly=FileTime.App.CommandPalette.Abstractions"
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
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">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
<StyleInclude Source="avares://FileTime.GuiApp/Resources/Styles.axaml" />
|
<StyleInclude Source="avares://FileTime.GuiApp/Resources/Styles.axaml" />
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
<Grid RowDefinitions="Auto,*"
|
<Grid RowDefinitions="Auto,*" x:DataType="vm:ICommandPaletteViewModel">
|
||||||
x:DataType="vm:ICommandPaletteViewModel">
|
|
||||||
<TextBox
|
<TextBox
|
||||||
KeyDown="Search_OnKeyDown"
|
KeyDown="Search_OnKeyDown"
|
||||||
|
KeyUp="Search_OnKeyUp"
|
||||||
Text="{Binding SearchText, Mode=TwoWay}"
|
Text="{Binding SearchText, Mode=TwoWay}"
|
||||||
x:Name="SearchTextBox" />
|
x:Name="SearchTextBox" />
|
||||||
<ListBox
|
<ListBox
|
||||||
@@ -25,9 +25,12 @@
|
|||||||
SelectedItem="{Binding SelectedItem}">
|
SelectedItem="{Binding SelectedItem}">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate x:DataType="vm:ICommandPaletteEntryViewModel">
|
<DataTemplate x:DataType="vm:ICommandPaletteEntryViewModel">
|
||||||
<Grid Margin="5" ColumnDefinitions="*, Auto">
|
<Grid ColumnDefinitions="*, Auto" Margin="5">
|
||||||
<TextBlock Text="{Binding Title}" />
|
<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>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public partial class CommandPalette : UserControl
|
|||||||
|
|
||||||
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.Handled) return;
|
||||||
if (DataContext is not ICommandPaletteViewModel viewModel) return;
|
if (DataContext is not ICommandPaletteViewModel viewModel) return;
|
||||||
|
|
||||||
if (e.Key == Key.Escape)
|
if (e.Key == Key.Escape)
|
||||||
@@ -38,4 +39,11 @@ public partial class CommandPalette : UserControl
|
|||||||
viewModel.HandleKeyDown(e);
|
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,*">
|
<Grid RowDefinitions="Auto,*">
|
||||||
<TextBox
|
<TextBox
|
||||||
KeyDown="Search_OnKeyDown"
|
KeyDown="Search_OnKeyDown"
|
||||||
|
KeyUp="Search_OnKeyUp"
|
||||||
Text="{Binding SearchText, Mode=TwoWay}"
|
Text="{Binding SearchText, Mode=TwoWay}"
|
||||||
x:Name="SearchTextBox" />
|
x:Name="SearchTextBox" />
|
||||||
<ListBox
|
<ListBox
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public partial class FrequencyNavigation : UserControl
|
|||||||
|
|
||||||
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.Handled) return;
|
||||||
|
|
||||||
if (DataContext is not IFrequencyNavigationViewModel viewModel) return;
|
if (DataContext is not IFrequencyNavigationViewModel viewModel) return;
|
||||||
|
|
||||||
if (e.Key == Key.Escape)
|
if (e.Key == Key.Escape)
|
||||||
@@ -35,4 +37,11 @@ public partial class FrequencyNavigation : UserControl
|
|||||||
viewModel.HandleKeyDown(e);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ public partial class MainWindow : Window, IUiAccessor
|
|||||||
&& sender is StyledElement control)
|
&& sender is StyledElement control)
|
||||||
{
|
{
|
||||||
FullName? path = null;
|
FullName? path = null;
|
||||||
if (control.DataContext is IHaveFullPath {Path: { }} hasFullPath)
|
if (control.DataContext is IHaveFullPath { Path: { } } hasFullPath)
|
||||||
{
|
{
|
||||||
path = hasFullPath.Path;
|
path = hasFullPath.Path;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user