New binding mechanism: Expression tracking
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.ConsoleUI.App.KeyInputHandling;
|
||||
using FileTime.Core.Command.CreateContainer;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Timeline;
|
||||
using GeneralInputKey;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TerminalUI;
|
||||
using TerminalUI.ConsoleDrivers;
|
||||
@@ -27,6 +31,7 @@ public class App : IApplication
|
||||
private readonly IConsoleDriver _consoleDriver;
|
||||
private readonly IAppState _appState;
|
||||
private readonly ILogger<App> _logger;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IKeyInputHandlerService _keyInputHandlerService;
|
||||
private readonly Thread _renderThread;
|
||||
|
||||
@@ -39,7 +44,8 @@ public class App : IApplication
|
||||
IApplicationContext applicationContext,
|
||||
IConsoleDriver consoleDriver,
|
||||
IAppState appState,
|
||||
ILogger<App> logger)
|
||||
ILogger<App> logger,
|
||||
IServiceProvider serviceProvider)
|
||||
{
|
||||
_lifecycleService = lifecycleService;
|
||||
_keyInputHandlerService = keyInputHandlerService;
|
||||
@@ -50,6 +56,7 @@ public class App : IApplication
|
||||
_consoleDriver = consoleDriver;
|
||||
_appState = appState;
|
||||
_logger = logger;
|
||||
_serviceProvider = serviceProvider;
|
||||
|
||||
_renderThread = new Thread(Render);
|
||||
}
|
||||
@@ -74,6 +81,12 @@ public class App : IApplication
|
||||
|
||||
var focusManager = _applicationContext.FocusManager;
|
||||
|
||||
var command = _serviceProvider.GetRequiredService<CreateContainerCommand>();
|
||||
command.Init(new FullName("local/C:/Test3"), "container1");
|
||||
var scheduler = _serviceProvider.GetRequiredService<ICommandScheduler>();
|
||||
|
||||
scheduler.AddCommand(command);
|
||||
|
||||
while (_applicationContext.IsRunning)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -129,7 +129,7 @@ public class CommandPalette
|
||||
};
|
||||
|
||||
root.WithPropertyChangedHandler(r => r.IsVisible,
|
||||
(_, _, isVisible) =>
|
||||
(_, isVisible) =>
|
||||
{
|
||||
if (isVisible)
|
||||
{
|
||||
|
||||
46
src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Timeline.cs
Normal file
46
src/ConsoleApp/FileTime.ConsoleUI.App/Controls/Timeline.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using FileTime.App.Core.ViewModels.Timeline;
|
||||
using TerminalUI.Controls;
|
||||
using TerminalUI.Extensions;
|
||||
|
||||
namespace FileTime.ConsoleUI.App.Controls;
|
||||
|
||||
public class Timeline
|
||||
{
|
||||
public IView<IRootViewModel> View()
|
||||
{
|
||||
var root = new Grid<IRootViewModel>
|
||||
{
|
||||
ChildInitializer =
|
||||
{
|
||||
new ItemsControl<IRootViewModel, ICommandTimeStateViewModel>()
|
||||
{
|
||||
ItemTemplate = () =>
|
||||
{
|
||||
var grid = new Grid<ICommandTimeStateViewModel>()
|
||||
{
|
||||
ChildInitializer =
|
||||
{
|
||||
new TextBlock<ICommandTimeStateViewModel>()
|
||||
{
|
||||
|
||||
}.Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc.DisplayLabel.Value,
|
||||
t => t.Text))
|
||||
}
|
||||
};
|
||||
|
||||
return grid;
|
||||
}
|
||||
}
|
||||
.Setup(i => i.Bind(
|
||||
i,
|
||||
dc => dc.TimelineViewModel.ParallelCommandsGroups[0].Commands,
|
||||
i => i.ItemsSource,
|
||||
v => v))
|
||||
}
|
||||
};
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,13 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.ConsoleUI.App.Controls;
|
||||
using FileTime.ConsoleUI.App.Styling;
|
||||
using FileTime.Core.Enums;
|
||||
using FileTime.Core.Interactions;
|
||||
using TerminalUI;
|
||||
using TerminalUI.Color;
|
||||
using TerminalUI.Controls;
|
||||
using TerminalUI.Extensions;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.Traits;
|
||||
using TerminalUI.ViewExtensions;
|
||||
|
||||
namespace FileTime.ConsoleUI.App;
|
||||
@@ -23,6 +19,7 @@ public class MainWindow
|
||||
private readonly ITheme _theme;
|
||||
private readonly CommandPalette _commandPalette;
|
||||
private readonly Dialogs _dialogs;
|
||||
private readonly Timeline _timeline;
|
||||
private readonly Lazy<IView> _root;
|
||||
|
||||
|
||||
@@ -31,13 +28,15 @@ public class MainWindow
|
||||
IApplicationContext applicationContext,
|
||||
ITheme theme,
|
||||
CommandPalette commandPalette,
|
||||
Dialogs dialogs)
|
||||
Dialogs dialogs,
|
||||
Timeline timeline)
|
||||
{
|
||||
_rootViewModel = rootViewModel;
|
||||
_applicationContext = applicationContext;
|
||||
_theme = theme;
|
||||
_commandPalette = commandPalette;
|
||||
_dialogs = dialogs;
|
||||
_timeline = timeline;
|
||||
_root = new Lazy<IView>(Initialize);
|
||||
}
|
||||
|
||||
@@ -67,7 +66,7 @@ public class MainWindow
|
||||
private Grid<IRootViewModel> MainContent() =>
|
||||
new()
|
||||
{
|
||||
RowDefinitionsObject = "Auto * Auto Auto",
|
||||
RowDefinitionsObject = "Auto * Auto Auto Auto",
|
||||
ChildInitializer =
|
||||
{
|
||||
new Grid<IRootViewModel>
|
||||
@@ -128,27 +127,19 @@ public class MainWindow
|
||||
SelectedsItemsView().WithExtension(new GridPositionExtension(2, 0)),
|
||||
}
|
||||
},
|
||||
new Grid<IRootViewModel>
|
||||
{
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(0, 2)
|
||||
},
|
||||
ChildInitializer =
|
||||
{
|
||||
PossibleCommands()
|
||||
}
|
||||
},
|
||||
new ItemsControl<IRootViewModel, string>
|
||||
{
|
||||
MaxHeight = 5,
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(0, 3)
|
||||
new GridPositionExtension(0, 2)
|
||||
},
|
||||
ItemTemplate = () =>
|
||||
{
|
||||
return new TextBlock<string>()
|
||||
return new TextBlock<string>
|
||||
{
|
||||
Foreground = _theme.WarningForegroundColor
|
||||
}
|
||||
.Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc,
|
||||
@@ -159,7 +150,19 @@ public class MainWindow
|
||||
i,
|
||||
root => root.AppState.PopupTexts,
|
||||
c => c.ItemsSource
|
||||
))
|
||||
)),
|
||||
new Grid<IRootViewModel>
|
||||
{
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(0, 3)
|
||||
},
|
||||
ChildInitializer =
|
||||
{
|
||||
PossibleCommands()
|
||||
}
|
||||
},
|
||||
_timeline.View().WithExtension(new GridPositionExtension(0, 4)),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -341,7 +344,8 @@ public class MainWindow
|
||||
textBlock.Bind(
|
||||
textBlock,
|
||||
dc => dc == null ? _theme.DefaultForegroundColor : ToForegroundColor(dc.ViewMode.Value, dc.BaseItem.Type),
|
||||
tb => tb.Foreground
|
||||
tb => tb.Foreground,
|
||||
v => v
|
||||
);
|
||||
textBlock.Bind(
|
||||
textBlock,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -13,18 +14,21 @@ public class RootViewModel : IRootViewModel
|
||||
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)
|
||||
IDialogService dialogService,
|
||||
ITimelineViewModel timelineViewModel)
|
||||
{
|
||||
AppState = appState;
|
||||
PossibleCommands = possibleCommands;
|
||||
CommandPalette = commandPalette;
|
||||
DialogService = dialogService;
|
||||
TimelineViewModel = timelineViewModel;
|
||||
|
||||
DialogService.ReadInput.PropertyChanged += (o, e) =>
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ public static class Startup
|
||||
services.TryAddSingleton<MainWindow>();
|
||||
services.TryAddSingleton<CommandPalette>();
|
||||
services.TryAddSingleton<Dialogs>();
|
||||
services.TryAddSingleton<Timeline>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user