feat: testing and fixes

This commit is contained in:
2026-07-08 08:25:09 +03:00
parent 72ae26eee7
commit 5b6abc045b
6 changed files with 730 additions and 606 deletions
+18
View File
@@ -54,6 +54,12 @@ public class ZoomPanImage : Control
get => GetValue(PanYProperty);
set => SetValue(PanYProperty, value);
}
public static readonly StyledProperty<bool> CanUserZoomPanProperty = AvaloniaProperty.Register<ZoomPanImage, bool>(nameof(CanUserZoomPan), defaultValue: true);
public bool CanUserZoomPan
{
get => GetValue(CanUserZoomPanProperty);
set => SetValue(CanUserZoomPanProperty, value);
}
public ZoomPanImage()
: base()
@@ -64,6 +70,10 @@ public class ZoomPanImage : Control
PanX = 0f;
PanY = 0f;
};
AffectsRender<ZoomPanImage>(ZoomProperty);
AffectsRender<ZoomPanImage>(PanXProperty);
AffectsRender<ZoomPanImage>(PanYProperty);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
@@ -75,6 +85,8 @@ public class ZoomPanImage : Control
protected override void OnPointerWheelChanged(PointerWheelEventArgs ea)
{
if (!CanUserZoomPan)
return;
if (ea.Pointer.Type == PointerType.Mouse)
{
var position = ea.GetPosition(this);
@@ -107,6 +119,8 @@ public class ZoomPanImage : Control
}
protected override void OnPointerPressed(PointerPressedEventArgs ea)
{
if (!CanUserZoomPan)
return;
if (ea.Pointer.Type == PointerType.Mouse)
{
if (ea.Properties.IsLeftButtonPressed)
@@ -136,6 +150,8 @@ public class ZoomPanImage : Control
}
protected override void OnPointerReleased(PointerReleasedEventArgs ea)
{
if (!CanUserZoomPan)
return;
if (ea.Pointer.Type == PointerType.Mouse)
{
if (!ea.Properties.IsLeftButtonPressed)
@@ -151,6 +167,8 @@ public class ZoomPanImage : Control
}
protected override void OnPointerMoved(PointerEventArgs ea)
{
if (!CanUserZoomPan)
return;
if (ea.Pointer.Type == PointerType.Mouse)
{
if (_lastMousePosition is null || Zoom == 1) // Если кнопка не нажата или зум == 1, то ничего не делаем