From b11fd13913f83b6b035e52622860855716ef1ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Tue, 11 Jul 2023 17:59:29 +0200 Subject: [PATCH] Timeline view animation --- .../Timeline/ParallelCommands.cs | 1 + .../CommandScheduler.cs | 30 +++-- .../FileTime.GuiApp/FileTime.GuiApp.csproj | 3 +- .../FileTime.GuiApp/Views/MainWindow.axaml | 122 ++++++++++++------ 4 files changed, 104 insertions(+), 52 deletions(-) diff --git a/src/Core/FileTime.Core.Abstraction/Timeline/ParallelCommands.cs b/src/Core/FileTime.Core.Abstraction/Timeline/ParallelCommands.cs index 85c90b1..bba72dd 100644 --- a/src/Core/FileTime.Core.Abstraction/Timeline/ParallelCommands.cs +++ b/src/Core/FileTime.Core.Abstraction/Timeline/ParallelCommands.cs @@ -16,6 +16,7 @@ public class ParallelCommands : IDisposable public IObservable> Commands { get; } public BindedCollection CommandsCollection { get; } + public int CommandCount => _commands.Count; public PointInTime? Result { get; private set; } diff --git a/src/Core/FileTime.Core.Timeline/CommandScheduler.cs b/src/Core/FileTime.Core.Timeline/CommandScheduler.cs index 83478f8..cc9bc73 100644 --- a/src/Core/FileTime.Core.Timeline/CommandScheduler.cs +++ b/src/Core/FileTime.Core.Timeline/CommandScheduler.cs @@ -115,18 +115,28 @@ public class CommandScheduler : ICommandScheduler private async void ExecutorOnCommandFinished(object? sender, ICommand command) { - var firstCommandBlock = _commandsToRun - .Items - .FirstOrDefault(); - var state = firstCommandBlock - ?.CommandsCollection - .Collection - ?.FirstOrDefault(c => c.Command == command); + await RunWithLockAsync(async () => + { + var firstCommandBlock = _commandsToRun + .Items + .FirstOrDefault(); + var state = firstCommandBlock + ?.CommandsCollection + .Collection + ?.FirstOrDefault(c => c.Command == command); - if (state is null) return; + if (state is null) return; - state.ExecutionState = ExecutionState.Finished; - if (firstCommandBlock is not null) await firstCommandBlock.RemoveCommand(command); + state.ExecutionState = ExecutionState.Finished; + if (firstCommandBlock is not null) + { + await firstCommandBlock.RemoveCommand(command); + if (firstCommandBlock.CommandCount == 0) + { + _commandsToRun.Remove(firstCommandBlock); + } + } + }); } private async Task RefreshCommands() diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/FileTime.GuiApp.csproj b/src/GuiApp/Avalonia/FileTime.GuiApp/FileTime.GuiApp.csproj index 77da032..c341a5e 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/FileTime.GuiApp.csproj +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/FileTime.GuiApp.csproj @@ -25,8 +25,9 @@ - + + diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml index c047282..5005ddc 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml @@ -1,4 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +