Move WinUI 3 controls to shared project
このコミットが含まれているのは:
1 親
ff42688483
コミット
ec901922db
10ファイル変更
+42
-4
検索条件に一致するファイルはありません
@@ -0,0 +1,69 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace ComputeSharp.WinUI;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="SwapChainPanel"/> that can be used to render animated backgrounds.
|
||||
/// It is powered by ComputeSharp and leverages compute shaders to create frames to display.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class ComputeShaderPanel : SwapChainPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ComputeShaderPanel"/> instance.
|
||||
/// </summary>
|
||||
public ComputeShaderPanel()
|
||||
{
|
||||
this.Loaded += ComputeShaderPanel_Loaded;
|
||||
this.Unloaded += ComputeShaderPanel_Unloaded;
|
||||
this.SizeChanged += ComputeShaderPanel_SizeChanged;
|
||||
this.CompositionScaleChanged += ComputeShaderPanel_CompositionScaleChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the current <see cref="ComputeShaderPanel"/> instance and releases all resources.
|
||||
/// </summary>
|
||||
~ComputeShaderPanel()
|
||||
{
|
||||
OnDisposed();
|
||||
}
|
||||
|
||||
// Initializes the swap chain and starts the render thread
|
||||
private void ComputeShaderPanel_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.width = (float)ActualWidth;
|
||||
this.height = (float)ActualHeight;
|
||||
this.compositionScaleX = CompositionScaleX;
|
||||
this.compositionScaleY = CompositionScaleY;
|
||||
this.resolutionScale = (float)ResolutionScale;
|
||||
this.targetResolutionScale = 1.0f;
|
||||
this.isDynamicResolutionEnabled = true;
|
||||
|
||||
OnInitialize();
|
||||
OnStartRenderLoop();
|
||||
}
|
||||
|
||||
// Requests a cancellation for the render thread
|
||||
private void ComputeShaderPanel_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OnStopRenderLoop();
|
||||
}
|
||||
|
||||
// Updates the background store for the frame size factors used by the render thread
|
||||
private void ComputeShaderPanel_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
this.width = (float)e.NewSize.Width;
|
||||
this.height = (float)e.NewSize.Height;
|
||||
|
||||
OnResize();
|
||||
}
|
||||
|
||||
// Updates the background store for the composition scale factors used by the render thread
|
||||
private void ComputeShaderPanel_CompositionScaleChanged(SwapChainPanel sender, object args)
|
||||
{
|
||||
this.compositionScaleX = CompositionScaleX;
|
||||
this.compositionScaleY = CompositionScaleY;
|
||||
|
||||
OnResize();
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする