mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
* 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.
41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
// 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.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;
|
|
|
|
public sealed partial class ImageResizerFitToStringConverter : IValueConverter
|
|
{
|
|
// Maps each ResizeFit to its localized string.
|
|
private static readonly Dictionary<ResizeFit, string> FitToText = new()
|
|
{
|
|
{ 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))
|
|
{
|
|
return parameter is string lowerParam && lowerParam == "ToLower" ?
|
|
fitText.ToLower(CultureInfo.CurrentCulture) :
|
|
fitText;
|
|
}
|
|
|
|
return DependencyProperty.UnsetValue;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
return value;
|
|
}
|
|
}
|