Moved and renamed WinUI sample project
このコミットが含まれているのは:
1 親
6c8b6af6e3
コミット
9e39c27545
20ファイル変更
+1
-1
検索条件に一致するファイルはありません
@@ -0,0 +1,12 @@
|
||||
<Application
|
||||
x:Class="ComputeSharp.SwapChain.WinUI.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,33 @@
|
||||
using ComputeSharp.SwapChain.WinUI.Views;
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// The main application window
|
||||
/// </summary>
|
||||
private Window? mainWindow;
|
||||
|
||||
/// <summary>
|
||||
/// 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()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
mainWindow = new MainWindow();
|
||||
mainWindow.Closed += (_, _) => Exit();
|
||||
mainWindow.Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 432 B |
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 5.2 KiB |
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 1.7 KiB |
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 637 B |
バイナリ
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 283 B |
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 456 B |
バイナリファイルは表示されません。
|
変更後 幅: | 高さ: | サイズ: 2.0 KiB |
@@ -0,0 +1,62 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>ComputeSharp.WinUI3</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x64</Platforms>
|
||||
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
|
||||
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
<Content Include="..\ComputeSharp.SwapChain\Textures\RustyMetal.png">
|
||||
<Link>Assets\Textures\RustyMetal.png</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\ColorfulInfinity.cs" Link="Shaders\ColorfulInfinity.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\ContouredLayers.cs" Link="Shaders\ContouredLayers.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\ExtrudedTruchetPattern.cs" Link="Shaders\ExtrudedTruchetPattern.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\FractalTiling.cs" Link="Shaders\FractalTiling.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\MengerJourney.cs" Link="Shaders\MengerJourney.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\TwoTiledTruchet.cs" Link="Shaders\TwoTiledTruchet.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\Octagrams.cs" Link="Shaders\Octagrams.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\ProteanClouds.cs" Link="Shaders\ProteanClouds.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\PyramidPattern.cs" Link="Shaders\PyramidPattern.cs" />
|
||||
<Compile Include="..\ComputeSharp.SwapChain\Shaders\TriangleGridContouring.cs" Link="Shaders\TriangleGridContouring.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-preview3" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22489-preview" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.1-preview3" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Core" Version="7.1.1-preview3" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.UI.Media" Version="7.1.1-preview3" />
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.WinUI\ComputeSharp.WinUI.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
|
||||
OutputItemType="Analyzer"
|
||||
ReferenceOutputAssembly="false"
|
||||
PrivateAssets="contentfiles;build" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// A class with some static converters for rendering state.
|
||||
/// </summary>
|
||||
public static class RenderingPauseConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a symbol for an input rendering state.
|
||||
/// </summary>
|
||||
/// <param name="value">Whether or not the rendering is currently paaused.</param>
|
||||
/// <returns>A symbol representing the next action for the rendering.</returns>
|
||||
public static Symbol ConvertPausedToSymbol(bool value)
|
||||
{
|
||||
return value ? Symbol.Play : Symbol.Pause;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace ComputeSharp.SwapChain.WinUI.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// A class with some static converters for resolution scale settings.
|
||||
/// </summary>
|
||||
public static class ResolutionScaleConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a resolution scale to a formatted string.
|
||||
/// </summary>
|
||||
/// <param name="value">The input resolution scale (in percentage).</param>
|
||||
/// <returns>A formatted percentage string for <paramref name="value"/>.</returns>
|
||||
public static string ConvertPercentageToFormattedString(int value)
|
||||
{
|
||||
return $"{value}%";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a percentage value to a scaled value in the [0, 1] range.
|
||||
/// </summary>
|
||||
/// <param name="value">The input percentage value to scale.</param>
|
||||
/// <returns>The input percentage scaled to the [0, 1] range.</returns>
|
||||
public static double ConvertPercentageToScale(int value)
|
||||
{
|
||||
return value / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using ComputeSharp.WinUI;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A model for a compute shader.
|
||||
/// </summary>
|
||||
/// <remarks>This can be converted to a record when bindings are fixed, see notes in the XAML code.</remarks>
|
||||
public sealed class ComputeShader : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ComputeShader"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the shader.</param>
|
||||
/// <param name="shaderRunner">The <see cref="IShaderRunner"/> instance to execute.</param>
|
||||
public ComputeShader(string name, IShaderRunner shaderRunner)
|
||||
{
|
||||
Name = name;
|
||||
ShaderRunner = shaderRunner;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the shader.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IShaderRunner"/> instance to execute.
|
||||
/// </summary>
|
||||
public IShaderRunner ShaderRunner { get; }
|
||||
|
||||
private bool isSelected;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the current shader is selected.
|
||||
/// </summary>
|
||||
public bool IsSelected
|
||||
{
|
||||
get => this.isSelected;
|
||||
set => SetProperty(ref this.isSelected, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity
|
||||
Name="0500384f-0d39-4588-96ba-14ccff63085b"
|
||||
Publisher="CN=Sergio"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>ComputeSharp.WinUI3</DisplayName>
|
||||
<PublisherDisplayName>Sergio</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="ComputeSharp.WinUI3"
|
||||
Description="ComputeSharp.WinUI3"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ComputeSharp.SwapChain.Shaders;
|
||||
using ComputeSharp.WinUI;
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI.Shaders.Runners
|
||||
{
|
||||
/// <summary>
|
||||
/// A specialized <see cref="IShaderRunner"/> for <see cref="ContouredLayers"/>.
|
||||
/// </summary>
|
||||
public sealed class ContouredLayersRunner : IShaderRunner
|
||||
{
|
||||
/// <summary>
|
||||
/// A texture for <c>\Textures\RustyMetal.png</c>.
|
||||
/// </summary>
|
||||
private ReadOnlyTexture2D<Rgba32, Float4>? texture;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute(IReadWriteTexture2D<Float4> texture, TimeSpan timespan)
|
||||
{
|
||||
if (this.texture is null)
|
||||
{
|
||||
string filename = Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Textures", "RustyMetal.png");
|
||||
|
||||
this.texture = Gpu.Default.LoadReadOnlyTexture2D<Rgba32, Float4>(filename);
|
||||
}
|
||||
|
||||
Gpu.Default.ForEach(texture, new ContouredLayers((float)timespan.TotalSeconds, this.texture));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
using System.Collections.Generic;
|
||||
using ComputeSharp.SwapChain.Shaders;
|
||||
using ComputeSharp.SwapChain.WinUI.Models;
|
||||
using ComputeSharp.WinUI;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using ComputeSharp.SwapChain.WinUI.Shaders.Runners;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// The viewmodel for for a view that allows users to select shaders and customize settings.
|
||||
/// </summary>
|
||||
public sealed class MainViewModel : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MainViewModel"/> instance.
|
||||
/// </summary>
|
||||
public MainViewModel()
|
||||
{
|
||||
this.isDynamicResolutionEnabled = true;
|
||||
this.selectedResolutionScale = 100;
|
||||
this.selectedComputeShader = ComputeShaderOptions[0];
|
||||
this.selectedComputeShader.IsSelected = true;
|
||||
|
||||
SetResolutionScaleCommand = new RelayCommand<int>(SetResolutionScale);
|
||||
ToggleRenderingPausedCommand = new RelayCommand(ToggleRenderingPaused);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available resolution scaling options (as percentage values).
|
||||
/// </summary>
|
||||
public IList<int> ResolutionScaleOptions { get; } = new[] { 25, 50, 75, 100 };
|
||||
|
||||
private bool isDynamicResolutionEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the dynamic resolution is enabled.
|
||||
/// </summary>
|
||||
public bool IsDynamicResolutionEnabled
|
||||
{
|
||||
get => this.isDynamicResolutionEnabled;
|
||||
set => SetProperty(ref this.isDynamicResolutionEnabled, value);
|
||||
}
|
||||
|
||||
private int selectedResolutionScale;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the currently selected resolution scale setting (as percentage valaue).
|
||||
/// </summary>
|
||||
public int SelectedResolutionScale
|
||||
{
|
||||
get => this.selectedResolutionScale;
|
||||
private set => SetProperty(ref this.selectedResolutionScale, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the command that sets <see cref="SelectedResolutionScale"/>.
|
||||
/// </summary>
|
||||
public IRelayCommand SetResolutionScaleCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="SelectedResolutionScale"/>.
|
||||
/// </summary>
|
||||
private void SetResolutionScale(int resolutionScale)
|
||||
{
|
||||
SelectedResolutionScale = resolutionScale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of available compute shader.
|
||||
/// </summary>
|
||||
public IReadOnlyList<ComputeShader> ComputeShaderOptions { get; } = new ComputeShader[]
|
||||
{
|
||||
new("Colorful infinity", new ShaderRunner<ColorfulInfinity>(static time => new((float)time.TotalSeconds))),
|
||||
new("Extruded truchet", new ShaderRunner<ExtrudedTruchetPattern>(static time => new((float)time.TotalSeconds))),
|
||||
new("Fractal tiling", new ShaderRunner<FractalTiling>(static time => new((float)time.TotalSeconds))),
|
||||
new("Menger Journey", new ShaderRunner<MengerJourney>(static time => new((float)time.TotalSeconds))),
|
||||
new("Octagrams", new ShaderRunner<Octagrams>(static time => new((float)time.TotalSeconds))),
|
||||
new("Protean clouds", new ShaderRunner<ProteanClouds>(static time => new((float)time.TotalSeconds))),
|
||||
new("Two tiled truchet", new ShaderRunner<TwoTiledTruchet>(static time => new((float)time.TotalSeconds))),
|
||||
new("Pyramid pattern", new ShaderRunner<PyramidPattern>(static time => new((float)time.TotalSeconds))),
|
||||
new("Triangle grid contouring", new ShaderRunner<TriangleGridContouring>(static time => new((float)time.TotalSeconds))),
|
||||
new("Contoured layers", new ContouredLayersRunner())
|
||||
};
|
||||
|
||||
private ComputeShader selectedComputeShader;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the currently selected compute shader.
|
||||
/// </summary>
|
||||
public ComputeShader SelectedComputeShader
|
||||
{
|
||||
get => this.selectedComputeShader;
|
||||
set
|
||||
{
|
||||
this.selectedComputeShader.IsSelected = false;
|
||||
|
||||
if (SetProperty(ref this.selectedComputeShader, value) &&
|
||||
value is not null)
|
||||
{
|
||||
value.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool isRenderingPaused;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the rendering is currently paused.
|
||||
/// </summary>
|
||||
public bool IsRenderingPaused
|
||||
{
|
||||
get => this.isRenderingPaused;
|
||||
set => SetProperty(ref this.isRenderingPaused, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the command that toggles <see cref="IsRenderingPaused"/>.
|
||||
/// </summary>
|
||||
public IRelayCommand ToggleRenderingPausedCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Toggles <see cref="IsRenderingPaused"/>.
|
||||
/// </summary>
|
||||
private void ToggleRenderingPaused()
|
||||
{
|
||||
IsRenderingPaused = !IsRenderingPaused;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
<Window
|
||||
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: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.WinUI.Converters"
|
||||
xmlns:viewmodels="using:ComputeSharp.SwapChain.WinUI.ViewModels"
|
||||
xmlns:models="using:ComputeSharp.SwapChain.WinUI.Models"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<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 Duration="0:0:0.5" From="0" To="1.0"/>
|
||||
</animations:Implicit.ShowAnimations>
|
||||
<animations:Implicit.HideAnimations>
|
||||
<animations:OpacityAnimation Duration="0:0:0.5" From="1.0" To="0"/>
|
||||
</animations:Implicit.HideAnimations>
|
||||
<Border.Background>
|
||||
<media:AcrylicBrush
|
||||
TintColor="#FF222222"
|
||||
TintOpacity="0.2"
|
||||
BlurAmount="12"
|
||||
TextureUri="ms-appx:///Images/Misc/noise_low.png"/>
|
||||
</Border.Background>
|
||||
|
||||
<!--Shadow panel with the shaders list-->
|
||||
<controls:DropShadowPanel
|
||||
ShadowOpacity="1"
|
||||
BlurRadius="20"
|
||||
OffsetY="-2"
|
||||
OffsetX="-12"
|
||||
IsMasked="True"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalAlignment="Bottom">
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:TranslationAnimation Duration="0:0:0.5" From="0,320,0" To="0"/>
|
||||
</animations:Implicit.ShowAnimations>
|
||||
<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">
|
||||
|
||||
<!--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
|
||||
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="models:ComputeShader">
|
||||
<Grid
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
ui:UIElementExtensions.ClipToBounds="True">
|
||||
|
||||
<!--Shader preview-->
|
||||
<computesharp:ComputeShaderPanel
|
||||
Width="568"
|
||||
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"
|
||||
Visibility="{x:Bind IsSelected, Mode=OneWay}">
|
||||
<Polygon
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Points="0,0 32,0 32,32"
|
||||
Fill="White"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Border>
|
||||
</controls:DropShadowPanel>
|
||||
</Border>
|
||||
</Grid.Resources>
|
||||
|
||||
<!--Shader-->
|
||||
<computesharp:ComputeShaderPanel
|
||||
x:Name="ShaderPanel"
|
||||
Grid.Row="1"
|
||||
ShaderRunner="{x:Bind ViewModel.SelectedComputeShader.ShaderRunner, Mode=OneWay}"
|
||||
IsDynamicResolutionEnabled="{x:Bind ViewModel.IsDynamicResolutionEnabled, Mode=OneWay}"
|
||||
ResolutionScale="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToScale(ViewModel.SelectedResolutionScale), Mode=OneWay}"
|
||||
IsPaused="{x:Bind ViewModel.IsRenderingPaused, Mode=OneWay}"/>
|
||||
|
||||
<!--Settings panel-->
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Spacing="20"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="48">
|
||||
|
||||
<!--Shader pause button-->
|
||||
<Button
|
||||
Padding="20"
|
||||
CornerRadius="9999"
|
||||
ToolTipService.ToolTip="Select shader"
|
||||
Command="{x:Bind ViewModel.ToggleRenderingPausedCommand}">
|
||||
<SymbolIcon Symbol="{x:Bind converters:RenderingPauseConverter.ConvertPausedToSymbol(ViewModel.IsRenderingPaused), Mode=OneWay}"/>
|
||||
</Button>
|
||||
|
||||
<!--Shader selection button-->
|
||||
<Button
|
||||
Padding="20"
|
||||
CornerRadius="9999"
|
||||
ToolTipService.ToolTip="Select shader"
|
||||
Click="OpenShaderSelectionPanelButton_Click">
|
||||
<SymbolIcon Symbol="Pictures"/>
|
||||
</Button>
|
||||
|
||||
<!--Settings button-->
|
||||
<Button
|
||||
Padding="20"
|
||||
CornerRadius="9999"
|
||||
ToolTipService.ToolTip="Settings">
|
||||
<SymbolIcon Symbol="Setting"/>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout>
|
||||
<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}"/>
|
||||
<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}"/>
|
||||
<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}"/>
|
||||
<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}"/>
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!--Invisible title bar-->
|
||||
<Rectangle
|
||||
x:Name="TitleBarRectangle"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="32"
|
||||
Fill="Transparent"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// A view for <see cref="MainViewModel"/>.
|
||||
/// </summary>
|
||||
public sealed partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.ExtendsContentIntoTitleBar = true;
|
||||
|
||||
SetTitleBar(TitleBarRectangle);
|
||||
}
|
||||
|
||||
// Opens the shader selection panel
|
||||
private void OpenShaderSelectionPanelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Root.Resources.Remove("ShaderSelectionPanel");
|
||||
Root.Children.Add(ShaderSelectionPanel);
|
||||
}
|
||||
|
||||
// Hides the shader selection panel
|
||||
private void ShaderSelectionPanel_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
{
|
||||
Root.Children.Remove(ShaderSelectionPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="ComputeSharp.WinUI3.app"/>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<!-- The combination of below two tags have the following effect:
|
||||
1) Per-Monitor for >= Windows 10 Anniversary Update
|
||||
2) System < Windows 10 Anniversary Update
|
||||
-->
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
||||
新しいイシューから参照
ユーザーをブロックする