[ImageResizer]Improve UI (#31357)

* update to v3

* SizeToContent="Height"

* unimportant code-behind

* UI and text

* finishing touch

* Update NOTICE.md

* Update Resources.resx

W to E

* Fix spellcheck
This commit is contained in:
Jay
2024-02-15 19:36:36 +01:00
committed by GitHub
parent 319a0dd6c2
commit 3e58382637
14 changed files with 105 additions and 209 deletions

View File

@@ -422,8 +422,8 @@ EResize
ERole ERole
ERRORIMAGE ERRORIMAGE
ERRORTITLE ERRORTITLE
erwrite
ESettings ESettings
esize
esrp esrp
etl etl
ETW ETW

View File

@@ -1,6 +1,7 @@
// Copyright (c) Brice Lambson // Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license. // 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/ // See the LICENSE file in the project root for more information.
// Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
namespace ImageResizer.Models namespace ImageResizer.Models
{ {

View File

@@ -1,6 +1,7 @@
// Copyright (c) Brice Lambson // Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license. // 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/ // See the LICENSE file in the project root for more information.
// Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;

View File

@@ -1,6 +1,7 @@
// Copyright (c) Brice Lambson // Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license. // 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/ // See the LICENSE file in the project root for more information.
// Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
namespace ImageResizer.Models namespace ImageResizer.Models
{ {

View File

@@ -87,15 +87,6 @@ namespace ImageResizer.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to H.
/// </summary>
public static string HeightChar {
get {
return ResourceManager.GetString("HeightChar", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Image Resizer. /// Looks up a localized string similar to Image Resizer.
/// </summary> /// </summary>
@@ -142,7 +133,7 @@ namespace ImageResizer.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Ign_ore the orientation of pictures. /// Looks up a localized string similar to Ignore the _orientation of pictures.
/// </summary> /// </summary>
public static string Input_IgnoreOrientation { public static string Input_IgnoreOrientation {
get { get {
@@ -151,7 +142,7 @@ namespace ImageResizer.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Remove metadata that doesn&apos;t affect rendering. /// Looks up a localized string similar to Remove meta_data that doesn&apos;t affect rendering.
/// </summary> /// </summary>
public static string Input_RemoveMetadata { public static string Input_RemoveMetadata {
get { get {
@@ -160,7 +151,7 @@ namespace ImageResizer.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to R_esize the original pictures (don&apos;t create copies). /// Looks up a localized string similar to Over_write files.
/// </summary> /// </summary>
public static string Input_Replace { public static string Input_Replace {
get { get {
@@ -519,15 +510,6 @@ namespace ImageResizer.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Times Symbol.
/// </summary>
public static string Times_Symbol {
get {
return ResourceManager.GetString("Times_Symbol", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Unit. /// Looks up a localized string similar to Unit.
/// </summary> /// </summary>
@@ -563,14 +545,5 @@ namespace ImageResizer.Properties {
return ResourceManager.GetString("Width", resourceCulture); return ResourceManager.GetString("Width", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to W.
/// </summary>
public static string WidthChar {
get {
return ResourceManager.GetString("WidthChar", resourceCulture);
}
}
} }
} }

View File

@@ -140,13 +140,13 @@
<value>Custom</value> <value>Custom</value>
</data> </data>
<data name="Input_IgnoreOrientation" xml:space="preserve"> <data name="Input_IgnoreOrientation" xml:space="preserve">
<value>Ign_ore the orientation of pictures</value> <value>Ignore the _orientation of pictures</value>
</data> </data>
<data name="Input_GifWarning" xml:space="preserve"> <data name="Input_GifWarning" xml:space="preserve">
<value>Gif files with animations may not be correctly resized.</value> <value>Gif files with animations may not be correctly resized.</value>
</data> </data>
<data name="Input_Replace" xml:space="preserve"> <data name="Input_Replace" xml:space="preserve">
<value>R_esize the original pictures (don't create copies)</value> <value>Ov_erwrite files</value>
</data> </data>
<data name="Input_Resize" xml:space="preserve"> <data name="Input_Resize" xml:space="preserve">
<value>Resize</value> <value>Resize</value>
@@ -189,33 +189,43 @@
</data> </data>
<data name="Progress_TimeRemaining_HourMinute" xml:space="preserve"> <data name="Progress_TimeRemaining_HourMinute" xml:space="preserve">
<value>About {0} hour, {1} minute remaining.</value> <value>About {0} hour, {1} minute remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_HourMinutes" xml:space="preserve"> <data name="Progress_TimeRemaining_HourMinutes" xml:space="preserve">
<value>About {0} hour, {1} minutes remaining.</value> <value>About {0} hour, {1} minutes remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_HoursMinute" xml:space="preserve"> <data name="Progress_TimeRemaining_HoursMinute" xml:space="preserve">
<value>About {0} hours, {1} minute remaining.</value> <value>About {0} hours, {1} minute remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_HoursMinutes" xml:space="preserve"> <data name="Progress_TimeRemaining_HoursMinutes" xml:space="preserve">
<value>About {0} hours, {1} minutes remaining.</value> <value>About {0} hours, {1} minutes remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_MinuteSecond" xml:space="preserve"> <data name="Progress_TimeRemaining_MinuteSecond" xml:space="preserve">
<value>About {1} minute, {2} second remaining.</value> <value>About {1} minute, {2} second remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_MinuteSeconds" xml:space="preserve"> <data name="Progress_TimeRemaining_MinuteSeconds" xml:space="preserve">
<value>About {1} minute, {2} seconds remaining.</value> <value>About {1} minute, {2} seconds remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_MinutesSecond" xml:space="preserve"> <data name="Progress_TimeRemaining_MinutesSecond" xml:space="preserve">
<value>About {1} minutes, {2} second remaining.</value> <value>About {1} minutes, {2} second remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_MinutesSeconds" xml:space="preserve"> <data name="Progress_TimeRemaining_MinutesSeconds" xml:space="preserve">
<value>About {1} minutes, {2} seconds remaining.</value> <value>About {1} minutes, {2} seconds remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_Second" xml:space="preserve"> <data name="Progress_TimeRemaining_Second" xml:space="preserve">
<value>About {2} second remaining.</value> <value>About {2} second remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="Progress_TimeRemaining_Seconds" xml:space="preserve"> <data name="Progress_TimeRemaining_Seconds" xml:space="preserve">
<value>About {2} seconds remaining.</value> <value>About {2} seconds remaining.</value>
<comment>"About" = Approximately, not "on the subject of"</comment>
</data> </data>
<data name="ResizeFit_Fill" xml:space="preserve"> <data name="ResizeFit_Fill" xml:space="preserve">
<value>Fill</value> <value>Fill</value>
@@ -262,9 +272,6 @@
<data name="Small" xml:space="preserve"> <data name="Small" xml:space="preserve">
<value>Small</value> <value>Small</value>
</data> </data>
<data name="Times_Symbol" xml:space="preserve">
<value>Times Symbol</value>
</data>
<data name="Unit" xml:space="preserve"> <data name="Unit" xml:space="preserve">
<value>Unit</value> <value>Unit</value>
</data> </data>
@@ -281,14 +288,6 @@
<value>Settings</value> <value>Settings</value>
</data> </data>
<data name="Input_RemoveMetadata" xml:space="preserve"> <data name="Input_RemoveMetadata" xml:space="preserve">
<value>Remove metadata that doesn't affect rendering</value> <value>Remove meta_data that doesn't affect rendering</value>
</data>
<data name="HeightChar" xml:space="preserve">
<value>H</value>
<comment>First character of 'Height'</comment>
</data>
<data name="WidthChar" xml:space="preserve">
<value>W</value>
<comment>First character of 'Width'</comment>
</data> </data>
</root> </root>

View File

@@ -57,9 +57,9 @@ namespace ImageResizer.ViewModels
public Settings Settings { get; } public Settings Settings { get; }
public IEnumerable<ResizeFit> ResizeFitValues { get => Enum.GetValues(typeof(ResizeFit)).Cast<ResizeFit>(); } public IEnumerable<ResizeFit> ResizeFitValues => Enum.GetValues(typeof(ResizeFit)).Cast<ResizeFit>();
public IEnumerable<ResizeUnit> ResizeUnitValues { get => Enum.GetValues(typeof(ResizeUnit)).Cast<ResizeUnit>(); } public IEnumerable<ResizeUnit> ResizeUnitValues => Enum.GetValues(typeof(ResizeUnit)).Cast<ResizeUnit>();
public ICommand ResizeCommand { get; } public ICommand ResizeCommand { get; }
@@ -69,14 +69,9 @@ namespace ImageResizer.ViewModels
public ICommand EnterKeyPressedCommand { get; private set; } public ICommand EnterKeyPressedCommand { get; private set; }
public bool TryingToResizeGifFiles // Any of the files is a gif
{ public bool TryingToResizeGifFiles =>
get _batch.Files.Any(filename => filename.EndsWith(".gif", System.StringComparison.InvariantCultureIgnoreCase));
{
// Any of the files is a gif.
return _batch.Files.Any(filename => filename.EndsWith(".gif", System.StringComparison.InvariantCultureIgnoreCase));
}
}
public void Resize() public void Resize()
{ {

View File

@@ -1,6 +1,7 @@
// Copyright (c) Brice Lambson // Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license. // 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/ // 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;
using System.Globalization; using System.Globalization;

View File

@@ -9,15 +9,16 @@
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <!-- ComboBox -->
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<!-- other controls -->
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ComboBox <ComboBox
x:Name="SizeComboBox" Name="SizeComboBox"
Grid.Row="1" Grid.Row="0"
Height="64" Height="64"
Margin="16,16,16,24" Margin="16"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
@@ -25,43 +26,30 @@
SelectedIndex="{Binding Settings.SelectedSizeIndex}"> SelectedIndex="{Binding Settings.SelectedSizeIndex}">
<ComboBox.Resources> <ComboBox.Resources>
<DataTemplate DataType="{x:Type m:ResizeSize}"> <DataTemplate DataType="{x:Type m:ResizeSize}">
<Grid <Grid VerticalAlignment="Center" AutomationProperties.Name="{Binding Name}">
Margin="2,0,0,0"
VerticalAlignment="Center"
AutomationProperties.Name="{Binding Name}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock FontWeight="SemiBold" Text="{Binding Name}" /> <TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Text="{Binding Name}" />
<StackPanel <StackPanel Grid.Row="1" Orientation="Horizontal">
Grid.Row="1" <TextBlock Foreground="{DynamicResource TextFillColorSecondaryBrush}" Text="{Binding Fit, Converter={StaticResource EnumValueConverter}, ConverterParameter=ThirdPersonSingular}" />
VerticalAlignment="Top"
Orientation="Horizontal">
<TextBlock
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{Binding Fit, Converter={StaticResource EnumValueConverter}, ConverterParameter=ThirdPersonSingular}" />
<TextBlock <TextBlock
Margin="4,0,0,0" Margin="4,0,0,0"
FontSize="12" Style="{StaticResource BodyStrongTextBlockStyle}"
FontWeight="SemiBold"
Text="{Binding Width, Converter={StaticResource AutoDoubleConverter}, ConverterParameter=Auto}" /> Text="{Binding Width, Converter={StaticResource AutoDoubleConverter}, ConverterParameter=Auto}" />
<TextBlock <TextBlock
Margin="4,0,0,0" Margin="4,0,0,0"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="×" Text="×"
Visibility="{Binding ShowHeight, Converter={StaticResource BoolValueConverter}}" /> Visibility="{Binding ShowHeight, Converter={StaticResource BoolValueConverter}}" />
<TextBlock <TextBlock
Margin="4,0,0,0" Margin="4,0,0,0"
FontSize="12" Style="{StaticResource BodyStrongTextBlockStyle}"
FontWeight="SemiBold"
Text="{Binding Height, Converter={StaticResource AutoDoubleConverter}, ConverterParameter=Auto}" Text="{Binding Height, Converter={StaticResource AutoDoubleConverter}, ConverterParameter=Auto}"
Visibility="{Binding ShowHeight, Converter={StaticResource BoolValueConverter}}" /> Visibility="{Binding ShowHeight, Converter={StaticResource BoolValueConverter}}" />
<TextBlock <TextBlock
Margin="4,0,0,0" Margin="4,0,0,0"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{Binding Unit, Converter={StaticResource EnumValueConverter}, ConverterParameter=ToLower}" /> Text="{Binding Unit, Converter={StaticResource EnumValueConverter}, ConverterParameter=ToLower}" />
</StackPanel> </StackPanel>
@@ -76,7 +64,7 @@
</ComboBox.Resources> </ComboBox.Resources>
</ComboBox> </ComboBox>
<Grid Grid.Row="2"> <Grid Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@@ -90,15 +78,13 @@
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}" BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
BorderThickness="0,1,0,0" /> BorderThickness="0,1,0,0" />
<Grid <!-- "Custom" input matrix -->
Height="86" <Grid Margin="16" Visibility="{Binding ElementName=SizeComboBox, Path=SelectedValue, Converter={StaticResource SizeTypeToVisibilityConverter}}">
Margin="18,16,16,16"
Visibility="{Binding ElementName=SizeComboBox, Path=SelectedValue, Converter={StaticResource SizeTypeToVisibilityConverter}}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="20" /> <ColumnDefinition Width="24" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="24" /> <ColumnDefinition Width="24" />
<ColumnDefinition Width="20" /> <ColumnDefinition Width="24" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -107,19 +93,17 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ui:SymbolIcon
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
AutomationProperties.Name="{x:Static p:Resources.Width}" AutomationProperties.Name="{x:Static p:Resources.Width}"
FontSize="12" FontSize="20"
FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{x:Static p:Resources.WidthChar}" Symbol="AutoFitWidth20"
ToolTipService.ToolTip="{x:Static p:Resources.Width}" /> ToolTipService.ToolTip="{x:Static p:Resources.Width}" />
<ui:NumberBox <ui:NumberBox
Name="WidthNumberBox" Name="WidthNumberBox"
Grid.Column="1" Grid.Column="1"
Margin="8,0,0,0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
AutomationProperties.Name="{x:Static p:Resources.Width}" AutomationProperties.Name="{x:Static p:Resources.Width}"
KeyDown="Button_KeyDown" KeyDown="Button_KeyDown"
@@ -133,20 +117,20 @@
UpdateSourceTrigger="PropertyChanged" /> UpdateSourceTrigger="PropertyChanged" />
</ui:NumberBox.Value> </ui:NumberBox.Value>
</ui:NumberBox> </ui:NumberBox>
<TextBlock
<ui:SymbolIcon
Grid.Column="3" Grid.Column="3"
HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
AutomationProperties.Name="{x:Static p:Resources.Height}" AutomationProperties.Name="{x:Static p:Resources.Height}"
FontSize="12" FontSize="20"
FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{x:Static p:Resources.HeightChar}" Symbol="AutoFitHeight20"
ToolTipService.ToolTip="{x:Static p:Resources.Height}" ToolTipService.ToolTip="{x:Static p:Resources.Height}"
Visibility="{Binding ElementName=SizeComboBox, Path=SelectedValue.ShowHeight, Converter={StaticResource BoolValueConverter}}" /> Visibility="{Binding ElementName=SizeComboBox, Path=SelectedValue.ShowHeight, Converter={StaticResource BoolValueConverter}}" />
<ui:NumberBox <ui:NumberBox
Name="HeightNumberBox" Name="HeightNumberBox"
Grid.Column="4" Grid.Column="4"
Margin="8,0,0,0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
AutomationProperties.Name="{x:Static p:Resources.Height}" AutomationProperties.Name="{x:Static p:Resources.Height}"
DataContext="{Binding ElementName=SizeComboBox, Path=SelectedItem}" DataContext="{Binding ElementName=SizeComboBox, Path=SelectedItem}"
@@ -154,7 +138,6 @@
Minimum="0" Minimum="0"
SpinButtonPlacementMode="Inline" SpinButtonPlacementMode="Inline"
Visibility="{Binding ElementName=SizeComboBox, Path=SelectedValue.ShowHeight, Converter={StaticResource BoolValueConverter}}"> Visibility="{Binding ElementName=SizeComboBox, Path=SelectedValue.ShowHeight, Converter={StaticResource BoolValueConverter}}">
<ui:NumberBox.Value> <ui:NumberBox.Value>
<Binding <Binding
ElementName="SizeComboBox" ElementName="SizeComboBox"
@@ -166,26 +149,22 @@
<ui:SymbolIcon <ui:SymbolIcon
Grid.Row="2" Grid.Row="2"
Margin="-2,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="20"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Symbol="ArrowMaximize16" Symbol="Crop20"
ToolTipService.ToolTip="{x:Static p:Resources.Resize_Type}" /> ToolTipService.ToolTip="{x:Static p:Resources.Resize_Type}" />
<ComboBox <ComboBox
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Margin="8,0,0,0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
AutomationProperties.Name="{x:Static p:Resources.Resize_Type}" AutomationProperties.Name="{x:Static p:Resources.Resize_Type}"
ItemsSource="{Binding ResizeFitValues, Mode=OneWay}" ItemsSource="{Binding ResizeFitValues, Mode=OneWay}"
SelectedIndex="{Binding ElementName=SizeComboBox, Path=SelectedValue.Fit, Mode=TwoWay, Converter={StaticResource EnumToIntConverter}}"> SelectedIndex="{Binding ElementName=SizeComboBox, Path=SelectedValue.Fit, Mode=TwoWay, Converter={StaticResource EnumToIntConverter}}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate DataType="{x:Type m:ResizeFit}"> <DataTemplate DataType="{x:Type m:ResizeFit}">
<TextBlock <TextBlock Padding="2,0" Text="{Binding {}, Converter={StaticResource EnumValueConverter}}" />
Margin="4,0,0,0"
FontSize="14"
Text="{Binding {}, Converter={StaticResource EnumValueConverter}}" />
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
@@ -193,76 +172,75 @@
<ui:SymbolIcon <ui:SymbolIcon
Grid.Row="2" Grid.Row="2"
Grid.Column="3" Grid.Column="3"
Margin="-2,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="18" FontSize="20"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Symbol="Ruler16" Symbol="Ruler20"
ToolTipService.ToolTip="{x:Static p:Resources.Unit}" /> ToolTipService.ToolTip="{x:Static p:Resources.Unit}" />
<ComboBox <ComboBox
Grid.Row="2" Grid.Row="2"
Grid.Column="4" Grid.Column="4"
Margin="8,0,0,0"
AutomationProperties.Name="{x:Static p:Resources.Unit}" AutomationProperties.Name="{x:Static p:Resources.Unit}"
ItemsSource="{Binding ResizeUnitValues, Mode=OneWay}" ItemsSource="{Binding ResizeUnitValues, Mode=OneWay}"
SelectedIndex="{Binding ElementName=SizeComboBox, Path=SelectedValue.Unit, Mode=TwoWay, Converter={StaticResource EnumToIntConverter}}"> SelectedIndex="{Binding ElementName=SizeComboBox, Path=SelectedValue.Unit, Mode=TwoWay, Converter={StaticResource EnumToIntConverter}}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate DataType="{x:Type m:ResizeUnit}"> <DataTemplate DataType="{x:Type m:ResizeUnit}">
<TextBlock <TextBlock Padding="2,0" Text="{Binding {}, Converter={StaticResource EnumValueConverter}}" />
Margin="4,0,0,0"
FontSize="14"
Text="{Binding {}, Converter={StaticResource EnumValueConverter}}" />
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
</Grid> </Grid>
<!-- CheckBoxes -->
<StackPanel <StackPanel
Grid.Row="1" Grid.Row="1"
VerticalAlignment="Top" Margin="16"
Orientation="Vertical"> Orientation="Vertical">
<CheckBox IsChecked="{Binding Settings.ShrinkOnly}">
<CheckBox.Content>
<AccessText Text="{x:Static p:Resources.Input_ShrinkOnly}" TextWrapping="Wrap" />
</CheckBox.Content>
</CheckBox>
<CheckBox <CheckBox IsChecked="{Binding Settings.IgnoreOrientation}">
Margin="16,12,16,0" <CheckBox.Content>
Content="{x:Static p:Resources.Input_ShrinkOnly}" <AccessText Text="{x:Static p:Resources.Input_IgnoreOrientation}" TextWrapping="Wrap" />
IsChecked="{Binding Settings.ShrinkOnly}" /> </CheckBox.Content>
</CheckBox>
<CheckBox <CheckBox IsChecked="{Binding Settings.Replace}">
Margin="16,2,16,0" <CheckBox.Content>
Content="{x:Static p:Resources.Input_IgnoreOrientation}" <AccessText Text="{x:Static p:Resources.Input_Replace}" TextWrapping="Wrap" />
IsChecked="{Binding Settings.IgnoreOrientation}" /> </CheckBox.Content>
<!-- </CheckBox>
TODO: This option doesn't make much sense when resizing into a directory. We should swap it for an option
to overwrite any files in the directory instead (issue #88)
-->
<CheckBox
Margin="16,2,16,0"
Content="{x:Static p:Resources.Input_Replace}"
IsChecked="{Binding Settings.Replace}" />
<CheckBox <CheckBox IsChecked="{Binding Settings.RemoveMetadata}">
Margin="16,2,16,0" <CheckBox.Content>
Content="{x:Static p:Resources.Input_RemoveMetadata}" <AccessText Text="{x:Static p:Resources.Input_RemoveMetadata}" TextWrapping="Wrap" />
IsChecked="{Binding Settings.RemoveMetadata}" /> </CheckBox.Content>
</CheckBox>
</StackPanel> </StackPanel>
<!-- Separator line -->
<Border <Border
Grid.Row="2" Grid.Row="2"
Height="1" Height="1"
Margin="0,12,0,8" Margin="0,8"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Top" VerticalAlignment="Top"
Background="{DynamicResource DividerStrokeColorDefaultBrush}" /> Background="{DynamicResource DividerStrokeColorDefaultBrush}" />
<ui:InfoBar <ui:InfoBar
Grid.Row="3" Grid.Row="3"
Margin="16,0,16,0" Margin="16,0"
Padding="12,8,8,8"
IsClosable="False" IsClosable="False"
IsOpen="{Binding TryingToResizeGifFiles}" IsOpen="{Binding TryingToResizeGifFiles}"
Message="{x:Static p:Resources.Input_GifWarning}" Message="{x:Static p:Resources.Input_GifWarning}"
Severity="Warning" /> Severity="Warning" />
<!-- Buttons -->
<Grid Grid.Row="4" Margin="16,8,16,16"> <Grid Grid.Row="4" Margin="16,8,16,16">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition /> <ColumnDefinition />
@@ -271,30 +249,26 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ui:Button <ui:Button
Width="36"
Height="36"
Margin="-6,0,0,0"
Padding="0" Padding="0"
HorizontalAlignment="Left"
AutomationProperties.Name="{x:Static p:Resources.Open_settings}" AutomationProperties.Name="{x:Static p:Resources.Open_settings}"
Background="Transparent" Background="Transparent"
BorderBrush="Transparent" BorderBrush="Transparent"
Command="{Binding OpenSettingsCommand}" Command="{Binding OpenSettingsCommand}"
ToolTipService.ToolTip="{x:Static p:Resources.Open_settings}"> ToolTipService.ToolTip="{x:Static p:Resources.Open_settings}">
<ui:Button.Content> <ui:Button.Content>
<ui:SymbolIcon FontSize="18" Symbol="Settings20" /> <ui:SymbolIcon FontSize="20" Symbol="Settings20" />
</ui:Button.Content> </ui:Button.Content>
</ui:Button> </ui:Button>
<ui:Button <ui:Button
Grid.Column="1" Grid.Column="1"
MinWidth="76" MinWidth="76"
Margin="8,0,0,0"
Appearance="Primary" Appearance="Primary"
AutomationProperties.Name="{x:Static p:Resources.Resize_Tooltip}" AutomationProperties.Name="{x:Static p:Resources.Resize_Tooltip}"
Command="{Binding ResizeCommand}" Command="{Binding ResizeCommand}"
IsDefault="True"> IsDefault="True">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<ui:SymbolIcon FontSize="18" Symbol="ResizeImage20" /> <ui:SymbolIcon FontSize="16" Symbol="ResizeLarge16" />
<TextBlock Margin="8,0,0,0" Text="{x:Static p:Resources.Input_Resize}" /> <TextBlock Margin="8,0,0,0" Text="{x:Static p:Resources.Input_Resize}" />
</StackPanel> </StackPanel>
</ui:Button> </ui:Button>
@@ -307,8 +281,6 @@
Content="{x:Static p:Resources.Cancel}" Content="{x:Static p:Resources.Cancel}"
IsCancel="True" /> IsCancel="True" />
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -1,13 +1,13 @@
// Copyright (c) Brice Lambson // Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license. // 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/ // See the LICENSE file in the project root for more information.
// Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using ImageResizer.ViewModels; using ImageResizer.ViewModels;
using Wpf.Ui.Controls; using Wpf.Ui.Controls;
using static ImageResizer.ViewModels.InputViewModel; using static ImageResizer.ViewModels.InputViewModel;
using Numberbox = Wpf.Ui.Controls.NumberBox;
namespace ImageResizer.Views namespace ImageResizer.Views
{ {
@@ -29,10 +29,9 @@ namespace ImageResizer.Views
if (e.Key == Key.Enter) if (e.Key == Key.Enter)
{ {
var numberBox = sender as NumberBox; var numberBox = sender as NumberBox;
var viewModel = (InputViewModel)this.DataContext; var viewModel = (InputViewModel)DataContext;
double number;
KeyPressParams keyParams; KeyPressParams keyParams;
if (double.TryParse(((System.Windows.Controls.TextBox)e.OriginalSource).Text, out number)) if (double.TryParse(((System.Windows.Controls.TextBox)e.OriginalSource).Text, out double number))
{ {
// Determine which NumberBox triggered the event based on its name // Determine which NumberBox triggered the event based on its name
switch (numberBox.Name) switch (numberBox.Name)

View File

@@ -16,6 +16,7 @@
ExtendsContentIntoTitleBar="True" ExtendsContentIntoTitleBar="True"
Icon="/PowerToys.ImageResizer;component/Resources/ImageResizer.ico" Icon="/PowerToys.ImageResizer;component/Resources/ImageResizer.ico"
ResizeMode="NoResize" ResizeMode="NoResize"
SizeToContent="Height"
WindowCornerPreference="Default" WindowCornerPreference="Default"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
@@ -58,6 +59,7 @@
<ui:ImageIcon Source="/PowerToys.ImageResizer;component/Resources/ImageResizer.ico" /> <ui:ImageIcon Source="/PowerToys.ImageResizer;component/Resources/ImageResizer.ico" />
</ui:TitleBar.Icon> </ui:TitleBar.Icon>
</ui:TitleBar> </ui:TitleBar>
<ContentPresenter Grid.Row="1" Content="{Binding CurrentPage}" /> <ContentPresenter Grid.Row="1" Content="{Binding CurrentPage}" />
</Grid> </Grid>
</ui:FluentWindow> </ui:FluentWindow>

View File

@@ -1,31 +0,0 @@
// Copyright (c) Brice Lambson
// 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.Globalization;
using System.Windows.Data;
using ImageResizer.Models;
using ImageResizer.Properties;
namespace ImageResizer.Views
{
[ValueConversion(typeof(ResizeUnit), typeof(string))]
internal class ResizeUnitConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var output = Resources.ResourceManager.GetString(Enum.GetName(typeof(ResizeUnit), value), culture);
if ((string)parameter == "ToLower")
{
output = output.ToLower(culture);
}
return output;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
}

View File

@@ -9,11 +9,7 @@
Margin="12,12,12,0" Margin="12,12,12,0"
FontSize="16" FontSize="16"
Text="{x:Static p:Resources.Results_MainInstruction}" /> Text="{x:Static p:Resources.Results_MainInstruction}" />
<ScrollViewer <ScrollViewer HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
MaxWidth="363"
MaxHeight="350"
HorizontalAlignment="Stretch"
VerticalScrollBarVisibility="Auto">
<ItemsControl Margin="12,4,12,0" ItemsSource="{Binding Errors}"> <ItemsControl Margin="12,4,12,0" ItemsSource="{Binding Errors}">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate DataType="ResizeError"> <DataTemplate DataType="ResizeError">
@@ -28,11 +24,12 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</ScrollViewer> </ScrollViewer>
<Border <Border
Margin="0,12,0,0" Margin="0,12,0,0"
Padding="12,12" Padding="12,12"
Background="{DynamicResource LayerFillColorDefaultBrush}" Background="{DynamicResource LayerFillColorDefaultBrush}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}" BorderBrush="{DynamicResource DividerStrokeColorDefaultBrush}"
BorderThickness="0,1,0,0"> BorderThickness="0,1,0,0">
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button <Button

View File

@@ -15,21 +15,7 @@ namespace ImageResizer.Views
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
if (value != null) return value != null && value.GetType() == typeof(CustomSize) ? Visibility.Visible : (object)Visibility.Collapsed;
{
if (value.GetType() == typeof(CustomSize))
{
return Visibility.Visible;
}
else
{
return Visibility.Collapsed;
}
}
else
{
return Visibility.Collapsed;
}
} }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)