Skip to content

Commit

Permalink
Merge pull request #4720 from Arlodotexe/fix/imagecropper-aspect-rati…
Browse files Browse the repository at this point in the history
…o-not-updating-on-image-load

Fixed ImageCropper AspectRatio not updating on image load
  • Loading branch information
michael-hawker authored Sep 29, 2022
2 parents bdcfa43 + 4ea8826 commit 0249f73
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ private void ImageCropperThumb_KeyUp(object sender, KeyRoutedEventArgs e)
_currentCroppedRect = croppedRect;
}

UpdateImageLayout(true);
if (TryUpdateImageLayout(true))
{
UpdateSelectionThumbs(true);
UpdateMaskArea(true);
}
}

private void ImageCropperThumb_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
Expand All @@ -119,7 +123,11 @@ private void ImageCropperThumb_ManipulationCompleted(object sender, Manipulation
_currentCroppedRect = croppedRect;
}

UpdateImageLayout(true);
if (TryUpdateImageLayout(true))
{
UpdateSelectionThumbs(true);
UpdateMaskArea(true);
}
}

private void ImageCropperThumb_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
Expand Down Expand Up @@ -161,7 +169,12 @@ private void SourceImage_ManipulationDelta(object sender, ManipulationDeltaRoute
var croppedRect = _inverseImageTransform.TransformBounds(selectedRect);
croppedRect.Intersect(_restrictedCropRect);
_currentCroppedRect = croppedRect;
UpdateImageLayout();

if (TryUpdateImageLayout())
{
UpdateSelectionThumbs();
UpdateMaskArea();
}
}

private void ImageCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
Expand All @@ -171,8 +184,16 @@ private void ImageCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
return;
}

UpdateImageLayout();
UpdateMaskArea();
if (TryUpdateImageLayout())
{
UpdateSelectionThumbs();
}

if (TryUpdateAspectRatio())
{
UpdateSelectionThumbs();
UpdateMaskArea();
}
}
}
}
Loading

0 comments on commit 0249f73

Please sign in to comment.