WIP CommandScheduler UI

This commit is contained in:
2023-01-31 23:26:36 +01:00
parent 06a9fc27d7
commit 30ecc6e515
37 changed files with 553 additions and 181 deletions

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}