Ruben 1 год назад
Родитель
Сommit
afb1ed59ea

+ 19 - 0
src/PicView.Core/ImageTransformations/RotationHelper.cs

@@ -42,4 +42,23 @@ public static class RotationHelper
             _ => 270
         };
     }
+
+    public static double Rotate(double currentDegrees, bool clockWise)
+    {
+        if (clockWise)
+        {
+            currentDegrees += 90;
+        }
+        else
+        {
+            currentDegrees -= 90;
+        }
+
+        if (Math.Abs(currentDegrees - 450) < 10)
+        {
+            currentDegrees = 0;
+        }
+
+        return currentDegrees;
+    }
 }

+ 3 - 28
src/PicView.WPF/UILogic/TransformImage/Rotation.cs

@@ -54,46 +54,21 @@ internal static class Rotation
         if (keyDown)
         {
             Rotate(up ? RotationAngle + 1 : RotationAngle - 1);
+            Tooltip.ShowTooltipMessage(RotationAngle);
         }
         else
         {
             if (RotationHelper.IsValidRotation(RotationAngle))
             {
-                Rotate(up);
+                Rotate(RotationHelper.Rotate(RotationAngle, up));
             }
             else
             {
-                Rotate(RotationHelper.NextRotationAngle(RotationAngle, up), true);
+                Rotate(RotationHelper.NextRotationAngle(RotationAngle, up));
             }
         }
     }
 
-    /// <summary>
-    /// Rotates the image by 90 degrees.
-    /// </summary>
-    /// <param name="up">If true, rotates the image up (clockwise); otherwise, rotates it down (counterclockwise).</param>
-    private static void Rotate(bool up)
-    {
-        if (up)
-        {
-            RotationAngle += 90;
-            if (RotationAngle >= 360)
-            {
-                RotationAngle -= 360;
-            }
-        }
-        else
-        {
-            RotationAngle -= 90;
-            if (RotationAngle < 0)
-            {
-                RotationAngle += 360;
-            }
-        }
-
-        Rotate(RotationAngle);
-    }
-
     /// <summary>
     /// Rotates the image.
     /// </summary>