Controls, Startup&Driver improvements
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using FileTime.App.Core.Models;
|
||||
using System.Collections.Specialized;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.ConsoleUI.App.KeyInputHandling;
|
||||
using TerminalUI;
|
||||
using TerminalUI.ConsoleDrivers;
|
||||
@@ -16,6 +18,7 @@ public class App : IApplication
|
||||
private readonly MainWindow _mainWindow;
|
||||
private readonly IApplicationContext _applicationContext;
|
||||
private readonly IConsoleDriver _consoleDriver;
|
||||
private readonly IAppState _appState;
|
||||
private readonly IKeyInputHandlerService _keyInputHandlerService;
|
||||
private readonly Thread _renderThread;
|
||||
|
||||
@@ -26,7 +29,8 @@ public class App : IApplication
|
||||
IAppKeyService<ConsoleKey> appKeyService,
|
||||
MainWindow mainWindow,
|
||||
IApplicationContext applicationContext,
|
||||
IConsoleDriver consoleDriver)
|
||||
IConsoleDriver consoleDriver,
|
||||
IAppState appState)
|
||||
{
|
||||
_lifecycleService = lifecycleService;
|
||||
_keyInputHandlerService = keyInputHandlerService;
|
||||
@@ -35,6 +39,7 @@ public class App : IApplication
|
||||
_mainWindow = mainWindow;
|
||||
_applicationContext = applicationContext;
|
||||
_consoleDriver = consoleDriver;
|
||||
_appState = appState;
|
||||
|
||||
_renderThread = new Thread(Render);
|
||||
}
|
||||
@@ -43,6 +48,12 @@ public class App : IApplication
|
||||
{
|
||||
Task.Run(async () => await _lifecycleService.InitStartupHandlersAsync()).Wait();
|
||||
|
||||
((INotifyCollectionChanged) _appState.Tabs).CollectionChanged += (_, _) =>
|
||||
{
|
||||
if(_appState.Tabs.Count == 0)
|
||||
_applicationContext.IsRunning = false;
|
||||
};
|
||||
|
||||
_mainWindow.Initialize();
|
||||
foreach (var rootView in _mainWindow.RootViews())
|
||||
{
|
||||
@@ -66,6 +77,7 @@ public class App : IApplication
|
||||
_keyInputHandlerService.HandleKeyInput(keyEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.App.Core.ViewModels.Timeline;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.ConsoleUI.App;
|
||||
|
||||
public class ConsoleAppState : AppStateBase, IConsoleAppState
|
||||
public partial class ConsoleAppState : AppStateBase, IConsoleAppState
|
||||
{
|
||||
[Notify] private string? _errorText;
|
||||
}
|
||||
@@ -12,6 +12,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="PropertyChanged.SourceGenerator" Version="1.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Serilog" Version="3.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace FileTime.ConsoleUI.App;
|
||||
|
||||
public class MainConsoleConfiguration
|
||||
{
|
||||
public static Dictionary<string, string?> Configuration { get; }
|
||||
static MainConsoleConfiguration()
|
||||
{
|
||||
Configuration = new();
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,12 @@ using DeclarativeProperty;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using TerminalUI;
|
||||
using TerminalUI.Color;
|
||||
using TerminalUI.Controls;
|
||||
using TerminalUI.Extensions;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.ViewExtensions;
|
||||
using ConsoleColor = TerminalUI.Color.ConsoleColor;
|
||||
|
||||
namespace FileTime.ConsoleUI.App;
|
||||
|
||||
@@ -17,6 +20,8 @@ public class MainWindow
|
||||
private readonly ITheme _theme;
|
||||
private ListView<IAppState, IItemViewModel> _selectedItemsView;
|
||||
|
||||
private Grid<object> _grid;
|
||||
|
||||
public MainWindow(
|
||||
IConsoleAppState consoleAppState,
|
||||
IApplicationContext applicationContext,
|
||||
@@ -56,9 +61,69 @@ public class MainWindow
|
||||
_selectedItemsView,
|
||||
appState => appState == null ? null : appState.SelectedTab.Map(t => t == null ? null : t.CurrentItems).Switch(),
|
||||
v => v.ItemsSource);
|
||||
|
||||
TestGrid();
|
||||
}
|
||||
|
||||
public IEnumerable<IView> RootViews() => new IView[] {_selectedItemsView};
|
||||
private void TestGrid()
|
||||
{
|
||||
var grid = new Grid<object>
|
||||
{
|
||||
ApplicationContext = _applicationContext,
|
||||
ColumnDefinitionsObject = "Auto Auto",
|
||||
RowDefinitionsObject = "Auto Auto",
|
||||
ChildInitializer =
|
||||
{
|
||||
new Rectangle<object>
|
||||
{
|
||||
Fill = new ConsoleColor(System.ConsoleColor.Blue, ColorType.Foreground),
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(0, 0)
|
||||
},
|
||||
Width = 2,
|
||||
Height = 2,
|
||||
},
|
||||
new Rectangle<object>
|
||||
{
|
||||
Fill = new ConsoleColor(System.ConsoleColor.Red, ColorType.Foreground),
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(0, 1)
|
||||
},
|
||||
Width = 3,
|
||||
Height = 3,
|
||||
},
|
||||
new Rectangle<object>
|
||||
{
|
||||
Fill = new ConsoleColor(System.ConsoleColor.Green, ColorType.Foreground),
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(1, 0)
|
||||
},
|
||||
Width = 4,
|
||||
Height = 4,
|
||||
},
|
||||
new Rectangle<object>
|
||||
{
|
||||
Fill = new ConsoleColor(System.ConsoleColor.Yellow, ColorType.Foreground),
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(1, 1)
|
||||
},
|
||||
Width = 5,
|
||||
Height = 5,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_grid = grid;
|
||||
}
|
||||
|
||||
public IEnumerable<IView> RootViews() => new IView[]
|
||||
{
|
||||
_grid, _selectedItemsView
|
||||
};
|
||||
|
||||
private IColor? ToForegroundColor(ItemViewMode viewMode)
|
||||
=> viewMode switch
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.Configuration;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.ConsoleUI.App.Configuration;
|
||||
using FileTime.ConsoleUI.App.KeyInputHandling;
|
||||
using FileTime.ConsoleUI.App.Services;
|
||||
using FileTime.Core.Interactions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using TerminalUI;
|
||||
@@ -12,7 +15,7 @@ namespace FileTime.ConsoleUI.App;
|
||||
|
||||
public static class Startup
|
||||
{
|
||||
public static IServiceCollection AddConsoleServices(this IServiceCollection services)
|
||||
public static IServiceCollection AddConsoleServices(this IServiceCollection services, IConfigurationRoot configuration)
|
||||
{
|
||||
services.TryAddSingleton<IApplication, App>();
|
||||
services.TryAddSingleton<MainWindow>();
|
||||
@@ -23,6 +26,9 @@ public static class Startup
|
||||
services.TryAddSingleton<IAppKeyService<ConsoleKey>, ConsoleAppKeyService>();
|
||||
services.TryAddSingleton<ISystemClipboardService, ConsoleSystemClipboardService>();
|
||||
services.AddSingleton<CustomLoggerSink>();
|
||||
services.TryAddSingleton(new ApplicationConfiguration(true));
|
||||
|
||||
services.Configure<ConsoleApplicationConfiguration>(configuration);
|
||||
|
||||
services.TryAddSingleton<IApplicationContext>(sp
|
||||
=> new ApplicationContext
|
||||
|
||||
Reference in New Issue
Block a user