Skip to content

Commit

Permalink
Add registerDefaultBehaviors parameter to diagram ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
zHaytam committed Dec 3, 2024
1 parent c93c07c commit 6917417
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Blazor.Diagrams.Core/Diagram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Type, Behavior>();
_orderedSelectables = new List<SelectableModel>();
Expand All @@ -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));
Expand Down
6 changes: 2 additions & 4 deletions src/Blazor.Diagrams/BlazorDiagram.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,7 +10,7 @@ public class BlazorDiagram : Diagram
{
private readonly Dictionary<Type, Type> _componentsMapping;

public BlazorDiagram(BlazorDiagramOptions? options = null)
public BlazorDiagram(BlazorDiagramOptions? options = null, bool registerDefaultBehaviors = true) : base(registerDefaultBehaviors)
{
_componentsMapping = new Dictionary<Type, Type>
{
Expand Down

0 comments on commit 6917417

Please sign in to comment.