mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[DSC] Add support for ImageresizerSizes property (#32657)
Add support for ImageresizerSizes property - do not use ints for enums in ImageSize struct - add required converters - extend setAdditional functionality - add samples Co-authored-by: Andrey Nekrasov <1828123+yuyoyuppe@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// 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 Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Converters;
|
||||
|
||||
public sealed class ImageResizerFitToIntConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is ResizeFit)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is int intValue)
|
||||
{
|
||||
return (ResizeFit)intValue;
|
||||
}
|
||||
|
||||
return ResizeFit.Fill;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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 Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Converters;
|
||||
|
||||
public sealed class ImageResizerUnitToIntConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is ResizeUnit)
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is int intValue)
|
||||
{
|
||||
return (ResizeUnit)intValue;
|
||||
}
|
||||
|
||||
return ResizeUnit.Centimeter;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,9 @@
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<converters:ImageResizerFitToStringConverter x:Key="ImageResizerFitToStringConverter" />
|
||||
<converters:ImageResizerFitToIntConverter x:Key="ImageResizerFitToIntConverter" />
|
||||
<converters:ImageResizerUnitToStringConverter x:Key="ImageResizerUnitToStringConverter" />
|
||||
<converters:ImageResizerUnitToIntConverter x:Key="ImageResizerUnitToIntConverter" />
|
||||
<toolkitconverters:BoolToObjectConverter
|
||||
x:Key="BoolToComboBoxIndexConverter"
|
||||
FalseValue="1"
|
||||
@@ -120,7 +122,7 @@
|
||||
x:Uid="ImageResizer_Fit"
|
||||
Width="240"
|
||||
HorizontalAlignment="Left"
|
||||
SelectedIndex="{x:Bind Fit, Mode=TwoWay}">
|
||||
SelectedIndex="{x:Bind Fit, Mode=TwoWay, Converter={StaticResource ImageResizerFitToIntConverter}}">
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Fit_Fill" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Fit_Fit" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Fit_Stretch" />
|
||||
@@ -146,7 +148,7 @@
|
||||
<ComboBox
|
||||
x:Uid="ImageResizer_Size"
|
||||
Width="240"
|
||||
SelectedIndex="{Binding Unit, Mode=TwoWay}">
|
||||
SelectedIndex="{Binding Unit, Mode=TwoWay, Converter={StaticResource ImageResizerUnitToIntConverter}}">
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_CM" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_Inches" />
|
||||
<ComboBoxItem x:Uid="ImageResizer_Sizes_Units_Percent" />
|
||||
|
||||
Reference in New Issue
Block a user