Skip to content

Commit 664c337

Browse files
authored
Merge pull request #119 from Blazor-Diagrams/develop
Version 2.1.3
2 parents 57c600c + af9cec6 commit 664c337

File tree

103 files changed

+4223
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+4223
-12
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,14 @@ MigrationBackup/
353353
.ionide/
354354
.vscode/symbols.json
355355
.vscode/settings.json
356+
357+
# JetBrains Rider
358+
.idea/
359+
*.sln.iml
360+
361+
# Mono auto generated files
362+
mono_crash.*
363+
364+
# Coverlet code coverage output
365+
**/coverage.json
366+
**/coverage.opencover.xml

Blazor.Diagrams.sln

+23
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CEEAE4C2
2929
EndProject
3030
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.Diagrams.Core.Tests", "tests\Blazor.Diagrams.Core.Tests\Blazor.Diagrams.Core.Tests.csproj", "{36B4DCCD-45AB-4338-9224-DDAF386A23A3}"
3131
EndProject
32+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A9FC9B20-A9F1-4066-8B59-83BD26D3B1C8}"
33+
EndProject
34+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diagram-Demo", "docs\Diagram-Demo\Diagram-Demo.csproj", "{5F423724-5319-4DCE-B9F2-8B2D7E1FDC17}"
35+
EndProject
36+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomNodesLinks", "docs\CustomNodesLinks\CustomNodesLinks.csproj", "{3D104DB4-C7F0-42CA-9D78-AB2C8A8AE3D5}"
37+
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Layouts", "docs\Layouts\Layouts.csproj", "{78C85C89-B464-4083-8829-78BA52BB4780}"
39+
EndProject
3240
Global
3341
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3442
Debug|Any CPU = Debug|Any CPU
@@ -63,6 +71,18 @@ Global
6371
{36B4DCCD-45AB-4338-9224-DDAF386A23A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
6472
{36B4DCCD-45AB-4338-9224-DDAF386A23A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
6573
{36B4DCCD-45AB-4338-9224-DDAF386A23A3}.Release|Any CPU.Build.0 = Release|Any CPU
74+
{5F423724-5319-4DCE-B9F2-8B2D7E1FDC17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{5F423724-5319-4DCE-B9F2-8B2D7E1FDC17}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{5F423724-5319-4DCE-B9F2-8B2D7E1FDC17}.Release|Any CPU.ActiveCfg = Release|Any CPU
77+
{5F423724-5319-4DCE-B9F2-8B2D7E1FDC17}.Release|Any CPU.Build.0 = Release|Any CPU
78+
{3D104DB4-C7F0-42CA-9D78-AB2C8A8AE3D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79+
{3D104DB4-C7F0-42CA-9D78-AB2C8A8AE3D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
80+
{3D104DB4-C7F0-42CA-9D78-AB2C8A8AE3D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
81+
{3D104DB4-C7F0-42CA-9D78-AB2C8A8AE3D5}.Release|Any CPU.Build.0 = Release|Any CPU
82+
{78C85C89-B464-4083-8829-78BA52BB4780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83+
{78C85C89-B464-4083-8829-78BA52BB4780}.Debug|Any CPU.Build.0 = Debug|Any CPU
84+
{78C85C89-B464-4083-8829-78BA52BB4780}.Release|Any CPU.ActiveCfg = Release|Any CPU
85+
{78C85C89-B464-4083-8829-78BA52BB4780}.Release|Any CPU.Build.0 = Release|Any CPU
6686
EndGlobalSection
6787
GlobalSection(SolutionProperties) = preSolution
6888
HideSolutionNode = FALSE
@@ -75,6 +95,9 @@ Global
7595
{B9EE910B-8FE7-490C-B20C-CEC27A2890D6} = {DA819127-3EF6-4EB9-A2DA-BC056B284A50}
7696
{CB3A42B6-3C87-4ECB-B60C-D98275AB1FB6} = {EE32E278-A887-454E-987D-FFE9E37169FE}
7797
{36B4DCCD-45AB-4338-9224-DDAF386A23A3} = {CEEAE4C2-CE68-4FC3-9E0F-D4781B91F7F4}
98+
{5F423724-5319-4DCE-B9F2-8B2D7E1FDC17} = {A9FC9B20-A9F1-4066-8B59-83BD26D3B1C8}
99+
{3D104DB4-C7F0-42CA-9D78-AB2C8A8AE3D5} = {A9FC9B20-A9F1-4066-8B59-83BD26D3B1C8}
100+
{78C85C89-B464-4083-8829-78BA52BB4780} = {A9FC9B20-A9F1-4066-8B59-83BD26D3B1C8}
78101
EndGlobalSection
79102
GlobalSection(ExtensibilityGlobals) = postSolution
80103
SolutionGuid = {969540A2-8162-4063-A4E3-B488F69BD582}

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Diagrams (2.1.3) - 2021-07-19
8+
9+
### Added
10+
11+
- Multiple demo projects by [TrevorDArcyEvans](https://github.com/TrevorDArcyEvans) showing:
12+
- Minimal project setup
13+
- Custom nodes & links
14+
- GraphShape layout algorithms
15+
16+
### Fixed
17+
18+
- Link labels not appearing (fixes #109).
19+
- `ZoomToFit` throwing a `NullReferenceException` when one of the nodes doesn't have a size yet (fixes #118).
20+
721
## Diagrams (2.1.2) - 2021-05-31
822

923
### Fixed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ You can get started very easily & quickly using:
4949

5050
- [Documentation](https://blazor-diagrams.zhaytam.com/)
5151
- [Quick Start](https://blazor-diagrams.zhaytam.com/quickstart)
52-
- [Demos](https://blazor-diagrams.zhaytam.com/demos/simple)
52+
- [Samples](https://blazor-diagrams.zhaytam.com/demos/simple)
53+
- [Docs/Demos](https://github.com/Blazor-Diagrams/Blazor.Diagrams/tree/master/docs)
5354

5455
### Sample project
5556

docs/CustomNodesLinks/App.razor

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

docs/CustomNodesLinks/Program.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
3+
4+
namespace CustomNodesLinks
5+
{
6+
public class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
CreateHostBuilder(args).Build().Run();
11+
}
12+
13+
public static IHostBuilder CreateHostBuilder(string[] args) =>
14+
Host.CreateDefaultBuilder(args)
15+
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
16+
}
17+
}

0 commit comments

Comments
 (0)