Update UWP sample with shared files

このコミットが含まれているのは:
Sergio Pedri committed 2024-12-21 12:27:20 +01:00
1 親 93538b190f
コミット 282798d803
23ファイル変更
+487 -49

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

+3
ファイルの表示
@@ -636,6 +636,9 @@ Global
src\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems*{54654960-54b5-4e19-b3ed-993591ca39e5}*SharedItemsImports = 5
src\ComputeSharp.D2D1.UI.SourceGenerators\ComputeSharp.D2D1.UI.SourceGenerators.projitems*{690c4014-a06b-44db-b717-aea4cafa9d68}*SharedItemsImports = 5
src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{690c4014-a06b-44db-b717-aea4cafa9d68}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders.D2D1\ComputeSharp.SwapChain.Shaders.D2D1.projitems*{6a861d53-2dbd-4b4f-8543-90dc8c0f2dc8}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders\ComputeSharp.SwapChain.Shaders.projitems*{6a861d53-2dbd-4b4f-8543-90dc8c0f2dc8}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.UI\ComputeSharp.SwapChain.UI.projitems*{6a861d53-2dbd-4b4f-8543-90dc8c0f2dc8}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.UI\ComputeSharp.SwapChain.UI.projitems*{6bc471c6-72f9-43cf-ae1e-f6d3e5ed3129}*SharedItemsImports = 13
src\ComputeSharp.D2D1.UI\ComputeSharp.D2D1.UI.projitems*{716df19e-69ba-4a9c-9ca4-bfd196152f46}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders.D2D1\ComputeSharp.SwapChain.Shaders.D2D1.projitems*{73c32d0f-64db-4674-84e9-8fcc41228474}*SharedItemsImports = 5
+9
ファイルの表示
@@ -1,10 +1,19 @@
using ComputeSharp.SwapChain.Core.Shaders;
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.UI.Xaml;
#if WINDOWS_UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
#else
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
#endif
#if WINDOWS_UWP
namespace ComputeSharp.SwapChain.Uwp.Views;
#else
namespace ComputeSharp.SwapChain.WinUI.Views;
#endif
/// <summary>
/// A custom <see cref="Control"/> that can be used to render animated backgrounds via Win2D.
+4
ファイルの表示
@@ -1,4 +1,8 @@
#if WINDOWS_UWP
using Windows.UI.Xaml.Controls;
#else
using Microsoft.UI.Xaml.Controls;
#endif
namespace ComputeSharp.SwapChain.Core.Converters;
+4
ファイルの表示
@@ -1,7 +1,11 @@
using System;
using ComputeSharp.D2D1;
using ComputeSharp.D2D1.Descriptors;
#if WINDOWS_UWP
using ComputeSharp.D2D1.Uwp;
#else
using ComputeSharp.D2D1.WinUI;
#endif
namespace ComputeSharp.SwapChain.Core.Shaders;
+4
ファイルの表示
@@ -1,7 +1,11 @@
using System;
using System.IO;
using ComputeSharp.SwapChain.Shaders;
#if WINDOWS_UWP
using ComputeSharp.Uwp;
#else
using ComputeSharp.WinUI;
#endif
using Windows.ApplicationModel;
namespace ComputeSharp.SwapChain.Core.Shaders.Runners;
+4
ファイルの表示
@@ -2,7 +2,11 @@ using System;
using System.IO;
using ComputeSharp.D2D1;
using ComputeSharp.D2D1.Interop;
#if WINDOWS_UWP
using ComputeSharp.D2D1.Uwp;
#else
using ComputeSharp.D2D1.WinUI;
#endif
using ComputeSharp.SwapChain.Shaders.D2D1;
using Windows.ApplicationModel;
+4
ファイルの表示
@@ -5,7 +5,11 @@ using ComputeSharp.SwapChain.Core.Enums;
using ComputeSharp.SwapChain.Core.Shaders;
using ComputeSharp.SwapChain.Core.Shaders.Runners;
using ComputeSharp.SwapChain.Shaders;
#if WINDOWS_UWP
using ComputeSharp.Uwp;
#else
using ComputeSharp.WinUI;
#endif
#pragma warning disable IDE0300 // CsWinRT does not support marshalling collection expression (https://github.com/microsoft/CsWinRT/issues/1661)
+4
ファイルの表示
@@ -1,6 +1,10 @@
using CommunityToolkit.Mvvm.ComponentModel;
using ComputeSharp.SwapChain.Core.Shaders;
#if WINDOWS_UWP
using ComputeSharp.Uwp;
#else
using ComputeSharp.WinUI;
#endif
namespace ComputeSharp.SwapChain.Core.ViewModels;
+11 -5
ファイルの表示
@@ -1,7 +1,13 @@
<Application
<Application
x:Class="ComputeSharp.SwapChain.Uwp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ComputeSharp.SwapChain.Uwp">
</Application>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="Controls/D2D1AnimatedPixelShaderPanel.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
+42 -16
ファイルの表示
@@ -1,6 +1,9 @@
using ComputeSharp.SwapChain.Uwp.Views;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace ComputeSharp.SwapChain.Uwp;
@@ -10,7 +13,7 @@ namespace ComputeSharp.SwapChain.Uwp;
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
@@ -21,26 +24,49 @@ sealed partial class App : Application
/// <inheritdoc/>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// Initialize the frame if needed
if (Window.Current.Content is not Frame rootFrame)
if (Window.Current.Content is not MainView)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
StyleTitleBar();
ExpandViewIntoTitleBar();
// Place the frame in the current Window
Window.Current.Content = rootFrame;
Window.Current.Content = new MainView();
}
if (!e.PrelaunchActivated)
{
if (rootFrame.Content is null)
{
// Navigate to the root page
_ = rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}
}
/// <summary>
/// Styles the title bar buttons according to the theme in use
/// </summary>
private static void StyleTitleBar()
{
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
// Transparent colors
titleBar.ForegroundColor = Colors.Transparent;
titleBar.BackgroundColor = Colors.Transparent;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.InactiveBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
// Theme aware colors
titleBar.ButtonForegroundColor = titleBar.ButtonHoverForegroundColor = titleBar.ButtonPressedForegroundColor = Colors.White;
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(0x20, 0xFF, 0xFF, 0xFF);
titleBar.ButtonPressedBackgroundColor = Color.FromArgb(0x40, 0xFF, 0xFF, 0xFF);
titleBar.ButtonInactiveForegroundColor = Color.FromArgb(0xC0, 0xFF, 0xFF, 0xFF);
titleBar.InactiveForegroundColor = Color.FromArgb(0xA0, 0xA0, 0xA0, 0xA0);
}
/// <summary>
/// Sets up the app UI to be expanded into the title bar
/// </summary>
private static void ExpandViewIntoTitleBar()
{
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
}
}
バイナリファイルは表示されません。

変更前

幅:  |  高さ:  |  サイズ: 1.4 KiB

バイナリファイルは表示されません。

変更前

幅:  |  高さ:  |  サイズ: 7.5 KiB

バイナリファイルは表示されません。

変更前

幅:  |  高さ:  |  サイズ: 2.9 KiB

バイナリファイルは表示されません。

変更前

幅:  |  高さ:  |  サイズ: 1.6 KiB

バイナリファイルは表示されません。

変更前

幅:  |  高さ:  |  サイズ: 1.2 KiB

バイナリファイルは表示されません。

変更前

幅:  |  高さ:  |  サイズ: 1.4 KiB

バイナリファイルは表示されません。

変更前

幅:  |  高さ:  |  サイズ: 3.1 KiB

+43
ファイルの表示
@@ -8,16 +8,59 @@
<UseUwpTools>true</UseUwpTools>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>
<DefaultLanguage>en-US</DefaultLanguage>
<PublishAot>true</PublishAot>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<EnableMsixTooling>true</EnableMsixTooling>
<!-- Disable 'INotifyPropertyChanging' support, same as in the WinUI 3 sample app -->
<MvvmToolkitEnableINotifyPropertyChangingSupport>false</MvvmToolkitEnableINotifyPropertyChangingSupport>
</PropertyGroup>
<!-- Same CsWinRT options as the WinUI 3 sample app -->
<PropertyGroup>
<CsWinRTGenerateProjection>false</CsWinRTGenerateProjection>
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
<CsWinRTAotWarningLevel>2</CsWinRTAotWarningLevel>
</PropertyGroup>
<!-- CsWinRT size saving options -->
<PropertyGroup>
<CsWinRTEnableDynamicObjectsSupport>false</CsWinRTEnableDynamicObjectsSupport>
<CsWinRTUseExceptionResourceKeys>true</CsWinRTUseExceptionResourceKeys>
</PropertyGroup>
<!-- NativeAOT options -->
<PropertyGroup>
<PublishAot>true</PublishAot>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<InvariantGlobalization>true</InvariantGlobalization>
<StackTraceSupport>false</StackTraceSupport>
<OptimizationPreference>Speed</OptimizationPreference>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="CommunityToolkit.Uwp.Controls.Primitives" Version="8.2.240924-local" />
<PackageReference Include="CommunityToolkit.Uwp.Media" Version="8.2.240924-local" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.3" />
<!-- Temporary workaround, see notes in D2D1 UWP sample app -->
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2739.15" IncludeAssets="none" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.Uwp\ComputeSharp.D2D1.Uwp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1\ComputeSharp.D2D1.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
<ProjectReference Include="..\..\src\ComputeSharp.Uwp\ComputeSharp.Uwp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
</ItemGroup>
<!-- Shared projects for the DX12/D2D1 shaders and the app backend -->
<Import Project="..\ComputeSharp.SwapChain.Shaders\ComputeSharp.SwapChain.Shaders.projitems" Label="Shared" />
<Import Project="..\ComputeSharp.SwapChain.Shaders.D2D1\ComputeSharp.SwapChain.Shaders.D2D1.projitems" Label="Shared" />
<Import Project="..\ComputeSharp.SwapChain.UI\ComputeSharp.SwapChain.UI.projitems" Label="Shared" />
</Project>
+16
ファイルの表示
@@ -0,0 +1,16 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ComputeSharp.SwapChain.Uwp.Views"
xmlns:win2d="using:Microsoft.Graphics.Canvas.UI.Xaml">
<Style TargetType="local:D2D1AnimatedPixelShaderPanel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:D2D1AnimatedPixelShaderPanel">
<win2d:CanvasAnimatedControl x:Name="PART_CanvasAnimatedControl" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
-14
ファイルの表示
@@ -1,14 +0,0 @@
<Page
x:Class="ComputeSharp.SwapChain.Uwp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ComputeSharp.SwapChain.Uwp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
</Grid>
</Page>
-14
ファイルの表示
@@ -1,14 +0,0 @@
using Windows.UI.Xaml.Controls;
namespace ComputeSharp.SwapChain.Uwp;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
}
}
+289
ファイルの表示
@@ -0,0 +1,289 @@
<UserControl
x:Class="ComputeSharp.SwapChain.Uwp.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
xmlns:computesharp="using:ComputeSharp.Uwp"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters"
xmlns:enums="using:ComputeSharp.SwapChain.Core.Enums"
xmlns:media="using:CommunityToolkit.WinUI.Media"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:viewModels="using:ComputeSharp.SwapChain.Core.ViewModels"
xmlns:views="using:ComputeSharp.SwapChain.Uwp.Views"
SizeChanged="UserControl_SizeChanged">
<Grid x:Name="Root">
<Grid.DataContext>
<viewModels:MainViewModel x:Name="ViewModel"/>
</Grid.DataContext>
<Grid.Resources>
<!--
Shader selection panel. This is declared as a resource and then added and removed to the visual
tree entirely instead of just changing its visibility, so that the loaded panels can detect the
change and stop their render loops. This avoids wasting GPU resources when the panel isn't visible.
-->
<Border
x:Key="ShaderSelectionPanel"
x:Name="ShaderSelectionPanel"
IsTapEnabled="True"
Tapped="ShaderSelectionPanel_Tapped">
<animations:Implicit.ShowAnimations>
<animations:OpacityAnimation
From="0"
To="1.0"
Duration="0:0:0.5" />
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:OpacityAnimation
From="1.0"
To="0"
Duration="0:0:0.5" />
</animations:Implicit.HideAnimations>
<Border.Background>
<media:AcrylicBrush
BlurAmount="12"
TextureUri="ms-appx:///Assets/Misc/noise_low.png"
TintColor="#FF222222"
TintOpacity="0.2" />
</Border.Background>
<!-- Shadow panel with the shaders list -->
<Border
x:Name="ShadersListContainerPanel"
Height="320"
Margin="-20,0,-20,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Background="#FF222222">
<animations:Implicit.ShowAnimations>
<animations:TranslationAnimation
From="0,320,0"
To="0"
Duration="0:0:0.5" />
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:TranslationAnimation
From="0"
To="0,320,0"
Duration="0:0:0.5" />
</animations:Implicit.HideAnimations>
<ui:Effects.Shadow>
<media:AttachedCardShadow
BlurRadius="20"
CornerRadius="0"
Opacity="1"
Offset="-12,-2"
Color="Black" />
</ui:Effects.Shadow>
<!-- Shaders list -->
<ListView
ItemsSource="{x:Bind ViewModel.ComputeShaderOptions}"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollMode="Disabled"
SelectedItem="{x:Bind ViewModel.SelectedComputeShader, Mode=TwoWay}"
SelectionMode="Single">
<ListView.Resources>
<!--
Lightweight styling to remove the selection background with the accent color, and
to remove the padding and stretch the list items to occupy all the available space
-->
<SolidColorBrush x:Key="ListViewItemBackgroundSelected" Color="Transparent" />
<SolidColorBrush x:Key="ListViewItemBackgroundSelectedPointerOver" Color="Transparent" />
<SolidColorBrush x:Key="ListViewItemBackgroundSelectedPressed" Color="Transparent" />
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
</Style>
</ListView.Resources>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<!-- Shader template -->
<DataTemplate x:DataType="viewModels:ShaderRunnerViewModel">
<controls:ConstrainedBox
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ui:UIElementExtensions.ClipToBounds="True"
AspectRatio="16:9">
<Grid>
<!-- Shader preview -->
<computesharp:AnimatedComputeShaderPanel RenderingFailed="SelectionShaderPanel_RenderingFailed" ShaderRunner="{x:Bind ShaderRunner}" />
<!--
Note: here we have a selection property to work around {x:Bind} not working correctly outside of the
current template scope. Once that's fixed in WinUI 3, this can be rewritten as a multi-binding like this:
Visibility="{x:Bind system:Object.ReferenceEquals((local:ComputeShader), ViewModel.SelectedComputeShader), Mode=OneWay}".
When that is working, the ComputeShader.IsSelected property can also be removed, as it will no longer be needed.
-->
<Border
BorderBrush="White"
BorderThickness="4"
Visibility="{x:Bind IsSelected, Mode=OneWay}">
<Polygon
HorizontalAlignment="Right"
VerticalAlignment="Top"
Fill="White"
Points="0,0 32,0 32,32" />
</Border>
</Grid>
</controls:ConstrainedBox>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Border>
</Grid.Resources>
<!-- Shader switches (for DirectX 12 or Win2D) -->
<controls:SwitchPresenter Grid.Row="1" Value="{x:Bind ViewModel.SelectedRenderingMode, Mode=OneWay}">
<controls:Case IsDefault="True" Value="{x:Bind enums:RenderingMode.DirectX12}">
<!-- DirectX 12 shader -->
<computesharp:AnimatedComputeShaderPanel
IsDynamicResolutionEnabled="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=OneWay}"
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"
IsVerticalSyncEnabled="{x:Bind ViewModel.IsVerticalSyncEnabled, Mode=OneWay}"
RenderingFailed="MainShaderPanel_RenderingFailed"
ResolutionScale="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToScale(ViewModel.SelectedResolutionScale), Mode=OneWay}"
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.ShaderRunner, Mode=OneWay}" />
</controls:Case>
<controls:Case Value="{x:Bind enums:RenderingMode.Win2D}">
<!-- Win2D shader -->
<views:D2D1AnimatedPixelShaderPanel IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}" PixelShaderEffect="{x:Bind ViewModel.SelectedComputeShader.PixelShaderEffect, Mode=OneWay}" />
</controls:Case>
</controls:SwitchPresenter>
<!-- Settings panel -->
<StackPanel
Margin="48"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Orientation="Horizontal"
Spacing="20">
<!-- Shader pause button -->
<Button
Padding="20"
Command="{x:Bind ViewModel.ToggleRenderingPausedCommand}"
CornerRadius="9999"
ToolTipService.ToolTip="Select shader">
<SymbolIcon Symbol="{x:Bind converters:RenderingPauseConverter.ConvertPausedToSymbol(ViewModel.IsRenderingPaused), Mode=OneWay}" />
</Button>
<!-- Shader selection button -->
<Button
Padding="20"
Click="OpenShaderSelectionPanelButton_Click"
CornerRadius="9999"
ToolTipService.ToolTip="Select shader">
<SymbolIcon Symbol="Pictures" />
</Button>
<!-- Settings button -->
<Button
Padding="20"
CornerRadius="9999"
ToolTipService.ToolTip="Settings">
<SymbolIcon Symbol="Setting" />
<Button.Flyout>
<MenuFlyout>
<ToggleMenuFlyoutItem
Command="{x:Bind ViewModel.SetRenderingModeCommand}"
CommandParameter="{x:Bind enums:RenderingMode.DirectX12}"
IsChecked="{x:Bind ViewModel.SelectedRenderingMode.Equals(enums:RenderingMode.DirectX12), Mode=OneWay}"
Text="DirectX 12" />
<ToggleMenuFlyoutItem
Command="{x:Bind ViewModel.SetRenderingModeCommand}"
CommandParameter="{x:Bind enums:RenderingMode.Win2D}"
IsChecked="{x:Bind ViewModel.SelectedRenderingMode.Equals(enums:RenderingMode.Win2D), Mode=OneWay}"
Text="Win2D (Direct2D)" />
<MenuFlyoutSeparator />
<ToggleMenuFlyoutItem
IsChecked="{x:Bind ViewModel.IsVerticalSyncEnabled, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.SelectedRenderingMode.Equals(enums:RenderingMode.DirectX12), Mode=OneWay}"
Text="Vertical sync" />
<ToggleMenuFlyoutItem
IsChecked="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.SelectedRenderingMode.Equals(enums:RenderingMode.DirectX12), Mode=OneWay}"
Text="Dynamic resolution" />
<MenuFlyoutSeparator />
<ToggleMenuFlyoutItem
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[0]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[0]), Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.IsResolutionScaleOptionEnabled, Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[0])}" />
<ToggleMenuFlyoutItem
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[1]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[1]), Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.IsResolutionScaleOptionEnabled, Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[1])}" />
<ToggleMenuFlyoutItem
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[2]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[2]), Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.IsResolutionScaleOptionEnabled, Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[2])}" />
<ToggleMenuFlyoutItem
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[3]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[3]), Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.IsResolutionScaleOptionEnabled, Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[3])}" />
</MenuFlyout>
</Button.Flyout>
</Button>
</StackPanel>
<!-- Invisible title bar -->
<Rectangle
x:Name="TitleBarRectangle"
Height="32"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Fill="Transparent" />
<!-- Info bar -->
<muxc:InfoBar
x:Name="RenderingErrorInfoBar"
Title="Rendering error"
Margin="80"
Message="There was an error that caused the rendering to fail. Try pausing and starting the rendering again, or restarting the app. If the issue persists, please report it by opening an issue on GitHub."
Severity="Error">
<muxc:InfoBar.ActionButton>
<HyperlinkButton Content="Report the issue" NavigateUri="https://github.com/Sergio0694/ComputeSharp/issues" />
</muxc:InfoBar.ActionButton>
<animations:Implicit.ShowAnimations>
<animations:OpacityAnimation
From="0"
To="1.0"
Duration="0:0:0.5" />
<animations:TranslationAnimation
From="0,20,0"
To="0"
Duration="0:0:0.5" />
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:OpacityAnimation To="0" Duration="0:0:0.5" />
<animations:TranslationAnimation To="0,20,0" Duration="0:0:0.5" />
</animations:Implicit.HideAnimations>
</muxc:InfoBar>
</Grid>
</UserControl>
+50
ファイルの表示
@@ -0,0 +1,50 @@
using System;
using ComputeSharp.Uwp;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
namespace ComputeSharp.SwapChain.Uwp.Views;
/// <summary>
/// A view for <see cref="Core.ViewModels.MainViewModel"/>.
/// </summary>
public sealed partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
}
// Opens the shader selection panel
private void OpenShaderSelectionPanelButton_Click(object sender, RoutedEventArgs e)
{
_ = this.Root.Resources.Remove(nameof(this.ShaderSelectionPanel));
this.Root.Children.Add(this.ShaderSelectionPanel);
}
// Hides the shader selection panel
private void ShaderSelectionPanel_Tapped(object sender, TappedRoutedEventArgs e)
{
_ = this.Root.Children.Remove(this.ShaderSelectionPanel);
}
// Updates the size of the shaders list panel
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
this.ShadersListContainerPanel.Height = Math.Round(e.NewSize.Height * 0.35);
}
// Logs rendering failed in the main panel
private void MainShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, RenderingFailedEventArgs args)
{
this.RenderingErrorInfoBar.IsOpen = true;
}
// Logs rendering failed in a secondary panel
private void SelectionShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, RenderingFailedEventArgs args)
{
this.RenderingErrorInfoBar.IsOpen = true;
}
}