Files
FileTime2/src/ConsoleApp/FileTime.ConsoleUI.App/RootViewModel.cs

44 lines
1.5 KiB
C#

using FileTime.App.CommandPalette.ViewModels;
using FileTime.App.Core.ViewModels;
using FileTime.App.Core.ViewModels.Timeline;
using FileTime.ConsoleUI.App.Services;
using FileTime.Core.Interactions;
namespace FileTime.ConsoleUI.App;
public class RootViewModel : IRootViewModel
{
public string UserName => Environment.UserName;
public string MachineName => Environment.MachineName;
public IPossibleCommandsViewModel PossibleCommands { get; }
public IConsoleAppState AppState { get; }
public ICommandPaletteViewModel CommandPalette { get; }
public IDialogService DialogService { get; }
public ITimelineViewModel TimelineViewModel { get; }
public event Action<IInputElement>? FocusReadInputElement;
public RootViewModel(
IConsoleAppState appState,
IPossibleCommandsViewModel possibleCommands,
ICommandPaletteViewModel commandPalette,
IDialogService dialogService,
ITimelineViewModel timelineViewModel)
{
AppState = appState;
PossibleCommands = possibleCommands;
CommandPalette = commandPalette;
DialogService = dialogService;
TimelineViewModel = timelineViewModel;
DialogService.ReadInput.PropertyChanged += (o, e) =>
{
if (e.PropertyName == nameof(DialogService.ReadInput.Value))
{
if (DialogService.ReadInput.Value is {Inputs.Count: > 0} readInputs)
{
FocusReadInputElement?.Invoke(readInputs.Inputs[0]);
}
}
};
}
}