Apply XAML styler refactor pass to UWP/WinUI 3 samples

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-21 19:30:22 +01:00
1 親 7b070bc87f
コミット e608db8a7f
3ファイル変更
+212 -185

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

+1 -3
ファイルの表示
@@ -1,6 +1,4 @@
<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">
</Application>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" />
+103 -87
ファイルの表示
@@ -2,128 +2,146 @@
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:Microsoft.Toolkit.Uwp.UI.Animations"
xmlns:computesharp="using:ComputeSharp.Uwp"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
xmlns:animations="using:Microsoft.Toolkit.Uwp.UI.Animations"
xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media"
xmlns:computesharp="using:ComputeSharp.Uwp"
xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters"
xmlns:viewmodels="using:ComputeSharp.SwapChain.Core.ViewModels"
xmlns:models="using:ComputeSharp.SwapChain.Core.Models"
mc:Ignorable="d"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
xmlns:viewmodels="using:ComputeSharp.SwapChain.Core.ViewModels"
d:DesignHeight="300"
d:DesignWidth="400"
SizeChanged="UserControl_SizeChanged">
SizeChanged="UserControl_SizeChanged"
mc:Ignorable="d">
<Grid x:Name="Root">
<Grid.DataContext>
<viewmodels:MainViewModel x:Name="ViewModel"/>
<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
<!--
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.-->
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 Duration="0:0:0.5" From="0" To="1.0"/>
<animations:OpacityAnimation
From="0"
To="1.0"
Duration="0:0:0.5" />
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:OpacityAnimation Duration="0:0:0.5" From="1.0" To="0"/>
<animations:OpacityAnimation
From="1.0"
To="0"
Duration="0:0:0.5" />
</animations:Implicit.HideAnimations>
<Border.Background>
<media:AcrylicBrush
TintColor="#FF222222"
TintOpacity="0.2"
BlurAmount="12"
TextureUri="ms-appx:///Assets/Misc/noise_low.png"/>
TextureUri="ms-appx:///Assets/Misc/noise_low.png"
TintColor="#FF222222"
TintOpacity="0.2" />
</Border.Background>
<!--Shadow panel with the shaders list-->
<!-- Shadow panel with the shaders list -->
<Border
x:Name="ShadersListContainerPanel"
Height="320"
Margin="-20,0,-20,0"
Background="#FF222222"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom">
VerticalAlignment="Bottom"
Background="#FF222222">
<animations:Implicit.ShowAnimations>
<animations:TranslationAnimation Duration="0:0:0.5" From="0,320,0" To="0"/>
<animations:TranslationAnimation
From="0,320,0"
To="0"
Duration="0:0:0.5" />
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:TranslationAnimation Duration="0:0:0.5" From="0" To="0,320,0"/>
<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"
Color="Black"
Opacity="1"
Offset="-12,-2"
Opacity="1"/>
Color="Black" />
</ui:Effects.Shadow>
<!--Shaders list-->
<!-- Shaders list -->
<ListView
ItemsSource="{x:Bind ViewModel.ComputeShaderOptions}"
SelectionMode="Single"
SelectedItem="{x:Bind ViewModel.SelectedComputeShader, Mode=TwoWay}"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
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"/>
<!--
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"/>
<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"/>
<ItemsStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<!--Shader template-->
<!-- Shader template -->
<DataTemplate x:DataType="models:ComputeShader">
<controls:ConstrainedBox
AspectRatio="16:9"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ui:UIElementExtensions.ClipToBounds="True">
ui:UIElementExtensions.ClipToBounds="True"
AspectRatio="16:9">
<Grid>
<!--Shader preview-->
<computesharp:ComputeShaderPanel 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.-->
<!-- Shader preview -->
<computesharp:ComputeShaderPanel 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
BorderThickness="4"
BorderBrush="White"
BorderThickness="4"
Visibility="{x:Bind IsSelected, Mode=OneWay}">
<Polygon
VerticalAlignment="Top"
HorizontalAlignment="Right"
Points="0,0 32,0 32,32"
Fill="White"/>
VerticalAlignment="Top"
Fill="White"
Points="0,0 32,0 32,32" />
</Border>
</Grid>
</controls:ConstrainedBox>
@@ -134,84 +152,82 @@
</Border>
</Grid.Resources>
<!--Shader-->
<!-- Shader -->
<computesharp:ComputeShaderPanel
x:Name="ShaderPanel"
Grid.Row="1"
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.ShaderRunner, Mode=OneWay}"
IsDynamicResolutionEnabled="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=OneWay}"
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"
ResolutionScale="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToScale(ViewModel.SelectedResolutionScale), Mode=OneWay}"
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"/>
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.ShaderRunner, Mode=OneWay}" />
<!--Settings panel-->
<!-- Settings panel -->
<StackPanel
Orientation="Horizontal"
Spacing="20"
VerticalAlignment="Bottom"
Margin="48"
HorizontalAlignment="Right"
Margin="48">
VerticalAlignment="Bottom"
Orientation="Horizontal"
Spacing="20">
<!--Shader pause button-->
<!-- Shader pause button -->
<Button
Padding="20"
Command="{x:Bind ViewModel.ToggleRenderingPausedCommand}"
CornerRadius="9999"
ToolTipService.ToolTip="Select shader"
Command="{x:Bind ViewModel.ToggleRenderingPausedCommand}">
<SymbolIcon Symbol="{x:Bind converters:RenderingPauseConverter.ConvertPausedToSymbol(ViewModel.IsRenderingPaused), Mode=OneWay}"/>
ToolTipService.ToolTip="Select shader">
<SymbolIcon Symbol="{x:Bind converters:RenderingPauseConverter.ConvertPausedToSymbol(ViewModel.IsRenderingPaused), Mode=OneWay}" />
</Button>
<!--Shader selection button-->
<!-- Shader selection button -->
<Button
Padding="20"
Click="OpenShaderSelectionPanelButton_Click"
CornerRadius="9999"
ToolTipService.ToolTip="Select shader"
Click="OpenShaderSelectionPanelButton_Click">
<SymbolIcon Symbol="Pictures"/>
ToolTipService.ToolTip="Select shader">
<SymbolIcon Symbol="Pictures" />
</Button>
<!--Settings button-->
<!-- Settings button -->
<Button
Padding="20"
CornerRadius="9999"
ToolTipService.ToolTip="Settings">
<SymbolIcon Symbol="Setting"/>
<SymbolIcon Symbol="Setting" />
<Button.Flyout>
<MenuFlyout>
<ToggleMenuFlyoutItem IsChecked="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=TwoWay}" Text="Dynamic resolution" />
<MenuFlyoutSeparator />
<ToggleMenuFlyoutItem
Text="Dynamic resolution"
IsChecked="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=TwoWay}"/>
<MenuFlyoutSeparator/>
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[0])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[0]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[0]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[0]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[0])}" />
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[1])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[1]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[1]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[1]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[1])}" />
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[2])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[2]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[2]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[2]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[2])}" />
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[3])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[3]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[3]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[3]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[3])}" />
</MenuFlyout>
</Button.Flyout>
</Button>
</StackPanel>
<!--Invisible title bar-->
<!-- Invisible title bar -->
<Rectangle
x:Name="TitleBarRectangle"
VerticalAlignment="Top"
HorizontalAlignment="Stretch"
Height="32"
Fill="Transparent"/>
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Fill="Transparent" />
</Grid>
</UserControl>
+108 -95
ファイルの表示
@@ -2,129 +2,144 @@
x:Class="ComputeSharp.SwapChain.WinUI.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:animations="using:CommunityToolkit.WinUI.UI.Animations"
xmlns:computesharp="using:ComputeSharp.WinUI"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:ui="using:CommunityToolkit.WinUI.UI"
xmlns:animations="using:CommunityToolkit.WinUI.UI.Animations"
xmlns:media="using:CommunityToolkit.WinUI.UI.Media"
xmlns:computesharp="using:ComputeSharp.WinUI"
xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters"
xmlns:viewmodels="using:ComputeSharp.SwapChain.Core.ViewModels"
xmlns:models="using:ComputeSharp.SwapChain.Core.Models"
mc:Ignorable="d"
SizeChanged="UserControl_SizeChanged">
xmlns:ui="using:CommunityToolkit.WinUI.UI"
xmlns:viewmodels="using:ComputeSharp.SwapChain.Core.ViewModels"
SizeChanged="UserControl_SizeChanged"
mc:Ignorable="d">
<!--NOTE: this view is a direct port of the one in the UWP sample. Any changes should always just be
made there first and then copied over to this project, given the two frameworks are almost identical.-->
<Grid x:Name="Root">
<Grid.DataContext>
<viewmodels:MainViewModel x:Name="ViewModel"/>
<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
<!--
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.-->
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 Duration="0:0:0.5" From="0" To="1.0"/>
<animations:OpacityAnimation
From="0"
To="1.0"
Duration="0:0:0.5" />
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:OpacityAnimation Duration="0:0:0.5" From="1.0" To="0"/>
<animations:OpacityAnimation
From="1.0"
To="0"
Duration="0:0:0.5" />
</animations:Implicit.HideAnimations>
<Border.Background>
<media:AcrylicBrush
TintColor="#FF222222"
TintOpacity="0.2"
BlurAmount="12"
TextureUri="ms-appx:///Assets/Misc/noise_low.png"/>
TextureUri="ms-appx:///Assets/Misc/noise_low.png"
TintColor="#FF222222"
TintOpacity="0.2" />
</Border.Background>
<!--Shadow panel with the shaders list-->
<!-- Shadow panel with the shaders list -->
<Border
x:Name="ShadersListContainerPanel"
Height="320"
Margin="-20,0,-20,0"
Background="#FF222222"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom">
VerticalAlignment="Bottom"
Background="#FF222222">
<animations:Implicit.ShowAnimations>
<animations:TranslationAnimation Duration="0:0:0.5" From="0,320,0" To="0"/>
<animations:TranslationAnimation
From="0,320,0"
To="0"
Duration="0:0:0.5" />
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:TranslationAnimation Duration="0:0:0.5" From="0" To="0,320,0"/>
<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"
Color="Black"
Opacity="1"
Offset="-12,-2"
Opacity="1"/>
Color="Black" />
</ui:Effects.Shadow>
<!--Shaders list-->
<!-- Shaders list -->
<ListView
ItemsSource="{x:Bind ViewModel.ComputeShaderOptions}"
SelectionMode="Single"
SelectedItem="{x:Bind ViewModel.SelectedComputeShader, Mode=TwoWay}"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
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"/>
<!--
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"/>
<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"/>
<ItemsStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<!--Shader template-->
<!-- Shader template -->
<DataTemplate x:DataType="models:ComputeShader">
<controls:ConstrainedBox
AspectRatio="16:9"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ui:UIElementExtensions.ClipToBounds="True">
ui:UIElementExtensions.ClipToBounds="True"
AspectRatio="16:9">
<Grid>
<!--Shader preview-->
<computesharp:ComputeShaderPanel ShaderRunner="{x:Bind ShaderRunner}"/>
<!-- Shader preview -->
<computesharp:ComputeShaderPanel ShaderRunner="{x:Bind ShaderRunner}" />
<!--Note: here we have a selection property to work around {x:Bind} not working correctly outside of the
<!--
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.-->
When that is working, the ComputeShader.IsSelected property can also be removed, as it will no longer be needed.
-->
<Border
BorderThickness="4"
BorderBrush="White"
BorderThickness="4"
Visibility="{x:Bind IsSelected, Mode=OneWay}">
<Polygon
VerticalAlignment="Top"
HorizontalAlignment="Right"
Points="0,0 32,0 32,32"
Fill="White"/>
VerticalAlignment="Top"
Fill="White"
Points="0,0 32,0 32,32" />
</Border>
</Grid>
</controls:ConstrainedBox>
@@ -135,96 +150,94 @@
</Border>
</Grid.Resources>
<!--Shader-->
<!-- Shader -->
<computesharp:ComputeShaderPanel
x:Name="ShaderPanel"
Grid.Row="1"
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.ShaderRunner, Mode=OneWay}"
IsDynamicResolutionEnabled="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=OneWay}"
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"
ResolutionScale="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToScale(ViewModel.SelectedResolutionScale), Mode=OneWay}"
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"/>
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.ShaderRunner, Mode=OneWay}" />
<!--Settings panel-->
<!-- Settings panel -->
<StackPanel
Orientation="Horizontal"
Spacing="20"
VerticalAlignment="Bottom"
Margin="48"
HorizontalAlignment="Right"
Margin="48">
VerticalAlignment="Bottom"
Orientation="Horizontal"
Spacing="20">
<!--Shader pause button-->
<!-- Shader pause button -->
<Button
Padding="20"
Command="{x:Bind ViewModel.ToggleRenderingPausedCommand}"
CornerRadius="9999"
ToolTipService.ToolTip="Select shader"
Command="{x:Bind ViewModel.ToggleRenderingPausedCommand}">
<SymbolIcon Symbol="{x:Bind converters:RenderingPauseConverter.ConvertPausedToSymbol(ViewModel.IsRenderingPaused), Mode=OneWay}"/>
ToolTipService.ToolTip="Select shader">
<SymbolIcon Symbol="{x:Bind converters:RenderingPauseConverter.ConvertPausedToSymbol(ViewModel.IsRenderingPaused), Mode=OneWay}" />
</Button>
<!--Shader selection button-->
<!-- Shader selection button -->
<Button
Padding="20"
Click="OpenShaderSelectionPanelButton_Click"
CornerRadius="9999"
ToolTipService.ToolTip="Select shader"
Click="OpenShaderSelectionPanelButton_Click">
<SymbolIcon Symbol="Pictures"/>
ToolTipService.ToolTip="Select shader">
<SymbolIcon Symbol="Pictures" />
</Button>
<!--Settings button-->
<!-- Settings button -->
<Button
Padding="20"
CornerRadius="9999"
ToolTipService.ToolTip="Settings">
<SymbolIcon Symbol="Setting"/>
<SymbolIcon Symbol="Setting" />
<Button.Flyout>
<MenuFlyout>
<ToggleMenuFlyoutItem IsChecked="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=TwoWay}" Text="Dynamic resolution" />
<MenuFlyoutSeparator />
<ToggleMenuFlyoutItem
Text="Dynamic resolution"
IsChecked="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=TwoWay}"/>
<MenuFlyoutSeparator/>
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[0])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[0]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[0]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[0]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[0])}" />
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[1])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[1]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[1]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[1]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[1])}" />
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[2])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[2]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[2]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[2]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[2])}" />
<ToggleMenuFlyoutItem
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[3])}"
Command="{x:Bind ViewModel.SetResolutionScaleCommand}"
CommandParameter="{x:Bind ViewModel.ResolutionScaleOptions[3]}"
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[3]), Mode=OneWay}"/>
IsChecked="{x:Bind ViewModel.SelectedResolutionScale.Equals(ViewModel.ResolutionScaleOptions[3]), Mode=OneWay}"
Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[3])}" />
</MenuFlyout>
</Button.Flyout>
</Button>
</StackPanel>
<!--Close button-->
<!-- Close button -->
<Button
Padding="20"
Margin="48"
CornerRadius="9999"
ToolTipService.ToolTip="Close"
Click="CloseButton_Click"
Padding="20"
HorizontalAlignment="Right"
VerticalAlignment="Top"
HorizontalAlignment="Right">
<SymbolIcon Symbol="Cancel"/>
Click="CloseButton_Click"
CornerRadius="9999"
ToolTipService.ToolTip="Close">
<SymbolIcon Symbol="Cancel" />
</Button>
<!--Invisible title bar-->
<!-- Invisible title bar -->
<Rectangle
x:Name="TitleBarRectangle"
VerticalAlignment="Top"
HorizontalAlignment="Stretch"
Height="32"
Fill="Transparent"/>
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Fill="Transparent" />
</Grid>
</Window>