mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[Settings]ImageResizer settings accessibility updates, fixes and refactor (#36903)
* Fix issue with missing Image Resizer unit and fit information in settings description. * Fix accessibility issues on Edit and Remove buttons. Fix various issues and refactor view model and ImageSize. New resources for accessibility text formats. * Fix unit test because of change to new preset width and height. Fix 2 unit tests having incorrect expected/actual orderings. * Post-review update: accessibility strings now formatted within the converter, instead of via format strings; simplified encoder GUID collection declaration and retrieval. * Minor example text fix.
This commit is contained in:
@@ -3,41 +3,38 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
using System.Windows;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Converters
|
||||
namespace Microsoft.PowerToys.Settings.UI.Converters;
|
||||
|
||||
public sealed partial class ImageResizerFitToStringConverter : IValueConverter
|
||||
{
|
||||
public sealed partial class ImageResizerFitToStringConverter : IValueConverter
|
||||
// Maps each ResizeFit to its localized string.
|
||||
private static readonly Dictionary<ResizeFit, string> FitToText = new()
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{ ResizeFit.Fill, Helpers.ResourceLoaderInstance.ResourceLoader.GetString("ImageResizer_Fit_Fill_ThirdPersonSingular") },
|
||||
{ ResizeFit.Fit, Helpers.ResourceLoaderInstance.ResourceLoader.GetString("ImageResizer_Fit_Fit_ThirdPersonSingular") },
|
||||
{ ResizeFit.Stretch, Helpers.ResourceLoaderInstance.ResourceLoader.GetString("ImageResizer_Fit_Stretch_ThirdPersonSingular") },
|
||||
};
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is ResizeFit fit && FitToText.TryGetValue(fit, out string fitText))
|
||||
{
|
||||
var toLower = false;
|
||||
if ((string)parameter == "ToLower")
|
||||
{
|
||||
toLower = true;
|
||||
}
|
||||
|
||||
string targetValue = string.Empty;
|
||||
switch (value)
|
||||
{
|
||||
case 0: targetValue = Helpers.ResourceLoaderInstance.ResourceLoader.GetString("ImageResizer_Fit_Fill_ThirdPersonSingular"); break;
|
||||
case 1: targetValue = Helpers.ResourceLoaderInstance.ResourceLoader.GetString("ImageResizer_Fit_Fit_ThirdPersonSingular"); break;
|
||||
case 2: targetValue = Helpers.ResourceLoaderInstance.ResourceLoader.GetString("ImageResizer_Fit_Stretch_ThirdPersonSingular"); break;
|
||||
}
|
||||
|
||||
if (toLower)
|
||||
{
|
||||
targetValue = targetValue.ToLower(CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
return targetValue;
|
||||
return parameter is string lowerParam && lowerParam == "ToLower" ?
|
||||
fitText.ToLower(CultureInfo.CurrentCulture) :
|
||||
fitText;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user