From 5f3d78bb82a4c3f7420f42bebeabc1bd31e0a683 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 24 Dec 2022 13:59:01 +0100 Subject: [PATCH] Disable resolution scale options when dynamic resolution is enabled --- ...mputeSharp.SwapChain.Core.Shared.projitems | 1 + .../Converters/BoolConverter.cs | 20 +++++++++++++++++++ .../Converters/RenderingPauseConverter.cs | 2 +- samples/ComputeSharp.SwapChain.Uwp/App.xaml | 2 +- .../Views/MainView.xaml | 6 +++++- samples/ComputeSharp.SwapChain.WinUI/App.xaml | 8 ++++---- .../Views/MainWindow.xaml | 8 ++++++-- 7 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 samples/ComputeSharp.SwapChain.Core.Shared/Converters/BoolConverter.cs diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems b/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems index d6b72cb2..bc2b2625 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems +++ b/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems @@ -11,6 +11,7 @@ + diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Converters/BoolConverter.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/BoolConverter.cs new file mode 100644 index 00000000..2d491fcd --- /dev/null +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/BoolConverter.cs @@ -0,0 +1,20 @@ +using System.Runtime.CompilerServices; + +namespace ComputeSharp.SwapChain.Core.Converters; + +/// +/// A class with some static converters for values. +/// +public static class BoolConverter +{ + /// + /// Negates an input value. + /// + /// The value to negate. + /// The negated value of . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool Not(bool value) + { + return !value; + } +} \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs index 3a04208c..0888d6e1 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Converters/RenderingPauseConverter.cs @@ -14,7 +14,7 @@ public static class RenderingPauseConverter /// /// Gets a symbol for an input rendering state. /// - /// Whether or not the rendering is currently paaused. + /// Whether or not the rendering is currently paused. /// A symbol representing the next action for the rendering. public static Symbol ConvertPausedToSymbol(bool value) { diff --git a/samples/ComputeSharp.SwapChain.Uwp/App.xaml b/samples/ComputeSharp.SwapChain.Uwp/App.xaml index 1afbd8c5..b203f6c3 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/App.xaml +++ b/samples/ComputeSharp.SwapChain.Uwp/App.xaml @@ -1,4 +1,4 @@ - diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml index d709383c..4d9ebc58 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml +++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml @@ -1,4 +1,4 @@ - diff --git a/samples/ComputeSharp.SwapChain.WinUI/App.xaml b/samples/ComputeSharp.SwapChain.WinUI/App.xaml index 27b27547..daf641e3 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/App.xaml +++ b/samples/ComputeSharp.SwapChain.WinUI/App.xaml @@ -1,4 +1,4 @@ - @@ -8,9 +8,9 @@ - - - + + + diff --git a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml index 84d2479e..770daeb4 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml +++ b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml @@ -1,4 +1,4 @@ - @@ -196,21 +196,25 @@ 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 converters:BoolConverter.Not(ViewModel.IsDynamicResolutionEnabled), Mode=OneWay}" Text="{x:Bind converters:ResolutionScaleConverter.ConvertPercentageToFormattedString(ViewModel.ResolutionScaleOptions[0])}" />