Add D2D1AnimatedPixelShaderPanel.IsPaused property

このコミットが含まれているのは:
Sergio Pedri committed 2023-01-21 20:43:09 +01:00
1 親 9c7ecdb654
コミット 0c3c16608e
2ファイル変更
+39 -3

検索条件に一致するファイルはありません

+35 -1
ファイルの表示
@@ -79,7 +79,41 @@ public sealed class D2D1AnimatedPixelShaderPanel : Control
// Pause or start the render thread if a runner is available
if (@this.canvasAnimatedControl is { } canvasAnimatedControl)
{
canvasAnimatedControl.Paused = e.NewValue is not ID2D1ShaderRunner;
bool shouldRender = @this.IsLoaded && !@this.IsPaused && shaderRunner is not null;
canvasAnimatedControl.Paused = !shouldRender;
}
}
/// <summary>
/// Gets or sets whether or not the rendering is paused.
/// </summary>
public bool IsPaused
{
get => (bool)GetValue(IsPausedProperty);
set => SetValue(IsPausedProperty, value);
}
/// <summary>
/// The <see cref="DependencyProperty"/> backing <see cref="IsPaused"/>.
/// </summary>
public static readonly DependencyProperty IsPausedProperty = DependencyProperty.Register(
nameof(IsPaused),
typeof(bool),
typeof(D2D1AnimatedPixelShaderPanel),
new PropertyMetadata(false, OnIsPausedPropertyChanged));
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
private static void OnIsPausedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
D2D1AnimatedPixelShaderPanel @this = (D2D1AnimatedPixelShaderPanel)d;
bool isPaused = (bool)e.NewValue;
if (@this.canvasAnimatedControl is { } canvasAnimatedControl)
{
bool shouldRender = @this.IsLoaded && !isPaused && @this.ShaderRunner is ID2D1ShaderRunner;
canvasAnimatedControl.Paused = !shouldRender;
}
}
}
+4 -2
ファイルの表示
@@ -148,7 +148,6 @@
<!-- Shader -->
<computesharp:AnimatedComputeShaderPanel
x:Name="ShaderPanel"
Grid.Row="1"
IsDynamicResolutionEnabled="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=OneWay}"
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"
@@ -158,7 +157,10 @@
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.ShaderRunner, Mode=OneWay}"
Visibility="Collapsed"/>
<views:D2D1AnimatedPixelShaderPanel Grid.Row="1" ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.D2D1ShaderRunner, Mode=OneWay}"/>
<views:D2D1AnimatedPixelShaderPanel
Grid.Row="1"
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.D2D1ShaderRunner, Mode=OneWay}"/>
<!-- Settings panel -->
<StackPanel