From 0791ea8911117dc1291cdf49c3a2a63c07f1a5fa Mon Sep 17 00:00:00 2001
From: Phap Dieu Duong <ddphap@gmail.com>
Date: Fri, 1 Nov 2024 14:52:54 +0800
Subject: [PATCH] Crop: do not apply cached aspect ratio for FreeRatio option

---
 Source/ImageGlass/Tools/FrmCrop.cs | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Source/ImageGlass/Tools/FrmCrop.cs b/Source/ImageGlass/Tools/FrmCrop.cs
index c7c85e57c..416e99889 100644
--- a/Source/ImageGlass/Tools/FrmCrop.cs
+++ b/Source/ImageGlass/Tools/FrmCrop.cs
@@ -116,6 +116,7 @@ protected override void OnLoad(EventArgs e)
         Local.FrmMain.KeyDown += FrmMain_KeyDown;
         Local.FrmMain.KeyUp += FrmMain_KeyUp;
         Local.ImageSaved += Local_ImageSaved;
+        Local.ImageLoading += Local_ImageLoading;
         Local.FrmMain.PicMain.SelectionChanged += PicMain_OnImageSelecting;
         Local.FrmMain.PicMain.ImageLoading += PicMain_ImageLoading;
         Local.FrmMain.PicMain.ImageDrawn += PicMain_ImageDrawn;
@@ -130,7 +131,8 @@ protected override void OnLoad(EventArgs e)
 
         TableTop.Enabled =
             TableBottom.Enabled = Local.FrmMain.PicMain.Source != ImageSource.Null
-                && !Local.FrmMain.PicMain.CanImageAnimate;
+                && !Local.FrmMain.PicMain.CanImageAnimate
+                && !Local.FrmMain.PicMain.UseWebview2;
 
         base.OnLoad(e);
 
@@ -141,6 +143,7 @@ protected override void OnLoad(EventArgs e)
         ApplyLanguage();
     }
 
+
     protected override int OnUpdateHeight(bool performUpdate = true)
     {
         var baseHeight = base.OnUpdateHeight(false);
@@ -176,6 +179,7 @@ protected override void OnToolFormClosing(ToolFormClosingEventArgs e)
         Local.FrmMain.KeyDown -= FrmMain_KeyDown;
         Local.FrmMain.KeyUp -= FrmMain_KeyUp;
         Local.ImageSaved -= Local_ImageSaved;
+        Local.ImageLoading -= Local_ImageLoading;
         Local.FrmMain.PicMain.SelectionChanged -= PicMain_OnImageSelecting;
         Local.FrmMain.PicMain.ImageLoading -= PicMain_ImageLoading;
         Local.FrmMain.PicMain.ImageDrawn -= PicMain_ImageDrawn;
@@ -455,7 +459,9 @@ private void LoadDefaultSelectionSetting(bool drawSelection)
 
 
         // update selection size according to the ratio
-        if (Settings.AspectRatioValues[0] > 0 && Settings.AspectRatioValues[1] > 0)
+        if (Settings.AspectRatio != SelectionAspectRatio.FreeRatio
+            && Settings.AspectRatioValues[0] > 0
+            && Settings.AspectRatioValues[1] > 0)
         {
             var ratioSize = GetSizeWithAspectRatio(new Size(w, h));
 
@@ -602,6 +608,10 @@ private void PicMain_OnImageSelecting(object? sender, Viewer.SelectionEventArgs
             BtnCopy.Enabled = !e.SourceSelection.IsEmpty;
     }
 
+    private void Local_ImageLoading(ImageLoadingEventArgs e)
+    {
+        TableTop.Enabled = TableBottom.Enabled = !e.UseWebview2;
+    }
 
     private void PicMain_ImageLoading(object? sender, EventArgs e)
     {