TerminalUI theming, Commands panel
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
using System.Collections.Specialized;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.ConsoleUI.App.Configuration;
|
||||
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 Microsoft.Extensions.Options;
|
||||
using TerminalUI;
|
||||
using TerminalUI.ConsoleDrivers;
|
||||
|
||||
@@ -23,40 +21,36 @@ public class App : IApplication
|
||||
|
||||
private readonly ILifecycleService _lifecycleService;
|
||||
|
||||
private readonly IConsoleAppState _consoleAppState;
|
||||
|
||||
private readonly IAppKeyService<ConsoleKey> _appKeyService;
|
||||
private readonly MainWindow _mainWindow;
|
||||
private readonly IApplicationContext _applicationContext;
|
||||
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;
|
||||
|
||||
public App(
|
||||
ILifecycleService lifecycleService,
|
||||
IKeyInputHandlerService keyInputHandlerService,
|
||||
IConsoleAppState consoleAppState,
|
||||
IAppKeyService<ConsoleKey> appKeyService,
|
||||
MainWindow mainWindow,
|
||||
IApplicationContext applicationContext,
|
||||
IConsoleDriver consoleDriver,
|
||||
IAppState appState,
|
||||
ILogger<App> logger,
|
||||
IServiceProvider serviceProvider)
|
||||
IOptions<ConsoleApplicationConfiguration> consoleApplicationConfiguration,
|
||||
ILogger<App> logger)
|
||||
{
|
||||
_lifecycleService = lifecycleService;
|
||||
_keyInputHandlerService = keyInputHandlerService;
|
||||
_consoleAppState = consoleAppState;
|
||||
_appKeyService = appKeyService;
|
||||
_mainWindow = mainWindow;
|
||||
_applicationContext = applicationContext;
|
||||
_consoleDriver = consoleDriver;
|
||||
_appState = appState;
|
||||
_logger = logger;
|
||||
_serviceProvider = serviceProvider;
|
||||
|
||||
_applicationContext.SupportUtf8Output = !consoleApplicationConfiguration.Value.DisableUtf8;
|
||||
|
||||
_renderThread = new Thread(Render);
|
||||
}
|
||||
@@ -81,12 +75,6 @@ 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
|
||||
|
||||
@@ -1,32 +1,87 @@
|
||||
using FileTime.App.Core.ViewModels.Timeline;
|
||||
using FileTime.ConsoleUI.App.Styling;
|
||||
using TerminalUI.Controls;
|
||||
using TerminalUI.Extensions;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.Styling.Controls;
|
||||
using TerminalUI.ViewExtensions;
|
||||
|
||||
namespace FileTime.ConsoleUI.App.Controls;
|
||||
|
||||
public class Timeline
|
||||
{
|
||||
private readonly IProgressBarTheme? _progressBarTheme;
|
||||
|
||||
public Timeline(ITheme theme)
|
||||
{
|
||||
_progressBarTheme = theme.ConsoleTheme?.ControlThemes.ProgressBar;
|
||||
}
|
||||
|
||||
public IView<IRootViewModel> View()
|
||||
{
|
||||
var root = new Grid<IRootViewModel>
|
||||
{
|
||||
ChildInitializer =
|
||||
{
|
||||
new ItemsControl<IRootViewModel, ICommandTimeStateViewModel>()
|
||||
new ItemsControl<IRootViewModel, ICommandTimeStateViewModel>
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
ItemTemplate = () =>
|
||||
{
|
||||
var grid = new Grid<ICommandTimeStateViewModel>()
|
||||
var grid = new Grid<ICommandTimeStateViewModel>
|
||||
{
|
||||
Margin = "0 0 1 0",
|
||||
Width = 20,
|
||||
RowDefinitionsObject = "Auto Auto",
|
||||
ChildInitializer =
|
||||
{
|
||||
new TextBlock<ICommandTimeStateViewModel>()
|
||||
new Grid<ICommandTimeStateViewModel>
|
||||
{
|
||||
|
||||
}.Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc.DisplayLabel.Value,
|
||||
t => t.Text))
|
||||
ColumnDefinitionsObject = "* Auto",
|
||||
ChildInitializer =
|
||||
{
|
||||
new TextBlock<ICommandTimeStateViewModel>().Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc.DisplayLabel.Value,
|
||||
t => t.Text)),
|
||||
new TextBlock<ICommandTimeStateViewModel>
|
||||
{
|
||||
Width = 5,
|
||||
TextAlignment = TextAlignment.Right,
|
||||
Extensions = {new GridPositionExtension(1, 0)}
|
||||
}.Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc.TotalProgress.Value,
|
||||
t => t.Text,
|
||||
v => $"{v}%")),
|
||||
}
|
||||
},
|
||||
new ProgressBar<ICommandTimeStateViewModel>
|
||||
{
|
||||
Theme = new ProgressBarTheme
|
||||
{
|
||||
ForegroundColor = _progressBarTheme?.ForegroundColor,
|
||||
UnfilledForeground = _progressBarTheme?.UnfilledForeground,
|
||||
FilledCharacter = '\u2594',
|
||||
UnfilledCharacter = '\u2594',
|
||||
Fraction1Per8Character = '\u2594',
|
||||
Fraction2Per8Character = '\u2594',
|
||||
Fraction3Per8Character = '\u2594',
|
||||
Fraction4Per8Character = '\u2594',
|
||||
Fraction5Per8Character = '\u2594',
|
||||
Fraction6Per8Character = '\u2594',
|
||||
Fraction7Per8Character = '\u2594',
|
||||
FractionFull = '\u2594',
|
||||
},
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(0, 1)
|
||||
}
|
||||
}
|
||||
.Setup(p => p.Bind(
|
||||
p,
|
||||
dc => dc.TotalProgress.Value,
|
||||
p => p.Value)),
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user