From 1f3deb89a45d635d4fcc7c0eeed441c3826cf856 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Wed, 7 Jul 2021 14:31:55 +0200 Subject: [PATCH 01/11] Flyout for ImageResizer sizes --- .../ImageResizerFitToStringConverter.cs | 46 ++++ .../ImageResizerUnitToStringConverter.cs | 44 ++++ .../Microsoft.PowerToys.Settings.UI.csproj | 2 + .../Strings/en-us/Resources.resw | 51 +++- .../Views/ImageResizerPage.xaml | 241 ++++++++---------- 5 files changed, 238 insertions(+), 146 deletions(-) create mode 100644 src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerFitToStringConverter.cs create mode 100644 src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerUnitToStringConverter.cs diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerFitToStringConverter.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerFitToStringConverter.cs new file mode 100644 index 000000000000..736ac8aa6d4d --- /dev/null +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerFitToStringConverter.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; +using System.Text; +using Windows.ApplicationModel.Resources; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Media; + +namespace Microsoft.PowerToys.Settings.UI.Converters +{ + public sealed class ImageResizerFitToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + var toLower = false; + if ((string)parameter == "ToLower") + { + toLower = true; + } + + string targetValue = string.Empty; + switch (value) + { + case 0: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Fit_Fill_ThirdPersonSingular"); break; + case 1: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Fit_Fit_ThirdPersonSingular"); break; + case 2: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Fit_Stretch_ThirdPersonSingular"); break; + } + + if (toLower) + { + targetValue = targetValue.ToLower(CultureInfo.CurrentCulture); + } + + return targetValue; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } + } +} diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerUnitToStringConverter.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerUnitToStringConverter.cs new file mode 100644 index 000000000000..b0b60715d0ec --- /dev/null +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Converters/ImageResizerUnitToStringConverter.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; +using Windows.ApplicationModel.Resources; +using Windows.UI.Xaml.Data; + +namespace Microsoft.PowerToys.Settings.UI.Converters +{ + public sealed class ImageResizerUnitToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + var toLower = false; + if ((string)parameter == "ToLower") + { + toLower = true; + } + + string targetValue = string.Empty; + switch (value) + { + case 0: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Centimeter"); break; + case 1: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Inch"); break; + case 2: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Percent"); break; + case 3: targetValue = ResourceLoader.GetForCurrentView().GetString("ImageResizer_Unit_Pixel"); break; + } + + if (toLower) + { + targetValue = targetValue.ToLower(CultureInfo.CurrentCulture); + } + + return targetValue; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } + } +} diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj index ef9685a01d56..643ce5231355 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj @@ -110,6 +110,8 @@ + + diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index 83548cb10162..e35feed97baf 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -610,23 +610,20 @@ Disabling this module or closing PowerToys will unmute the microphone and camera Configurations - - Configuration Name + + Name - - Fit Property - - - Width Property + + Fit - - Height Property + + Width - - Size Property + + Height - - Times Symbol + + Unit Remove @@ -709,6 +706,10 @@ Disabling this module or closing PowerToys will unmute the microphone and camera Fill Refers to filling an image into a certain size. It could overflow + + Fill + Refers to filling an image into a certain size. It could overflow + Fit Refers to fitting an image into a certain size. It won't overflow @@ -1341,4 +1342,28 @@ From there, simply click on a Markdown file or SVG icon in the File Explorer and Download and install + + Fills + + + Fits within + + + Stretches to + + + Centimeters + + + Inches + + + Percent + + + Pixels + + + Edit + \ No newline at end of file diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml index dc046646ff1a..a57c74209aa5 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml @@ -6,11 +6,18 @@ xmlns:models="using:Microsoft.PowerToys.Settings.UI.Library" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:muxc="using:Microsoft.UI.Xaml.Controls" + xmlns:muxc="using:Microsoft.UI.Xaml.Controls" + xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters" + xmlns:toolkitconverters="using:Microsoft.Toolkit.Uwp.UI.Converters" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" AutomationProperties.LandmarkType="Main"> + + + + + @@ -27,150 +34,118 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + From cd38bd17f78213018bb66a9c1b03a88eab2b2808 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Wed, 7 Jul 2021 22:12:57 +0200 Subject: [PATCH 02/11] Narrator support --- .../Strings/en-us/Resources.resw | 3 +++ .../Views/ImageResizerPage.xaml | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index e35feed97baf..d0d008a7e079 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -1366,4 +1366,7 @@ From there, simply click on a Markdown file or SVG icon in the File Explorer and Edit + + Edit + \ No newline at end of file diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml index a57c74209aa5..3532b556bd78 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml @@ -44,8 +44,8 @@ - - + + @@ -53,10 +53,11 @@ + + - @@ -67,12 +68,12 @@