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.
Merge pull request Blazor-Diagrams#119 from Blazor-Diagrams/develop
Version 2.1.3
- Loading branch information
Showing
103 changed files
with
4,223 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Blazor.Diagrams.Core\Blazor.Diagrams.Core.csproj" /> | ||
<ProjectReference Include="..\..\src\Blazor.Diagrams\Blazor.Diagrams.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,16 @@ | ||
using Blazor.Diagrams.Core.Models; | ||
|
||
namespace CustomNodesLinks.Models | ||
{ | ||
public sealed class DiagramLink : LinkModel | ||
{ | ||
public DiagramLink(string name, NodeModel sourceNode, NodeModel? targetNode) : | ||
base(name, sourceNode, targetNode) | ||
{ | ||
Name = name; | ||
Labels.Add(new DiagramLinkLabel(this, Name)); | ||
} | ||
|
||
public string Name { get; set; } | ||
} | ||
} |
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,21 @@ | ||
using Blazor.Diagrams.Core.Geometry; | ||
using Blazor.Diagrams.Core.Models; | ||
using Blazor.Diagrams.Core.Models.Base; | ||
|
||
namespace CustomNodesLinks.Models | ||
{ | ||
public sealed class DiagramLinkLabel : LinkLabelModel | ||
{ | ||
public DiagramLinkLabel(BaseLinkModel parent, string id, string content, double? distance = null, Point? offset = null) : | ||
base(parent, id, content, distance, offset) | ||
{ | ||
} | ||
|
||
public DiagramLinkLabel(BaseLinkModel parent, string content, double? distance = null, Point? offset = null) : | ||
base(parent, content, distance, offset) | ||
{ | ||
} | ||
|
||
public bool ShowLabel { get; set; } = true; | ||
} | ||
} |
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,16 @@ | ||
using Blazor.Diagrams.Core.Geometry; | ||
using Blazor.Diagrams.Core.Models; | ||
|
||
namespace CustomNodesLinks.Models | ||
{ | ||
public sealed class DiagramNode : NodeModel | ||
{ | ||
public DiagramNode(string name, Point pos) : | ||
base(name, pos) | ||
{ | ||
Name = name; | ||
} | ||
|
||
public string Name { get; set; } | ||
} | ||
} |
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,42 @@ | ||
@page | ||
@model CustomNodesLinks.Pages.ErrorModel | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> | ||
<title>Error</title> | ||
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet"/> | ||
<link href="~/css/app.css" rel="stylesheet"/> | ||
</head> | ||
|
||
<body> | ||
<div class="main"> | ||
<div class="content px-4"> | ||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (Model.ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@Model.RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
It can result in displaying sensitive information from exceptions to end users. | ||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
and restarting the app. | ||
</p> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
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,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace CustomNodesLinks.Pages | ||
{ | ||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
[IgnoreAntiforgeryToken] | ||
public class ErrorModel : PageModel | ||
{ | ||
public string RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
private readonly ILogger<ErrorModel> _logger; | ||
|
||
public ErrorModel(ILogger<ErrorModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
} |
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,69 @@ | ||
@page "/" | ||
|
||
@using Blazor.Diagrams.Core | ||
@using Blazor.Diagrams.Core.Geometry | ||
@using Blazor.Diagrams.Core.Models | ||
|
||
<!-- required to resolve DiagramCanvas component --> | ||
@using Blazor.Diagrams.Components | ||
@using CustomNodesLinks.Models | ||
@using CustomNodesLinks.Widgets | ||
|
||
<h1>Hello, World of Custom Nodes and Links!</h1> | ||
|
||
<!-- | ||
Parent of DiagramCanvas has to have a fixed width/height | ||
or it will not be rendered. | ||
100vw = 100% viewport width | ||
100vh = 100% viewport height | ||
--> | ||
<div style="width:100vw; height: 100vh"> | ||
<CascadingValue Value="_diagram"> | ||
<DiagramCanvas></DiagramCanvas> | ||
</CascadingValue> | ||
</div> | ||
|
||
@code { | ||
private Diagram _diagram { get; set; } | ||
|
||
protected override void OnInitialized() | ||
{ | ||
base.OnInitialized(); | ||
|
||
var options = new DiagramOptions | ||
{ | ||
DeleteKey = "Delete", // What key deletes the selected nodes/links | ||
DefaultNodeComponent = null, // Default component for nodes | ||
AllowMultiSelection = true, // Whether to allow multi selection using CTRL | ||
Links = new DiagramLinkOptions | ||
{ | ||
}, | ||
Zoom = new DiagramZoomOptions | ||
{ | ||
Minimum = 0.5, // Minimum zoom value | ||
Inverse = false, // Whether to inverse the direction of the zoom when using the wheel | ||
} | ||
}; | ||
_diagram = new Diagram(options); | ||
|
||
// connect node/link to renderer | ||
_diagram.RegisterModelComponent<DiagramNode, DiagramNodeWidget>(); | ||
_diagram.RegisterModelComponent<DiagramLinkLabel, DiagramLinkLabelWidget>(); | ||
|
||
Setup(); | ||
} | ||
|
||
private void Setup() | ||
{ | ||
var node1 = new DiagramNode("Node 0", new Point(50, 50)); | ||
var node2 = new DiagramNode("Node 1", new Point(300, 300)); | ||
var node3 = new DiagramNode("Node 2", new Point(300, 50)); | ||
_diagram.Nodes.Add(new[] { node1, node2, node3 }); | ||
|
||
// use portless links so connection points move around when we move node | ||
var link = new DiagramLink($"{node1.Name}-->{node2.Name}", node1, node2); | ||
_diagram.Links.Add(link); | ||
} | ||
|
||
} |
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,44 @@ | ||
@page "/" | ||
@namespace CustomNodesLinks.Pages | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
@{ | ||
Layout = null; | ||
} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<title>CustomNodesLinks</title> | ||
<base href="~/"/> | ||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css"/> | ||
<link href="css/site.css" rel="stylesheet"/> | ||
<link href="CustomNodesLinks.styles.css" rel="stylesheet"/> | ||
|
||
<!-- in the head element --> | ||
<link href="_content/Z.Blazor.Diagrams/style.min.css" rel="stylesheet"/> | ||
<!-- if you want the default styling --> | ||
<link href="_content/Z.Blazor.Diagrams/default.styles.min.css" rel="stylesheet"/> | ||
</head> | ||
|
||
<body> | ||
<!-- in the body element --> | ||
<script src="_content/Z.Blazor.Diagrams/script.min.js"></script> | ||
|
||
<component type="typeof(App)" render-mode="ServerPrerendered"/> | ||
|
||
<div id="blazor-error-ui"> | ||
<environment include="Staging,Production"> | ||
An error has occurred. This application may no longer respond until reloaded. | ||
</environment> | ||
<environment include="Development"> | ||
An unhandled exception has occurred. See browser dev tools for details. | ||
</environment> | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
|
||
<script src="_framework/blazor.server.js"></script> | ||
</body> | ||
</html> |
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,17 @@ | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace CustomNodesLinks | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); | ||
} | ||
} |
Oops, something went wrong.