handling percentage unit (#8567)

This commit is contained in:
Davide Giacometti
2020-12-15 20:21:27 +01:00
committed by GitHub
parent 764c01befb
commit 8007c0af3f
2 changed files with 12 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) Brice Lambson
// 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/
@@ -52,14 +52,7 @@ namespace ImageResizer.Models
public ResizeFit Fit
{
get => _fit;
set
{
Set(ref _fit, value);
if (!Equals(_fit, value))
{
UpdateShowHeight();
}
}
set => Set(ref _fit, value);
}
[JsonProperty(PropertyName = "width")]
@@ -77,7 +70,10 @@ namespace ImageResizer.Models
}
public bool ShowHeight
=> _showHeight;
{
get => _showHeight;
set => Set(ref _showHeight, value);
}
public bool HasAuto
=> Width == 0 || Height == 0;
@@ -88,8 +84,9 @@ namespace ImageResizer.Models
get => _unit;
set
{
var previousUnit = _unit;
Set(ref _unit, value);
if (!Equals(_unit, value))
if (!Equals(previousUnit, value))
{
UpdateShowHeight();
}
@@ -114,9 +111,9 @@ namespace ImageResizer.Models
: text;
private void UpdateShowHeight()
=> Set(
ref _showHeight,
Fit == ResizeFit.Stretch || Unit != ResizeUnit.Percent);
{
ShowHeight = Unit != ResizeUnit.Percent;
}
private double ConvertToPixels(double value, ResizeUnit unit, int originalValue, double dpi)
{

View File

@@ -11,6 +11,7 @@
Name="_this"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
MinWidth="485"
Title="{x:Static p:Resources.ImageResizer}"
WindowStartupLocation="CenterScreen"
ui:WindowHelper.UseModernWindowStyle="True"