Port UWP sample updates to WinUI 3 project
このコミットが含まれているのは:
1 親
50249f3b6a
コミット
d9fa15a880
3ファイル変更
+72
-56
検索条件に一致するファイルはありません
@@ -5,6 +5,9 @@ using Windows.UI.Xaml.Input;
|
||||
|
||||
namespace ComputeSharp.SwapChain.Uwp.Views;
|
||||
|
||||
/// <summary>
|
||||
/// A view for <see cref="ViewModels.MainViewModel"/>.
|
||||
/// </summary>
|
||||
public sealed partial class MainView : UserControl
|
||||
{
|
||||
public MainView()
|
||||
|
||||
@@ -12,8 +12,12 @@
|
||||
xmlns:converters="using:ComputeSharp.SwapChain.WinUI.Converters"
|
||||
xmlns:viewmodels="using:ComputeSharp.SwapChain.WinUI.ViewModels"
|
||||
xmlns:models="using:ComputeSharp.SwapChain.WinUI.Models"
|
||||
mc:Ignorable="d">
|
||||
mc:Ignorable="d"
|
||||
SizeChanged="UserControl_SizeChanged">
|
||||
|
||||
<!--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"/>
|
||||
@@ -43,14 +47,12 @@
|
||||
</Border.Background>
|
||||
|
||||
<!--Shadow panel with the shaders list-->
|
||||
<controls:DropShadowPanel
|
||||
ShadowOpacity="1"
|
||||
BlurRadius="20"
|
||||
OffsetY="-2"
|
||||
OffsetX="-12"
|
||||
IsMasked="True"
|
||||
<Border
|
||||
x:Name="ShadersListContainerPanel"
|
||||
Height="320"
|
||||
Margin="-20,0,-20,0"
|
||||
Background="#FF222222"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalAlignment="Bottom">
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:TranslationAnimation Duration="0:0:0.5" From="0,320,0" To="0"/>
|
||||
@@ -58,53 +60,57 @@
|
||||
<animations:Implicit.HideAnimations>
|
||||
<animations:TranslationAnimation Duration="0:0:0.5" From="0" To="0,320,0"/>
|
||||
</animations:Implicit.HideAnimations>
|
||||
<Border
|
||||
Height="320"
|
||||
Margin="-20,0,-20,0"
|
||||
Background="#FF222222">
|
||||
<ui:Effects.Shadow>
|
||||
<media:AttachedCardShadow
|
||||
BlurRadius="20"
|
||||
CornerRadius="0"
|
||||
Color="Black"
|
||||
Offset="-12,-2"
|
||||
Opacity="1"/>
|
||||
</ui:Effects.Shadow>
|
||||
|
||||
<!--Shaders list-->
|
||||
<ListView
|
||||
ItemsSource="{x:Bind ViewModel.ComputeShaderOptions}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedComputeShader, Mode=TwoWay}"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollMode="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden">
|
||||
<ListView.Resources>
|
||||
<!--Shaders list-->
|
||||
<ListView
|
||||
ItemsSource="{x:Bind ViewModel.ComputeShaderOptions}"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{x:Bind ViewModel.SelectedComputeShader, Mode=TwoWay}"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollMode="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden">
|
||||
<ListView.Resources>
|
||||
|
||||
<!--Lightweight styling to remove the selection background with the accent color, and
|
||||
<!--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>
|
||||
<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="models:ComputeShader">
|
||||
<Grid
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ui:UIElementExtensions.ClipToBounds="True">
|
||||
<!--Shader template-->
|
||||
<DataTemplate x:DataType="models:ComputeShader">
|
||||
<controls:ConstrainedBox
|
||||
AspectRatio="16:9"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ui:UIElementExtensions.ClipToBounds="True">
|
||||
<Grid>
|
||||
|
||||
<!--Shader preview-->
|
||||
<computesharp:ComputeShaderPanel
|
||||
Width="568"
|
||||
ShaderRunner="{x:Bind ShaderRunner}"/>
|
||||
<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:
|
||||
@@ -121,11 +127,11 @@
|
||||
Fill="White"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Border>
|
||||
</controls:DropShadowPanel>
|
||||
</controls:ConstrainedBox>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid.Resources>
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI.Views;
|
||||
|
||||
/// <summary>
|
||||
/// A view for <see cref="ComputeSharp.SwapChain.WinUI.ViewModels.MainViewModel"/>.
|
||||
/// A view for <see cref="ViewModels.MainViewModel"/>.
|
||||
/// </summary>
|
||||
public sealed partial class MainWindow : Window
|
||||
{
|
||||
@@ -28,4 +29,10 @@ public sealed partial class MainWindow : Window
|
||||
{
|
||||
Root.Children.Remove(ShaderSelectionPanel);
|
||||
}
|
||||
|
||||
// Updates the size of the shaders list panel
|
||||
private void UserControl_SizeChanged(object sender, WindowSizeChangedEventArgs e)
|
||||
{
|
||||
ShadersListContainerPanel.Height = Math.Round(e.Size.Height * 0.35);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする