From fe861707ede3dc2611225b0dc68643349e3f479f Mon Sep 17 00:00:00 2001 From: Suraj Date: Wed, 17 Jan 2024 12:39:05 +0530 Subject: [PATCH 1/3] add test --- .../Controls/ControlsContainerTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/Blazor.Diagrams.Core.Tests/Controls/ControlsContainerTests.cs diff --git a/tests/Blazor.Diagrams.Core.Tests/Controls/ControlsContainerTests.cs b/tests/Blazor.Diagrams.Core.Tests/Controls/ControlsContainerTests.cs new file mode 100644 index 00000000..33291ca7 --- /dev/null +++ b/tests/Blazor.Diagrams.Core.Tests/Controls/ControlsContainerTests.cs @@ -0,0 +1,28 @@ +using Blazor.Diagrams.Core.Controls; +using Blazor.Diagrams.Core.Events; +using Blazor.Diagrams.Core.Models; +using Xunit; + +namespace Blazor.Diagrams.Core.Tests.Controls +{ + public class ControlsContainerTests + { + [Fact] + public void AlwaysOnControlType_AlwaysVisible() + { + // Arrange + var diagram = new TestDiagram(); + var node = diagram.Nodes.Add(new NodeModel()); + var controls = diagram.Controls.AddFor(node, ControlsType.AlwaysOn); + + // Assert + Assert.True(controls.Visible); + + node.Selected = true; + Assert.True(controls.Visible); + + diagram.TriggerPointerEnter(node, new PointerEventArgs(0, 0, 0, 0, false, false, false, 0, 0, 0, 0, 0, 0, string.Empty, true)); + Assert.True(controls.Visible); + } + } +} From 61d4d516f6b04a2a73be253c7717ed2610d489a9 Mon Sep 17 00:00:00 2001 From: Suraj Date: Wed, 17 Jan 2024 12:39:15 +0530 Subject: [PATCH 2/3] Add AlwaysOn ControlsType --- src/Blazor.Diagrams.Core/Controls/ControlsContainer.cs | 4 ++++ src/Blazor.Diagrams.Core/Controls/ControlsType.cs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Blazor.Diagrams.Core/Controls/ControlsContainer.cs b/src/Blazor.Diagrams.Core/Controls/ControlsContainer.cs index 5ebc16b4..1a71d1d0 100644 --- a/src/Blazor.Diagrams.Core/Controls/ControlsContainer.cs +++ b/src/Blazor.Diagrams.Core/Controls/ControlsContainer.cs @@ -16,6 +16,10 @@ public ControlsContainer(Model model, ControlsType type = ControlsType.OnSelecti { Model = model; Type = type; + if (type == ControlsType.AlwaysOn) + { + Visible = true; + } } public Model Model { get; } diff --git a/src/Blazor.Diagrams.Core/Controls/ControlsType.cs b/src/Blazor.Diagrams.Core/Controls/ControlsType.cs index 5997e72c..641a79fd 100644 --- a/src/Blazor.Diagrams.Core/Controls/ControlsType.cs +++ b/src/Blazor.Diagrams.Core/Controls/ControlsType.cs @@ -3,5 +3,6 @@ namespace Blazor.Diagrams.Core.Controls; public enum ControlsType { OnHover, - OnSelection + OnSelection, + AlwaysOn } \ No newline at end of file From dd05a3f72a1b8fce16cf5ed5bb5e73aac5e2cd3c Mon Sep 17 00:00:00 2001 From: Suraj Date: Mon, 22 Jan 2024 11:04:22 +0530 Subject: [PATCH 3/3] add documentation --- site/Site/Pages/Documentation/Controls/Overview.razor | 1 + 1 file changed, 1 insertion(+) diff --git a/site/Site/Pages/Documentation/Controls/Overview.razor b/site/Site/Pages/Documentation/Controls/Overview.razor index 335838ae..034a2637 100644 --- a/site/Site/Pages/Documentation/Controls/Overview.razor +++ b/site/Site/Pages/Documentation/Controls/Overview.razor @@ -40,6 +40,7 @@ // Initialize var node1Controls = Diagram.Controls.AddFor(Node1); // OnSelection default var node2Controls = Diagram.Controls.AddFor(Node2, ControlsType.OnHover); +var node3Controls = Diagram.Controls.AddFor(Node2, ControlsType.AlwaysOn); // Control always visible // Add node1Controls.Add(new SomeControl());