[Image Resizer]Localize units and resize mode (#31140)

* [Image Resizer] Do not use Culture when getting resources with ResourceLoader

* Localize fit and unit comboboxes

* Update font

* Address PR comments
This commit is contained in:
Stefan Markovic
2024-02-05 17:24:46 +01:00
committed by GitHub
parent 7ca476d6b0
commit ebc7860e5b
4 changed files with 32 additions and 23 deletions

View File

@@ -13,24 +13,6 @@
<ui:ControlsDictionary />
</ResourceDictionary.MergedDictionaries>
<ObjectDataProvider
x:Key="ResizeFitValues"
MethodName="GetValues"
ObjectType="sys:Enum">
<ObjectDataProvider.MethodParameters>
<x:Type Type="{x:Type m:ResizeFit}" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider
x:Key="ResizeUnitValues"
MethodName="GetValues"
ObjectType="sys:Enum">
<ObjectDataProvider.MethodParameters>
<x:Type Type="{x:Type m:ResizeUnit}" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<v:SizeTypeToVisibilityConverter x:Key="SizeTypeToVisibilityConverter" />
<v:EnumValueConverter x:Key="EnumValueConverter" />
<v:AutoDoubleConverter x:Key="AutoDoubleConverter" />

View File

@@ -2,6 +2,8 @@
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using Common.UI;
@@ -55,6 +57,10 @@ namespace ImageResizer.ViewModels
public Settings Settings { get; }
public IEnumerable<ResizeFit> ResizeFitValues { get => Enum.GetValues(typeof(ResizeFit)).Cast<ResizeFit>(); }
public IEnumerable<ResizeUnit> ResizeUnitValues { get => Enum.GetValues(typeof(ResizeUnit)).Cast<ResizeUnit>(); }
public ICommand ResizeCommand { get; }
public ICommand CancelCommand { get; }

View File

@@ -35,7 +35,10 @@ namespace ImageResizer.Views
.Append(parameter);
}
var targetValue = Resources.ResourceManager.GetString(builder.ToString(), culture);
// Fixes #16792 - Looks like culture defaults to en-US, so wrong resource is being fetched.
#pragma warning disable CA1304 // Specify CultureInfo
var targetValue = Resources.ResourceManager.GetString(builder.ToString());
#pragma warning restore CA1304 // Specify CultureInfo
if (toLower)
{

View File

@@ -178,8 +178,17 @@
Grid.Column="1"
HorizontalAlignment="Stretch"
AutomationProperties.Name="{x:Static p:Resources.Resize_Type}"
ItemsSource="{Binding Source={StaticResource ResizeFitValues}}"
Text="{Binding ElementName=SizeComboBox, Path=SelectedValue.Fit, Mode=TwoWay}" />
ItemsSource="{Binding ResizeFitValues, Mode=OneWay}"
SelectedIndex="0">
<ComboBox.ItemTemplate>
<DataTemplate DataType="sys:Enum">
<TextBlock
Margin="4,0,0,0"
FontSize="14"
Text="{Binding {}, Converter={StaticResource EnumValueConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ui:SymbolIcon
Grid.Row="2"
@@ -196,8 +205,17 @@
Grid.Row="2"
Grid.Column="4"
AutomationProperties.Name="{x:Static p:Resources.Unit}"
ItemsSource="{Binding Source={StaticResource ResizeUnitValues}}"
Text="{Binding ElementName=SizeComboBox, Path=SelectedValue.Unit, Mode=TwoWay}" />
ItemsSource="{Binding ResizeUnitValues, Mode=OneWay}"
SelectedIndex="0">
<ComboBox.ItemTemplate>
<DataTemplate DataType="sys:Enum">
<TextBlock
Margin="4,0,0,0"
FontSize="14"
Text="{Binding {}, Converter={StaticResource EnumValueConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>