mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Added Image Resizer Settings (#2324)
* added image resizer settings * updated string resource and binding * added tests and removed sett advanced settings from image resizer * fixed string resource spacing * moved conbo box strings to string resource * updated name of contributor * Capitalized size names * updated fallback encoder and sizers configs * removed interence between settings | used static resource binding * fixed build error
This commit is contained in:
@@ -2,13 +2,18 @@
|
||||
x:Class="Microsoft.PowerToys.Settings.UI.Views.ImageResizerPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
|
||||
xmlns:viewModel="using:Microsoft.PowerToys.Settings.UI.ViewModels"
|
||||
xmlns:models="using:Microsoft.PowerToys.Settings.UI.Lib"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Page.Resources>
|
||||
<viewModel:ImageResizerViewModel x:Key="ViewModel"/>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="LayoutVisualStates">
|
||||
@@ -40,107 +45,182 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="Lets you resize images by right-clicking."
|
||||
<StackPanel Orientation="Vertical" x:Name="ImageResizerView">
|
||||
|
||||
<TextBlock x:Uid="ImageResizer_Description"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<ToggleSwitch Header="Enable Image Resizer"
|
||||
IsOn="True"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
|
||||
<TextBlock Text="Sizes"
|
||||
<TextBlock x:Uid="ImageResizer_EnableGroupSettingsHeader"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
<!-- TO DO: Don't know if a listview with these items is the best solution here. Maybe a data grid is better? -->
|
||||
<!--<ListView Margin="{StaticResource SmallTopMargin}" Padding="-12,0,0,0" SelectionMode="None" ItemsSource="{x:Bind Sizes, Mode=OneWay}">
|
||||
<!--x:Uid="ImageResizer_EnableToggle"-->
|
||||
<ToggleSwitch IsOn="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
|
||||
<TextBlock x:Uid="ImageResizer_CustomSizes"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
|
||||
<ListView x:Name="ImagesSizesListView"
|
||||
ItemsSource="{Binding Sizes, Mode=TwoWay, Source={StaticResource ViewModel}}"
|
||||
Padding="0"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}"
|
||||
Margin="0"
|
||||
>
|
||||
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
|
||||
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
|
||||
<Setter Property="Background" Value="{ThemeResource ListViewItemBackground}"/>
|
||||
<Setter Property="Foreground" Value="{ThemeResource ListViewItemForeground}"/>
|
||||
<Setter Property="TabNavigation" Value="Local"/>
|
||||
<Setter Property="IsHoldingEnabled" Value="True"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}"/>
|
||||
<Setter Property="MinHeight" Value="0"/>
|
||||
<Setter Property="AllowDrop" Value="False"/>
|
||||
<Setter Property="UseSystemFocusVisuals" Value="True"/>
|
||||
<Setter Property="FocusVisualMargin" Value="0"/>
|
||||
<Setter Property="FocusVisualPrimaryBrush" Value="{ThemeResource ListViewItemFocusVisualPrimaryBrush}"/>
|
||||
<Setter Property="FocusVisualPrimaryThickness" Value="2"/>
|
||||
<Setter Property="FocusVisualSecondaryBrush" Value="{ThemeResource ListViewItemFocusVisualSecondaryBrush}"/>
|
||||
<Setter Property="FocusVisualSecondaryThickness" Value="1"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListViewItem">
|
||||
<ListViewItemPresenter CheckBrush="{ThemeResource ListViewItemCheckBrush}" ContentMargin="{TemplateBinding Padding}" CheckMode="{ThemeResource ListViewItemCheckMode}" ContentTransitions="{TemplateBinding ContentTransitions}" CheckBoxBrush="{ThemeResource ListViewItemCheckBoxBrush}" DragForeground="{ThemeResource ListViewItemDragForeground}" DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}" DragBackground="{ThemeResource ListViewItemDragBackground}" DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}" FocusVisualPrimaryBrush="{TemplateBinding FocusVisualPrimaryBrush}" FocusVisualSecondaryThickness="{TemplateBinding FocusVisualSecondaryThickness}" FocusBorderBrush="{ThemeResource ListViewItemFocusBorderBrush}" FocusVisualMargin="{TemplateBinding FocusVisualMargin}" FocusVisualPrimaryThickness="{TemplateBinding FocusVisualPrimaryThickness}" FocusSecondaryBorderBrush="{ThemeResource ListViewItemFocusSecondaryBorderBrush}" FocusVisualSecondaryBrush="{TemplateBinding FocusVisualSecondaryBrush}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Control.IsTemplateFocusTarget="True" PointerOverForeground="{ThemeResource ListViewItemForegroundPointerOver}" PressedBackground="{ThemeResource ListViewItemBackgroundPressed}" PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackground}" PointerOverBackground="{ThemeResource ListViewItemBackgroundPointerOver}" ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" SelectedPressedBackground="{ThemeResource ListViewItemBackgroundSelectedPressed}" SelectionCheckMarkVisualEnabled="{ThemeResource ListViewItemSelectionCheckMarkVisualEnabled}" SelectedForeground="{ThemeResource ListViewItemForegroundSelected}" SelectedPointerOverBackground="{ThemeResource ListViewItemBackgroundSelectedPointerOver}" SelectedBackground="{ThemeResource ListViewItemBackgroundSelected}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="local:ResizeSize">
|
||||
<StackPanel Orientation="Horizontal" Spacing="4">
|
||||
<TextBox Text="{x:Bind Title}" Width="68"/>
|
||||
<ComboBox SelectedIndex="1" Width="88">
|
||||
<ComboBoxItem>Fill</ComboBoxItem>
|
||||
<ComboBoxItem>Fit</ComboBoxItem>
|
||||
<ComboBoxItem>Stretch</ComboBoxItem>
|
||||
<DataTemplate x:Name="SingleLineDataTemplate" x:DataType="models:ImageSize" >
|
||||
<StackPanel Orientation="Horizontal" Padding="0" Spacing="4">
|
||||
<TextBox Text="{x:Bind Path=Name, Mode=TwoWay}"
|
||||
Width="90"
|
||||
Height="35"
|
||||
Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<ComboBox SelectedIndex="{x:Bind Path=Fit, Mode=TwoWay}"
|
||||
Width="90"
|
||||
Height="35"
|
||||
Margin="{StaticResource SmallTopMargin}">
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Fit_Fill" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Fit_Fit" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Fit_Stretch" />
|
||||
</ComboBox>
|
||||
<muxc:NumberBox Value="{x:Bind Width}"/>
|
||||
<TextBlock Text="x" FontWeight="SemiBold" Margin="0,4,0,0"/>
|
||||
<muxc:NumberBox Value="{x:Bind Height}"/>
|
||||
<ComboBox SelectedIndex="3">
|
||||
<ComboBoxItem>Centimeters</ComboBoxItem>
|
||||
<ComboBoxItem>Inches</ComboBoxItem>
|
||||
<ComboBoxItem>Percent</ComboBoxItem>
|
||||
<ComboBoxItem>Pixels</ComboBoxItem>
|
||||
|
||||
<muxc:NumberBox Value="{x:Bind Path=Width, Mode=TwoWay}"
|
||||
Width="68"
|
||||
Height="34"
|
||||
Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<TextBlock Text="x"
|
||||
FontWeight="SemiBold"
|
||||
TextAlignment="Center"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Width="25"
|
||||
Height="35"/>
|
||||
|
||||
<muxc:NumberBox Value="{x:Bind Path=Height, Mode=TwoWay}"
|
||||
Width="68"
|
||||
Height="34"
|
||||
Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<ComboBox SelectedIndex="{Binding Path=Unit, Mode=TwoWay}"
|
||||
Width="90"
|
||||
Height="35"
|
||||
Margin="{StaticResource SmallTopMargin}">
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_CM" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_Inches" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_Percent" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_Pixels" />
|
||||
</ComboBox>
|
||||
<Button x:Name="RemoveButton" Background="Transparent" Click="RemoveButton_Click">
|
||||
<Button.Content>
|
||||
<FontIcon Opacity="0.8" Glyph=""/>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<AppBarButton x:Name="RemoveButton"
|
||||
Background="Transparent"
|
||||
Command = "{Binding DeleteImageSizeEventHandler, Source={StaticResource ViewModel}}"
|
||||
CommandParameter="{Binding Id}"
|
||||
Icon="Delete"
|
||||
Width="52"
|
||||
Height="32"
|
||||
Margin="{StaticResource SmallTopMargin}" Padding="0,0,50,100" UseLayoutRounding="False"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>-->
|
||||
</ListView>
|
||||
|
||||
<Button x:Name="AddSizeButton" Content="Add new size" Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<AppBarButton Icon="Add"
|
||||
x:Name="AddSizeButton"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}"
|
||||
Label="Add Size"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
Command = "{Binding AddImageSizeEventHandler, Source={StaticResource ViewModel}}"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="Encoding"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
<ComboBox Header="Fallback encoder"
|
||||
SelectedIndex="1"
|
||||
SelectedIndex="{Binding Path=Encoder, Mode=TwoWay, Source={StaticResource ViewModel}}"
|
||||
MinWidth="240"
|
||||
Margin="{StaticResource SmallTopMargin}">
|
||||
<ComboBoxItem>BMP Encoder</ComboBoxItem>
|
||||
<ComboBoxItem>GIF Encoder</ComboBoxItem>
|
||||
<ComboBoxItem>JPEG Encoder</ComboBoxItem>
|
||||
<ComboBoxItem>PNG Encoder</ComboBoxItem>
|
||||
<ComboBoxItem>TIFF Encoder</ComboBoxItem>
|
||||
<ComboBoxItem>WMPhoto Encoder</ComboBoxItem>
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}">
|
||||
<ComboBoxItem x:Uid="ImageResizer_FallbackEncoder_PNG" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_FallbackEncoder_BMP" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_FallbackEncoder_JPEG" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_FallbackEncoder_TIFF" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_FallbackEncoder_WMPhoto" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_FallbackEncoder_GIF" />
|
||||
</ComboBox>
|
||||
|
||||
|
||||
<muxc:NumberBox Header="JPEG Quality level"
|
||||
Minimum="0"
|
||||
Maximum="100"
|
||||
Value="90"
|
||||
Value="{ Binding Mode=TwoWay, Path=JPEGQualityLevel, Source={StaticResource ViewModel}}"
|
||||
MinWidth="240"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="{StaticResource SmallTopMargin}" />
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}"/>
|
||||
|
||||
<ComboBox Header="PNG interlacing"
|
||||
SelectedIndex="0"
|
||||
SelectedIndex="{ Binding Mode=TwoWay, Path=PngInterlaceOption, Source={StaticResource ViewModel}}"
|
||||
MinWidth="240"
|
||||
Margin="{StaticResource SmallTopMargin}">
|
||||
<ComboBoxItem>Default</ComboBoxItem>
|
||||
<ComboBoxItem>On</ComboBoxItem>
|
||||
<ComboBoxItem>Off</ComboBoxItem>
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}">
|
||||
<ComboBoxItem x:Uid="Default"/>
|
||||
<ComboBoxItem x:Uid="On"/>
|
||||
<ComboBoxItem x:Uid="Off"/>
|
||||
</ComboBox>
|
||||
|
||||
<ComboBox Header="TIFF Compression"
|
||||
SelectedIndex="0"
|
||||
SelectedIndex="{ Binding Mode=TwoWay, Path=TiffCompressOption, Source={StaticResource ViewModel}}"
|
||||
MinWidth="240"
|
||||
Margin="{StaticResource SmallTopMargin}">
|
||||
<ComboBoxItem>Default</ComboBoxItem>
|
||||
<ComboBoxItem>None</ComboBoxItem>
|
||||
<ComboBoxItem>CCITT3</ComboBoxItem>
|
||||
<ComboBoxItem>CCITT4</ComboBoxItem>
|
||||
<ComboBoxItem>LZW</ComboBoxItem>
|
||||
<ComboBoxItem>RLE</ComboBoxItem>
|
||||
<ComboBoxItem>Zip</ComboBoxItem>
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}">
|
||||
<ComboBoxItem x:Uid="ImageResizer_ENCODER_TIFF_Default"/>
|
||||
<ComboBoxItem x:Uid="ImageResizer_ENCODER_TIFF_None"/>
|
||||
<ComboBoxItem x:Uid="ImageResizer_ENCODER_TIFF_CCITT3"/>
|
||||
<ComboBoxItem x:Uid="ImageResizer_ENCODER_TIFF_CCITT4"/>
|
||||
<ComboBoxItem x:Uid="ImageResizer_ENCODER_TIFF_LZW"/>
|
||||
<ComboBoxItem x:Uid="ImageResizer_ENCODER_TIFF_RLE"/>
|
||||
<ComboBoxItem x:Uid="ImageResizer_ENCODER_TIFF_Zip"/>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Text="File"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||
|
||||
|
||||
<TextBox Header="Filename format"
|
||||
Text="%1 (%2)"
|
||||
HorizontalAlignment="Left"
|
||||
MinWidth="240"
|
||||
Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<TextBlock Text="The following parameters can be used:"
|
||||
Margin="{StaticResource SmallTopBottomMargin}"/>
|
||||
Margin="{StaticResource SmallTopBottomMargin}"/>
|
||||
|
||||
<TextBlock FontSize="12">
|
||||
<Run FontWeight="Bold">%1</Run>
|
||||
@@ -167,11 +247,20 @@
|
||||
<Run> - Actual width</Run>
|
||||
</TextBlock>
|
||||
|
||||
<CheckBox Content="Use original date modified"
|
||||
<TextBox Header="Filename format"
|
||||
Text="{ Binding Mode=TwoWay, Path=FileName, Source={StaticResource ViewModel}}"
|
||||
HorizontalAlignment="Left"
|
||||
MinWidth="240"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}"
|
||||
Margin="{StaticResource SmallTopMargin}"/>
|
||||
|
||||
<CheckBox Content="Use original date modified"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled, Source={StaticResource ViewModel}}"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsChecked="{Binding Mode=TwoWay, Path=KeepDateModified, Source={StaticResource ViewModel}}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
<StackPanel
|
||||
x:Name="SidePanel"
|
||||
Orientation="Vertical"
|
||||
HorizontalAlignment="Left"
|
||||
@@ -179,19 +268,26 @@
|
||||
Grid.Column="1">
|
||||
|
||||
<TextBlock
|
||||
Text="About this feature"
|
||||
x:Uid="About_This_Feature"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||
|
||||
<HyperlinkButton Content="Module overview"/>
|
||||
<HyperlinkButton
|
||||
x:Uid="Module_overview"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/src/modules/imageresizer/README.md"/>
|
||||
|
||||
<HyperlinkButton x:Uid="Give_Feedback"
|
||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||
|
||||
<TextBlock
|
||||
Text="Attribution"
|
||||
x:Uid="AttributionTitle"
|
||||
Style="{StaticResource SettingsGroupTitleStyle}" />
|
||||
|
||||
<HyperlinkButton
|
||||
Content="Brice Lams's Image Resizer"
|
||||
Content="Brice Lambson"
|
||||
NavigateUri="https://github.com/bricelam/ImageResizer/" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -9,11 +9,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
public sealed partial class ImageResizerPage : Page
|
||||
{
|
||||
public ImageResizerViewModel ViewModel { get; } = new ImageResizerViewModel();
|
||||
public ImageResizerViewModel ViewModel { get; set; }
|
||||
|
||||
public ImageResizerPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new ImageResizerViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Uid="PowerLauncher_Description" Style="{StaticResource BodyTextBlockStyle}"
|
||||
<TextBlock x:Uid="PowerLauncher_Description"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<ToggleSwitch x:Uid="PowerLauncher_EnablePowerLauncher"
|
||||
|
||||
Reference in New Issue
Block a user