WIP CommandScheduler UI
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using FileTime.App.Core.UserCommand;
|
||||
using FileTime.Core.Timeline;
|
||||
|
||||
namespace FileTime.App.Core.Services.UserCommandHandler;
|
||||
|
||||
public class CommandSchedulerUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
{
|
||||
private readonly ICommandScheduler _commandScheduler;
|
||||
|
||||
public CommandSchedulerUserCommandHandlerService(ICommandScheduler commandScheduler)
|
||||
{
|
||||
_commandScheduler = commandScheduler;
|
||||
AddCommandHandlers(new IUserCommandHandler[]
|
||||
{
|
||||
new TypeUserCommandHandler<PauseCommandSchedulerCommand>(PauseCommandScheduler),
|
||||
new TypeUserCommandHandler<StartCommandSchedulerCommand>(StartCommandScheduler),
|
||||
});
|
||||
}
|
||||
|
||||
private async Task PauseCommandScheduler()
|
||||
=> await _commandScheduler.SetRunningEnabledAsync(false);
|
||||
|
||||
private async Task StartCommandScheduler()
|
||||
=> await _commandScheduler.SetRunningEnabledAsync(true);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
SaveCurrentLocation(l => _currentLocation = l);
|
||||
SaveCurrentSelectedItem(i => _currentSelectedItem = i);
|
||||
|
||||
_markedItems = new BindedCollection<FullName>(appState.SelectedTab.Select(t => t?.MarkedItems));
|
||||
_markedItems = appState.SelectedTab.Select(t => t?.MarkedItems).ToBindedCollection();
|
||||
|
||||
AddCommandHandlers(new IUserCommandHandler[]
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using FileTime.App.Core.Services.UserCommandHandler;
|
||||
using FileTime.App.Core.StartupServices;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.App.Core.ViewModels.ItemPreview;
|
||||
using FileTime.App.Core.ViewModels.Timeline;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
@@ -23,6 +24,7 @@ public static class Startup
|
||||
serviceCollection.TryAddSingleton<IClipboardService, ClipboardService>();
|
||||
serviceCollection.TryAddSingleton<IIdentifiableUserCommandService, IdentifiableUserCommandService>();
|
||||
serviceCollection.TryAddSingleton<IItemPreviewService, ItemPreviewService>();
|
||||
serviceCollection.TryAddSingleton<ITimelineViewModel, TimelineViewModel>();
|
||||
|
||||
return serviceCollection
|
||||
.AddCommandHandlers()
|
||||
@@ -35,6 +37,7 @@ public static class Startup
|
||||
return serviceCollection
|
||||
.AddSingleton<IUserCommandHandler, NavigationUserCommandHandlerService>()
|
||||
.AddSingleton<IUserCommandHandler, ItemManipulationUserCommandHandlerService>()
|
||||
.AddSingleton<IUserCommandHandler, ToolUserCommandHandlerService>();
|
||||
.AddSingleton<IUserCommandHandler, ToolUserCommandHandlerService>()
|
||||
.AddSingleton<IUserCommandHandler, CommandSchedulerUserCommandHandlerService>();
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,9 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
||||
AddUserCommand(PasteCommand.Merge);
|
||||
AddUserCommand(PasteCommand.Overwrite);
|
||||
AddUserCommand(PasteCommand.Skip);
|
||||
AddUserCommand(PauseCommandSchedulerCommand.Instance);
|
||||
AddUserCommand(RefreshCommand.Instance);
|
||||
AddUserCommand(StartCommandSchedulerCommand.Instance);
|
||||
AddUserCommand(SwitchToTabCommand.SwitchToLastTab);
|
||||
AddUserCommand(SwitchToTabCommand.SwitchToTab1);
|
||||
AddUserCommand(SwitchToTabCommand.SwitchToTab2);
|
||||
|
||||
@@ -3,12 +3,14 @@ using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.ViewModels.Timeline;
|
||||
using MvvmGen;
|
||||
using MoreLinq;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
[ViewModel]
|
||||
[Inject(typeof(ITimelineViewModel), "TimelineViewModel", PropertyAccessModifier = AccessModifier.Public)]
|
||||
public abstract partial class AppStateBase : IAppState
|
||||
{
|
||||
private readonly BehaviorSubject<string?> _searchText = new(null);
|
||||
@@ -76,7 +78,10 @@ public abstract partial class AppStateBase : IAppState
|
||||
|
||||
private ITabViewModel? GetSelectedTab(IEnumerable<ITabViewModel> tabs, ITabViewModel? expectedSelectedTab)
|
||||
{
|
||||
var (preferred, others) = tabs.OrderBy(t => t.TabNumber).Partition(t => t.TabNumber >= (expectedSelectedTab?.TabNumber ?? 0));
|
||||
var (preferred, others) =
|
||||
tabs
|
||||
.OrderBy(t => t.TabNumber)
|
||||
.Partition(t => t.TabNumber >= (expectedSelectedTab?.TabNumber ?? 0));
|
||||
return preferred.Concat(others.Reverse()).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Reactive.Subjects;
|
||||
using FileTime.Core.Timeline;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels.Timeline;
|
||||
|
||||
public class CommandTimeStateViewModel : ICommandTimeStateViewModel
|
||||
{
|
||||
public IObservable<int> TotalProgress { get; }
|
||||
|
||||
public IObservable<string> DisplayLabel { get; }
|
||||
|
||||
public IObservable<bool> IsSelected { get; }
|
||||
|
||||
public CommandTimeStateViewModel(CommandTimeState commandTimeState)
|
||||
{
|
||||
DisplayLabel = commandTimeState.Command.DisplayLabel;
|
||||
TotalProgress = commandTimeState.Command.TotalProgress;
|
||||
//TODO
|
||||
IsSelected = new BehaviorSubject<bool>(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using DynamicData.Alias;
|
||||
using FileTime.Core.Extensions;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Timeline;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels.Timeline;
|
||||
|
||||
public class ParallelCommandsViewModel : IParallelCommandsViewModel
|
||||
{
|
||||
public BindedCollection<ICommandTimeStateViewModel> Commands { get; }
|
||||
|
||||
public ParallelCommandsViewModel(ParallelCommands parallelCommands)
|
||||
{
|
||||
Commands = parallelCommands
|
||||
.Commands
|
||||
.Select(c => new CommandTimeStateViewModel(c) as ICommandTimeStateViewModel)
|
||||
.ToBindedCollection();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using DynamicData.Alias;
|
||||
using FileTime.Core.Extensions;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Timeline;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels.Timeline;
|
||||
|
||||
public class TimelineViewModel : ITimelineViewModel
|
||||
{
|
||||
public BindedCollection<IParallelCommandsViewModel> ParallelCommandsGroups { get; }
|
||||
|
||||
public TimelineViewModel(ICommandScheduler commandScheduler)
|
||||
{
|
||||
ParallelCommandsGroups =
|
||||
commandScheduler
|
||||
.CommandsToRun
|
||||
.Select(p => new ParallelCommandsViewModel(p) as IParallelCommandsViewModel)
|
||||
.ToBindedCollection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user