From 11c81cc24740df4875f11929ace0c6c0413d10ad Mon Sep 17 00:00:00 2001 From: TheXamlGuy Date: Fri, 11 Oct 2024 09:35:28 +0100 Subject: [PATCH] Update cropping UI --- .../ContentCropper/ContentCropper.axaml | 95 ++++++++----------- .../ContentCropper/ContentCropper.cs | 36 ++++--- 2 files changed, 65 insertions(+), 66 deletions(-) diff --git a/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.axaml b/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.axaml index 33a46bb..6e3c494 100644 --- a/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.axaml +++ b/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.axaml @@ -4,64 +4,43 @@ xmlns:controls="using:Toolkit.UI.Controls.Avalonia"> - - - + + + + + - - + + + - 10 - 12 - 12 + 18 18 + + 3,3,0,0 + 0,3,3,0 + 0,0,3,3 + 3,0,0,3 + - - - + - - - - - - - - + BorderThickness="{TemplateBinding BorderThickness}" /> - - - + @@ -79,45 +58,53 @@ diff --git a/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.cs b/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.cs index ee69b53..4044e03 100644 --- a/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.cs +++ b/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.cs @@ -251,20 +251,32 @@ public class ContentCropper : ContentControl case "TopLeftButton": newWidth = Math.Max(0, border.Width - deltaX); newHeight = Math.Max(0, border.Height - deltaY); - if (newWidth > 0) leftPosition += deltaX; - if (newHeight > 0) topPosition += deltaY; + if (newWidth > 0) + { + leftPosition += deltaX; + } + if (newHeight > 0) + { + topPosition += deltaY; + } break; case "TopRightButton": newWidth = Math.Max(0, border.Width + deltaX); newHeight = Math.Max(0, border.Height - deltaY); - if (newHeight > 0) topPosition += deltaY; + if (newHeight > 0) + { + topPosition += deltaY; + } break; case "BottomLeftButton": newWidth = Math.Max(0, border.Width - deltaX); newHeight = Math.Max(0, border.Height + deltaY); - if (newWidth > 0) leftPosition += deltaX; + if (newWidth > 0) + { + leftPosition += deltaX; + } break; case "BottomRightButton": @@ -301,26 +313,26 @@ public class ContentCropper : ContentControl if (topLeftButton is not null) { - Canvas.SetLeft(topLeftButton, borderLeft - (topLeftButton.Width / 2)); - Canvas.SetTop(topLeftButton, borderTop - (topLeftButton.Height / 2)); + Canvas.SetLeft(topLeftButton, borderLeft); + Canvas.SetTop(topLeftButton, borderTop); } if (topRightButton is not null) { - Canvas.SetLeft(topRightButton, borderLeft + borderWidth - (topRightButton.Width / 2)); - Canvas.SetTop(topRightButton, borderTop - (topRightButton.Height / 2)); + Canvas.SetLeft(topRightButton, borderLeft + borderWidth - topRightButton.Width); + Canvas.SetTop(topRightButton, borderTop); } if (bottomLeftButton is not null) { - Canvas.SetLeft(bottomLeftButton, borderLeft - (bottomLeftButton.Width / 2)); - Canvas.SetTop(bottomLeftButton, borderTop + borderHeight - (bottomLeftButton.Height / 2)); + Canvas.SetLeft(bottomLeftButton, borderLeft); + Canvas.SetTop(bottomLeftButton, borderTop + borderHeight - bottomLeftButton.Height); } if (bottomRightButton is not null) { - Canvas.SetLeft(bottomRightButton, borderLeft + borderWidth - (bottomRightButton.Width / 2)); - Canvas.SetTop(bottomRightButton, borderTop + borderHeight - (bottomRightButton.Height / 2)); + Canvas.SetLeft(bottomRightButton, borderLeft + borderWidth - bottomRightButton.Width); + Canvas.SetTop(bottomRightButton, borderTop + borderHeight - bottomRightButton.Height); } }