From fe69e733bbf7a2c3ba0ce5284e21625fc49484c3 Mon Sep 17 00:00:00 2001 From: Gulam Nabi Azad Date: Wed, 12 Jun 2024 13:01:06 +0530 Subject: [PATCH 1/4] WI00737678---RemoveDragNodesBehavior --- .../Behaviors/DragMovablesBehavior.cs | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs index 3a01eed7..650fcd9b 100644 --- a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs +++ b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs @@ -8,25 +8,22 @@ namespace Blazor.Diagrams.Core.Behaviors; -public class DragMovablesBehavior : Behavior +public class DragMovablesBehavior : DragBehavior { private readonly Dictionary _initialPositions; - private double? _lastClientX; - private double? _lastClientY; - private bool _moved; - private double _totalMovedX = 0; - private double _totalMovedY = 0; + protected double? _lastClientX; + protected double? _lastClientY; + protected bool _moved; + protected double _totalMovedX = 0; + protected double _totalMovedY = 0; public DragMovablesBehavior(Diagram diagram) : base(diagram) { _initialPositions = new Dictionary(); - Diagram.PointerDown += OnPointerDown; - Diagram.PointerMove += OnPointerMove; - Diagram.PointerUp += OnPointerUp; Diagram.PanChanged += OnPanChanged; } - private void OnPointerDown(Model? model, PointerEventArgs e) + protected override void OnPointerDown(Model? model, PointerEventArgs e) { if (model is not MovableModel) return; @@ -56,7 +53,7 @@ private void OnPointerDown(Model? model, PointerEventArgs e) _moved = false; } - private void OnPointerMove(Model? model, PointerEventArgs e) + protected override void OnPointerMove(Model? model, PointerEventArgs e) { if (_initialPositions.Count == 0 || _lastClientX == null || _lastClientY == null) return; @@ -68,13 +65,13 @@ private void OnPointerMove(Model? model, PointerEventArgs e) _totalMovedX += deltaX; _totalMovedY += deltaY; - MoveNodes(model, _totalMovedX, _totalMovedY); + MoveNodes(_totalMovedX, _totalMovedY); _lastClientX = e.ClientX; _lastClientY = e.ClientY; } - public void OnPanChanged(double deltaX, double deltaY) + protected virtual void OnPanChanged(double deltaX, double deltaY) { if (_initialPositions.Count == 0 || _lastClientX == null || _lastClientY == null) return; @@ -84,10 +81,10 @@ public void OnPanChanged(double deltaX, double deltaY) _totalMovedX += deltaX; _totalMovedY += deltaY; - MoveNodes(null, _totalMovedX, _totalMovedY); + MoveNodes(_totalMovedX, _totalMovedY); } - private void MoveNodes(Model? model, double deltaX, double deltaY) + protected virtual void MoveNodes(double deltaX, double deltaY) { foreach (var (movable, initialPosition) in _initialPositions) { @@ -104,7 +101,7 @@ private void MoveNodes(Model? model, double deltaX, double deltaY) } } - private void OnPointerUp(Model? model, PointerEventArgs e) + protected override void OnPointerUp(Model? model, PointerEventArgs e) { if (_initialPositions.Count == 0) return; From 37ee1a0d9830288719bfbcf0e6242fe9a0f07d5a Mon Sep 17 00:00:00 2001 From: Gulam Nabi Azad Date: Wed, 12 Jun 2024 13:04:15 +0530 Subject: [PATCH 2/4] WI00737678---RemoveDragNodesBehavior---Update-1 --- src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs index 650fcd9b..e8418d02 100644 --- a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs +++ b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs @@ -132,9 +132,6 @@ private double ApplyGridSize(double n) public override void Dispose() { _initialPositions.Clear(); - Diagram.PointerDown -= OnPointerDown; - Diagram.PointerMove -= OnPointerMove; - Diagram.PointerUp -= OnPointerUp; Diagram.PanChanged -= OnPanChanged; } } From c3df21f264eb7bdc094fa1a34458fd512722801d Mon Sep 17 00:00:00 2001 From: Gulam Nabi Azad Date: Wed, 12 Jun 2024 13:12:02 +0530 Subject: [PATCH 3/4] WI00737678---RemoveDragNodesBehavior---Update-2 --- src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs index e8418d02..a48ea29b 100644 --- a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs +++ b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs @@ -8,7 +8,7 @@ namespace Blazor.Diagrams.Core.Behaviors; -public class DragMovablesBehavior : DragBehavior +public class DragMovablesBehavior : Behavior { private readonly Dictionary _initialPositions; protected double? _lastClientX; From 2866a8bce058aa840d0fbec1516c41bec1f9bfbe Mon Sep 17 00:00:00 2001 From: Gulam Nabi Azad Date: Wed, 12 Jun 2024 13:13:24 +0530 Subject: [PATCH 4/4] WI00737678---RemoveDragNodesBehavior---Update-3 --- src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs index a48ea29b..e8418d02 100644 --- a/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs +++ b/src/Blazor.Diagrams.Core/Behaviors/DragMovablesBehavior.cs @@ -8,7 +8,7 @@ namespace Blazor.Diagrams.Core.Behaviors; -public class DragMovablesBehavior : Behavior +public class DragMovablesBehavior : DragBehavior { private readonly Dictionary _initialPositions; protected double? _lastClientX;