瀏覽代碼

Make `Scale`, `TranslateX`, and `TranslateY` properties read-only in `ZoomPanControl` and remove unused setters.

Ruben 1 周之前
父節點
當前提交
96169ec023
共有 1 個文件被更改,包括 5 次插入19 次删除
  1. 5 19
      src/PicView.Avalonia/CustomControls/ZoomPanControl.cs

+ 5 - 19
src/PicView.Avalonia/CustomControls/ZoomPanControl.cs

@@ -30,27 +30,12 @@ public class ZoomPanControl : Decorator
     }
 
     // Transform Properties
-    private double _scale = 1.0;
-    private double _translateX;
-    private double _translateY;
 
-    public double Scale
-    {
-        get => _scale;
-        set => _scale = value;
-    }
+    public double Scale { get; private set; } = 1.0;
 
-    public double TranslateX
-    {
-        get => _translateX;
-        set => _translateX = value;
-    }
+    public double TranslateX { get; private set; }
 
-    public double TranslateY
-    {
-        get => _translateY;
-        set => _translateY = value;
-    }
+    public double TranslateY { get; private set; }
 
     /// <summary>
     /// Represents the current zoom level as a percentage.
@@ -508,6 +493,7 @@ public class ZoomPanControl : Decorator
             return;
         }
 
+
         // We need the child's size in local coordinates
         var childSize = Child.Bounds.Size;
         if (childSize.Width <= 0 || childSize.Height <= 0 || double.IsNaN(childSize.Width) ||
@@ -525,7 +511,7 @@ public class ZoomPanControl : Decorator
         // Without rotation, the scaled content bounds are straightforward
         var scaledWidth = childSize.Width * Scale;
         var scaledHeight = childSize.Height * Scale;
-        
+
         var controlWidth = Bounds.Width;
         var controlHeight = Bounds.Height;