Timeline view animation

This commit is contained in:
2023-07-11 17:59:29 +02:00
parent b1898e1120
commit b11fd13913
4 changed files with 104 additions and 52 deletions

View File

@@ -16,6 +16,7 @@ public class ParallelCommands : IDisposable
public IObservable<IChangeSet<CommandTimeState>> Commands { get; } public IObservable<IChangeSet<CommandTimeState>> Commands { get; }
public BindedCollection<CommandTimeState> CommandsCollection { get; } public BindedCollection<CommandTimeState> CommandsCollection { get; }
public int CommandCount => _commands.Count;
public PointInTime? Result { get; private set; } public PointInTime? Result { get; private set; }

View File

@@ -115,18 +115,28 @@ public class CommandScheduler : ICommandScheduler
private async void ExecutorOnCommandFinished(object? sender, ICommand command) private async void ExecutorOnCommandFinished(object? sender, ICommand command)
{ {
var firstCommandBlock = _commandsToRun await RunWithLockAsync(async () =>
.Items {
.FirstOrDefault(); var firstCommandBlock = _commandsToRun
var state = firstCommandBlock .Items
?.CommandsCollection .FirstOrDefault();
.Collection var state = firstCommandBlock
?.FirstOrDefault(c => c.Command == command); ?.CommandsCollection
.Collection
?.FirstOrDefault(c => c.Command == command);
if (state is null) return; if (state is null) return;
state.ExecutionState = ExecutionState.Finished; state.ExecutionState = ExecutionState.Finished;
if (firstCommandBlock is not null) await firstCommandBlock.RemoveCommand(command); if (firstCommandBlock is not null)
{
await firstCommandBlock.RemoveCommand(command);
if (firstCommandBlock.CommandCount == 0)
{
_commandsToRun.Remove(firstCommandBlock);
}
}
});
} }
private async Task RefreshCommands() private async Task RefreshCommands()

View File

@@ -25,8 +25,9 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0" /> <PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.0.0-rc1.1" /> <PackageReference Include="Avalonia.Svg.Skia" Version="11.0.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" /> <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="MvvmGen" Version="1.2.1" /> <PackageReference Include="MvvmGen" Version="1.2.1" />

View File

@@ -1,4 +1,4 @@
<Window <Window
Background="Transparent" Background="Transparent"
Closed="OnWindowClosed" Closed="OnWindowClosed"
ExtendClientAreaToDecorationsHint="True" ExtendClientAreaToDecorationsHint="True"
@@ -23,6 +23,8 @@
xmlns:config="using:FileTime.GuiApp.Configuration" xmlns:config="using:FileTime.GuiApp.Configuration"
xmlns:corevm="using:FileTime.App.Core.ViewModels" xmlns:corevm="using:FileTime.App.Core.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
xmlns:interactions="using:FileTime.Core.Interactions" xmlns:interactions="using:FileTime.Core.Interactions"
xmlns:local="using:FileTime.GuiApp.Views" xmlns:local="using:FileTime.GuiApp.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -258,46 +260,84 @@
Grid.Row="1" Grid.Row="1"
RowDefinitions="Auto,40,*,Auto"> RowDefinitions="Auto,40,*,Auto">
<Grid> <Grid x:Name="CommandGroupsContainer">
<ItemsControl ItemsSource="{Binding AppState.TimelineViewModel.ParallelCommandsGroups.Collection}"> <Grid.Transitions>
<ItemsControl.ItemsPanel> <Transitions>
<ItemsPanelTemplate> <DoubleTransition Duration="0:0:.2" Property="Height" />
<StackPanel Orientation="Horizontal" /> </Transitions>
</ItemsPanelTemplate> </Grid.Transitions>
</ItemsControl.ItemsPanel> <i:Interaction.Behaviors>
<ItemsControl.ItemTemplate> <ia:DataTriggerBehavior
<DataTemplate> Binding="{Binding #CommandGroups.ItemCount}"
<Border ComparisonCondition="GreaterThan"
Background="{DynamicResource ContainerBackgroundColor}" Value="0">
CornerRadius="10" <ia:ChangePropertyAction
Margin="0,0,10,0" PropertyName="Height"
MaxHeight="200" TargetObject="CommandGroupsContainer"
Padding="5"> Value="180" />
<ScrollViewer> </ia:DataTriggerBehavior>
<ItemsControl ItemsSource="{Binding Commands.Collection}"> <ia:DataTriggerBehavior
<ItemsControl.ItemTemplate> Binding="{Binding #CommandGroups.ItemCount}"
<DataTemplate> ComparisonCondition="LessThanOrEqual"
<Border BorderThickness="1" Classes.SelectedTimelineCommand="{Binding IsSelected}"> Value="0">
<StackPanel> <ia:ChangePropertyAction
<TextBlock Text="{Binding DisplayLabel^}" /> PropertyName="Height"
<ProgressBar TargetObject="CommandGroupsContainer"
Margin="0,5,0,0" Value="0" />
Maximum="100" </ia:DataTriggerBehavior>
Value="{Binding CurrentProgress^}" /> </i:Interaction.Behaviors>
<ProgressBar <Grid ColumnDefinitions="Auto,10">
Margin="0,5,0,0" <ItemsControl
Maximum="100" ItemsSource="{Binding AppState.TimelineViewModel.ParallelCommandsGroups.Collection}"
Value="{Binding TotalProgress^}" /> VerticalAlignment="Top"
</StackPanel> x:Name="CommandGroups">
</Border> <ItemsControl.ItemsPanel>
</DataTemplate> <ItemsPanelTemplate>
</ItemsControl.ItemTemplate> <StackPanel Orientation="Horizontal" />
</ItemsControl> </ItemsPanelTemplate>
</ScrollViewer> </ItemsControl.ItemsPanel>
</Border> <ItemsControl.ItemTemplate>
</DataTemplate> <DataTemplate>
</ItemsControl.ItemTemplate> <Border
</ItemsControl> Background="{DynamicResource ContainerBackgroundColor}"
CornerRadius="10"
Height="50"
Margin="0,0,10,0"
Padding="5">
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Commands.Collection}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderThickness="1" Classes.SelectedTimelineCommand="{Binding IsSelected}">
<StackPanel>
<TextBlock Text="{Binding DisplayLabel^}" />
<ProgressBar
Margin="0,5,0,0"
Maximum="100"
Value="{Binding CurrentProgress^}" />
<ProgressBar
Margin="0,5,0,0"
Maximum="100"
Value="{Binding TotalProgress^}" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Rectangle
Fill="{DynamicResource ContentSeparatorBrush}"
Grid.Column="1"
HorizontalAlignment="Center"
Margin="0,10,0,10"
VerticalAlignment="Stretch"
Width="1" />
</Grid>
</Grid> </Grid>
<ItemsControl Grid.Row="1" ItemsSource="{Binding AppState.Tabs}"> <ItemsControl Grid.Row="1" ItemsSource="{Binding AppState.Tabs}">