Skip to content

Commit

Permalink
handling percentage unit (#8567)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegiacometti committed Dec 15, 2020
1 parent 764c01b commit 8007c0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/modules/imageresizer/ui/Models/ResizeSize.cs
Original file line number Diff line number Diff line change
@@ -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/

Expand Down Expand Up @@ -52,14 +52,7 @@ public virtual string Name
public ResizeFit Fit
{
get => _fit;
set
{
Set(ref _fit, value);
if (!Equals(_fit, value))
{
UpdateShowHeight();
}
}
set => Set(ref _fit, value);
}

[JsonProperty(PropertyName = "width")]
Expand All @@ -77,7 +70,10 @@ public double Height
}

public bool ShowHeight
=> _showHeight;
{
get => _showHeight;
set => Set(ref _showHeight, value);
}

public bool HasAuto
=> Width == 0 || Height == 0;
Expand All @@ -88,8 +84,9 @@ public ResizeUnit Unit
get => _unit;
set
{
var previousUnit = _unit;
Set(ref _unit, value);
if (!Equals(_unit, value))
if (!Equals(previousUnit, value))
{
UpdateShowHeight();
}
Expand All @@ -114,9 +111,9 @@ private static string ReplaceTokens(string text)
: 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)
{
Expand Down
1 change: 1 addition & 0 deletions src/modules/imageresizer/ui/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Name="_this"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
MinWidth="485"
Title="{x:Static p:Resources.ImageResizer}"
WindowStartupLocation="CenterScreen"
ui:WindowHelper.UseModernWindowStyle="True"
Expand Down

0 comments on commit 8007c0a

Please sign in to comment.