From 6917417d263324cfc88767db573629c046c4aafd Mon Sep 17 00:00:00 2001 From: Haytam Zanid Date: Tue, 3 Dec 2024 10:53:44 +0100 Subject: [PATCH] Add registerDefaultBehaviors parameter to diagram ctors --- src/Blazor.Diagrams.Core/Diagram.cs | 8 ++++---- src/Blazor.Diagrams/BlazorDiagram.cs | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Blazor.Diagrams.Core/Diagram.cs b/src/Blazor.Diagrams.Core/Diagram.cs index a2fffeacb..713fbc758 100644 --- a/src/Blazor.Diagrams.Core/Diagram.cs +++ b/src/Blazor.Diagrams.Core/Diagram.cs @@ -4,9 +4,6 @@ using Blazor.Diagrams.Core.Layers; using Blazor.Diagrams.Core.Models.Base; using Blazor.Diagrams.Core.Events; -using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; using Blazor.Diagrams.Core.Options; using Blazor.Diagrams.Core.Controls; @@ -38,7 +35,7 @@ public abstract class Diagram public event Action? ContainerChanged; public event Action? Changed; - protected Diagram() + protected Diagram(bool registerDefaultBehaviors = true) { _behaviors = new Dictionary(); _orderedSelectables = new List(); @@ -56,6 +53,9 @@ protected Diagram() Links.Removed += OnSelectableRemoved; Groups.Removed += OnSelectableRemoved; + if (!registerDefaultBehaviors) + return; + RegisterBehavior(new SelectionBehavior(this)); RegisterBehavior(new DragMovablesBehavior(this)); RegisterBehavior(new DragNewLinkBehavior(this)); diff --git a/src/Blazor.Diagrams/BlazorDiagram.cs b/src/Blazor.Diagrams/BlazorDiagram.cs index ab61d98a8..ad4041694 100644 --- a/src/Blazor.Diagrams/BlazorDiagram.cs +++ b/src/Blazor.Diagrams/BlazorDiagram.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Blazor.Diagrams.Components.Controls; +using Blazor.Diagrams.Components.Controls; using Blazor.Diagrams.Core; using Blazor.Diagrams.Core.Controls.Default; using Blazor.Diagrams.Core.Models.Base; @@ -12,7 +10,7 @@ public class BlazorDiagram : Diagram { private readonly Dictionary _componentsMapping; - public BlazorDiagram(BlazorDiagramOptions? options = null) + public BlazorDiagram(BlazorDiagramOptions? options = null, bool registerDefaultBehaviors = true) : base(registerDefaultBehaviors) { _componentsMapping = new Dictionary {