forked from Blazor-Diagrams/Blazor.Diagrams
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NodeRenderer and a way to register node components by model type
- Loading branch information
Showing
14 changed files
with
101 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Blazor.Diagrams.Core.Models | ||
{ | ||
public class LinkModel : Model | ||
{ | ||
public LinkModel(PortModel sourcePort, PortModel targetPort) | ||
{ | ||
SourcePort = sourcePort; | ||
TargetPort = targetPort; | ||
} | ||
|
||
public LinkModel(string id, PortModel sourcePort, PortModel targetPort) : base(id) | ||
{ | ||
SourcePort = sourcePort; | ||
TargetPort = targetPort; | ||
} | ||
|
||
public PortModel SourcePort { get; } | ||
public PortModel TargetPort { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Blazor.Diagrams.Core; | ||
using Blazor.Diagrams.Core.Models; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Rendering; | ||
|
||
namespace Blazor.Diagrams.Components | ||
{ | ||
public class NodeRenderer : ComponentBase | ||
{ | ||
[CascadingParameter(Name = "DiagramManager")] | ||
public DiagramManager DiagramManager { get; set; } | ||
|
||
[Parameter] | ||
public NodeModel Node { get; set; } | ||
|
||
protected override void BuildRenderTree(RenderTreeBuilder builder) | ||
{ | ||
var component = DiagramManager.GetComponentForModel(Node) ?? typeof(NodeWidget); | ||
builder.OpenComponent(0, component); | ||
builder.AddAttribute(1, "Node", Node); | ||
builder.CloseComponent(); | ||
} | ||
} | ||
} |