diff --git a/src/AppCommon/FileTime.App.CommandPalette/Services/CommandPaletteService.cs b/src/AppCommon/FileTime.App.CommandPalette/Services/CommandPaletteService.cs index c6a09a4..30ff0f7 100644 --- a/src/AppCommon/FileTime.App.CommandPalette/Services/CommandPaletteService.cs +++ b/src/AppCommon/FileTime.App.CommandPalette/Services/CommandPaletteService.cs @@ -40,8 +40,9 @@ public partial class CommandPaletteService : ICommandPaletteService public IReadOnlyList GetCommands() => _identifiableUserCommandService - .GetCommandIdentifiers() - .Select(c => new CommandPaletteEntry(c, c)) + .IdentifiableUserCommands + .Select(c => new CommandPaletteEntry(c.Key, c.Value.Title)) + .OrderBy(c => c.Title) .ToList() .AsReadOnly(); } \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.CommandPalette/ViewModels/CommandPaletteViewModel.cs b/src/AppCommon/FileTime.App.CommandPalette/ViewModels/CommandPaletteViewModel.cs index 1cc8d50..66ff7ef 100644 --- a/src/AppCommon/FileTime.App.CommandPalette/ViewModels/CommandPaletteViewModel.cs +++ b/src/AppCommon/FileTime.App.CommandPalette/ViewModels/CommandPaletteViewModel.cs @@ -41,9 +41,8 @@ public class CommandPaletteViewModel : FuzzyPanelViewModel - (ICommandPaletteEntryViewModel) new CommandPaletteEntryViewModel(c.Identifier, c.Title)) - .Take(30) // TODO remove magic number - .OrderBy(c => c.Title) + (ICommandPaletteEntryViewModel) new CommandPaletteEntryViewModel(c.Identifier, c.Title) + ) .ToList(); public override async Task HandleKeyDown(KeyEventArgs keyEventArgs) diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/Services/IIdentifiableUserCommandService.cs b/src/AppCommon/FileTime.App.Core.Abstraction/Services/IIdentifiableUserCommandService.cs index c925895..9151d56 100644 --- a/src/AppCommon/FileTime.App.Core.Abstraction/Services/IIdentifiableUserCommandService.cs +++ b/src/AppCommon/FileTime.App.Core.Abstraction/Services/IIdentifiableUserCommandService.cs @@ -4,7 +4,8 @@ namespace FileTime.App.Core.Services; public interface IIdentifiableUserCommandService { - void AddIdentifiableUserCommandFactory(string identifier, Func commandFactory); + void AddIdentifiableUserCommandFactory(string identifier, IIdentifiableUserCommand commandFactory); IIdentifiableUserCommand? GetCommand(string identifier); IReadOnlyCollection GetCommandIdentifiers(); + IReadOnlyDictionary IdentifiableUserCommands { get; } } \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/IdentifiableUserCommandService.cs b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/IdentifiableUserCommandService.cs index 9d65eb0..bb7e1cf 100644 --- a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/IdentifiableUserCommandService.cs +++ b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/IdentifiableUserCommandService.cs @@ -4,9 +4,15 @@ namespace FileTime.App.Core.Services.UserCommandHandler; public class IdentifiableUserCommandService : IIdentifiableUserCommandService { - private readonly Dictionary> _identifiableUserCommands = new(); + private readonly Dictionary _identifiableUserCommands = new(); + public IReadOnlyDictionary IdentifiableUserCommands { get; } - public void AddIdentifiableUserCommandFactory(string identifier, Func commandFactory) + public IdentifiableUserCommandService() + { + IdentifiableUserCommands = _identifiableUserCommands.AsReadOnly(); + } + + public void AddIdentifiableUserCommandFactory(string identifier, IIdentifiableUserCommand commandFactory) => _identifiableUserCommands.Add(identifier, commandFactory); public IIdentifiableUserCommand? GetCommand(string identifier) @@ -15,7 +21,7 @@ public class IdentifiableUserCommandService : IIdentifiableUserCommandService if (!_identifiableUserCommands.ContainsKey(identifier)) throw new IndexOutOfRangeException($"No command factory is registered for command {identifier}"); - return _identifiableUserCommands[identifier].Invoke(); + return _identifiableUserCommands[identifier]; } public IReadOnlyCollection GetCommandIdentifiers() => _identifiableUserCommands.Keys.ToList(); diff --git a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs index 3e006bd..2f18609 100644 --- a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs +++ b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs @@ -68,5 +68,5 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler public Task InitAsync() => Task.CompletedTask; private void AddUserCommand(IIdentifiableUserCommand command) - => _userCommandHandlerService.AddIdentifiableUserCommandFactory(command.UserCommandID, () => command); + => _userCommandHandlerService.AddIdentifiableUserCommandFactory(command.UserCommandID, command); } \ No newline at end of file diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/CommandPalette.axaml b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/CommandPalette.axaml index 47e3916..bd28874 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/CommandPalette.axaml +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/CommandPalette.axaml @@ -3,6 +3,8 @@ d:DesignWidth="800" 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" @@ -10,7 +12,8 @@ - + - + - + diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml index 6956fd3..4bb721e 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml @@ -45,7 +45,8 @@ - + @@ -59,8 +60,10 @@ - - + + - + - + - + - + - + @@ -502,11 +511,14 @@ Width="1" /> - - + + - + - + - + - + - + - + - + - + @@ -680,7 +702,8 @@ - + @@ -749,8 +772,10 @@ - - + + @@ -762,11 +787,13 @@ - + - + @@ -774,7 +801,8 @@ - + @@ -880,7 +908,7 @@ HorizontalAlignment="Stretch" IsVisible="{Binding ShowWindow^, FallbackValue=False}" VerticalAlignment="Stretch"> - + @@ -891,7 +919,7 @@ HorizontalAlignment="Stretch" IsVisible="{Binding ShowWindow^, FallbackValue=False}" VerticalAlignment="Stretch"> - +