mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[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:
@@ -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" />
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user