Console upgrades, PossibleCommands VM

This commit is contained in:
2023-08-10 22:54:52 +02:00
parent 96d4eb926d
commit e989a65e81
48 changed files with 983 additions and 400 deletions

View File

@@ -4,9 +4,7 @@ using System.Reactive.Subjects;
using DeclarativeProperty;
using FileTime.App.Core.Configuration;
using FileTime.App.Core.Models.Enums;
using FileTime.App.Core.ViewModels.Timeline;
using FileTime.Core.Models.Extensions;
using MvvmGen;
using MoreLinq;
using PropertyChanged.SourceGenerator;
@@ -31,7 +29,6 @@ public abstract partial class AppStateBase : IAppState
public IDeclarativeProperty<string?> ContainerStatus { get; }
[Notify] public List<KeyConfig> PreviousKeys { get; } = new();
[Notify] public List<CommandBindingConfiguration> PossibleCommands { get; set; } = new();
[Notify] public bool NoCommandFound { get; set; }
protected AppStateBase()

View File

@@ -0,0 +1,6 @@
namespace FileTime.App.Core.ViewModels;
public record PossibleCommandEntryViewModel(
string CommandName,
string Title,
string KeysText) : IPossibleCommandEntryViewModel;

View File

@@ -0,0 +1,36 @@
using System.Collections.ObjectModel;
using FileTime.App.Core.Configuration;
using FileTime.App.Core.Services;
using ObservableComputations;
namespace FileTime.App.Core.ViewModels;
public class PossibleCommandsViewModel : IPossibleCommandsViewModel, IDisposable
{
private readonly IIdentifiableUserCommandService _identifiableUserCommandService;
private readonly OcConsumer _ocConsumer = new();
public ObservableCollection<IPossibleCommandEntryViewModel> PossibleCommands { get; }
public PossibleCommandsViewModel(
IPossibleCommandsService possibleCommandsService,
IIdentifiableUserCommandService identifiableUserCommandService)
{
_identifiableUserCommandService = identifiableUserCommandService;
PossibleCommands = possibleCommandsService
.PossibleCommands
.Selecting(c => CreatePossibleCommandViewModel(c))
.For(_ocConsumer);
}
private IPossibleCommandEntryViewModel CreatePossibleCommandViewModel(CommandBindingConfiguration commandBindingConfiguration)
{
var commandName = commandBindingConfiguration.Command;
var title = _identifiableUserCommandService.GetCommand(commandName)?.Title ?? commandName;
return new PossibleCommandEntryViewModel(
CommandName: commandName,
Title: title,
KeysText: commandBindingConfiguration.GetKeysDisplayText());
}
public void Dispose() => _ocConsumer.Dispose();
}