Skip to content

Commit 9cb0e13

Browse files
authored
Merge pull request #372 from Blazor-Diagrams/develop
Version 3.0.1
2 parents 6a8eb9a + 11798a1 commit 9cb0e13

File tree

17 files changed

+383
-29
lines changed

17 files changed

+383
-29
lines changed

.github/workflows/push.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: PushToNuget
2+
env:
3+
NUGET_DIR: '${{ github.workspace }}/nuget'
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Pack Blazor.Diagrams.Core
15+
working-directory: src/Blazor.Diagrams.Core
16+
run: 'dotnet pack --configuration Release --output ${{ env.NUGET_DIR }}'
17+
18+
- name: Pack Blazor.Diagrams
19+
working-directory: src/Blazor.Diagrams
20+
run: 'dotnet pack --configuration Release --output ${{ env.NUGET_DIR }}'
21+
22+
- name: Pack Blazor.Diagrams.Algorithms
23+
working-directory: src/Blazor.Diagrams.Algorithms
24+
run: 'dotnet pack --configuration Release --output ${{ env.NUGET_DIR }}'
25+
26+
- name: Push
27+
run: |
28+
foreach($file in (Get-ChildItem "${{ env.NUGET_DIR }}" -Recurse -Include *.nupkg)) {
29+
dotnet nuget push $file --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
30+
}

Blazor.Diagrams.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2424
.github\workflows\build.yml = .github\workflows\build.yml
2525
CHANGELOG.md = CHANGELOG.md
2626
.github\workflows\main.yml = .github\workflows\main.yml
27+
.github\workflows\push.yml = .github\workflows\push.yml
2728
README.md = README.md
2829
EndProjectSection
2930
EndProject

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Diagrams (3.0.1) - 2023-10-27
9+
10+
### Added
11+
12+
- `Route` property to `BaseLinkModel` to hold the result of the executed router
13+
14+
### Fixed
15+
16+
- Constraints not checked when using `RemoveControl` (thanks to @[K0369](https://github.com/K0369))
17+
- NRE Exception on the landing page demo when dragging a new link and not linking it to something (thanks to @[K0369](https://github.com/K0369))
18+
- `LinkVertexWidgetTests` failing on cultures that are not using a dot as decimal separator (thanks to @[K0369](https://github.com/K0369))
19+
- NRE exception in the Diagram Demo project (thanks to @[Suraj0500](https://github.com/Suraj0500))
20+
821
## Diagrams (3.0.0) - 2023-08-14
922

1023
Finally, the new documentation website is here!

docs/Diagram-Demo/Pages/Diagrams.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ or it will not be rendered.
2828
</div>
2929

3030
@code {
31-
private Diagram Diagram { get; set; }
31+
private BlazorDiagram Diagram { get; set; }
3232

3333
protected override void OnInitialized()
3434
{

site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,24 @@ private void OnLinkAdded(BaseLinkModel link)
6565
link.TargetChanged += OnLinKTargetChanged;
6666
}
6767

68-
private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? newTarget)
68+
private void OnLinKTargetChanged(BaseLinkModel link, Anchor oldTarget, Anchor newTarget)
6969
{
70-
if (oldTarget == null && newTarget != null) // First attach
70+
// only refresh on the first time the link is attached
71+
if (oldTarget is PositionAnchor
72+
&& newTarget.Model is PortModel targetModel
73+
&& link.IsAttached)
7174
{
72-
(newTarget.Model as PortModel)!.Parent.Refresh();
75+
targetModel.Parent.Refresh();
7376
}
7477
}
7578

7679
private void OnLinkRemoved(BaseLinkModel link)
7780
{
7881
(link.Source.Model as PortModel)!.Parent.Refresh();
79-
if (link.Target != null) (link.Target.Model as PortModel)!.Parent.Refresh();
82+
if (link.Target is SinglePortAnchor anchor && anchor.Model is PortModel portModel)
83+
{
84+
portModel.Parent.Refresh();
85+
}
8086
link.TargetChanged -= OnLinKTargetChanged;
8187
}
8288
}

site/Site/Pages/Documentation/Links/PathGenerators.razor

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ link.PathGenerator = new SmoothPathGenerator();
3535
<h2>Straight Path Generator</h2>
3636

3737
<p>
38-
The <code>StraightPathGenerator</code> generates straight lines.
38+
The <code>StraightPathGenerator</code> generates straight lines.<br />
39+
You can also choose a radius for when the path contains vertices or direction changes.
3940
</p>
4041

4142
<h3>Usage</h3>
@@ -78,12 +79,13 @@ link.PathGenerator = new StraightPathGenerator();
7879
// Straight Path Generator
7980
var stpgNode1 = _stpgDiagram.Nodes.Add(new NodeModel(new Point(150, 50)));
8081
var stpgNode2 = _stpgDiagram.Nodes.Add(new NodeModel(new Point(450, 110)));
81-
var stpgBottomPort1 = stpgNode1.AddPort(PortAlignment.BottomRight);
82+
var stpgBottomPort1 = stpgNode1.AddPort(PortAlignment.Bottom);
8283
var stpgRightPort1 = stpgNode1.AddPort(PortAlignment.Right);
8384
var stpgBottomPort2 = stpgNode2.AddPort(PortAlignment.BottomLeft);
8485
var stpgLeftPort2 = stpgNode2.AddPort(PortAlignment.Left);
85-
_stpgDiagram.Links.Add(new LinkModel(stpgBottomPort1, stpgBottomPort2)).PathGenerator = new StraightPathGenerator();
8686
_stpgDiagram.Links.Add(new LinkModel(stpgRightPort1, stpgLeftPort2)).PathGenerator = new StraightPathGenerator();
87-
87+
var link = _stpgDiagram.Links.Add(new LinkModel(stpgBottomPort1, stpgBottomPort2));
88+
link.PathGenerator = new StraightPathGenerator(10);
89+
link.AddVertex(new Point(200, 250));
8890
}
8991
}

src/Blazor.Diagrams.Algorithms/Blazor.Diagrams.Algorithms.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<PackageLicenseExpression>MIT</PackageLicenseExpression>
88
<Authors>zHaytam</Authors>
99
<Description>Algorithms for Z.Blazor.Diagrams</Description>
10-
<AssemblyVersion>3.0.0</AssemblyVersion>
11-
<FileVersion>3.0.0</FileVersion>
10+
<AssemblyVersion>3.0.1</AssemblyVersion>
11+
<FileVersion>3.0.1</FileVersion>
1212
<RepositoryUrl>https://github.com/zHaytam/Blazor.Diagrams</RepositoryUrl>
13-
<Version>3.0.0</Version>
13+
<Version>3.0.1</Version>
1414
<PackageId>Z.Blazor.Diagrams.Algorithms</PackageId>
1515
<PackageTags>blazor diagrams diagramming svg drag algorithms layouts</PackageTags>
1616
<Product>Z.Blazor.Diagrams.Algorithms</Product>

src/Blazor.Diagrams.Core/Blazor.Diagrams.Core.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<PackageLicenseExpression>MIT</PackageLicenseExpression>
88
<Authors>zHaytam</Authors>
99
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
10-
<AssemblyVersion>3.0.0</AssemblyVersion>
11-
<FileVersion>3.0.0</FileVersion>
10+
<AssemblyVersion>3.0.1</AssemblyVersion>
11+
<FileVersion>3.0.1</FileVersion>
1212
<RepositoryUrl>https://github.com/Blazor-Diagrams/Blazor.Diagrams</RepositoryUrl>
13-
<Version>3.0.0</Version>
13+
<Version>3.0.1</Version>
1414
<PackageId>Z.Blazor.Diagrams.Core</PackageId>
1515
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
1616
<Product>Z.Blazor.Diagrams.Core</Product>

src/Blazor.Diagrams.Core/Controls/Default/RemoveControl.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,44 @@ public RemoveControl(IPositionProvider positionProvider)
2323

2424
public override Point? GetPosition(Model model) => _positionProvider.GetPosition(model);
2525

26-
public override ValueTask OnPointerDown(Diagram diagram, Model model, PointerEventArgs _)
26+
public override async ValueTask OnPointerDown(Diagram diagram, Model model, PointerEventArgs _)
2727
{
28-
switch (model)
28+
if (await ShouldDeleteModel(diagram, model))
2929
{
30+
DeleteModel(diagram, model);
31+
}
32+
}
33+
34+
private static void DeleteModel(Diagram diagram, Model model)
35+
{
36+
switch (model)
37+
{
38+
case GroupModel group:
39+
diagram.Groups.Delete(group);
40+
return;
3041
case NodeModel node:
3142
diagram.Nodes.Remove(node);
32-
break;
43+
return;
44+
3345
case BaseLinkModel link:
3446
diagram.Links.Remove(link);
35-
break;
47+
return;
48+
}
49+
}
50+
51+
private static async ValueTask<bool> ShouldDeleteModel(Diagram diagram, Model model)
52+
{
53+
if (model.Locked)
54+
{
55+
return false;
3656
}
3757

38-
return ValueTask.CompletedTask;
58+
return model switch
59+
{
60+
GroupModel group => await diagram.Options.Constraints.ShouldDeleteGroup.Invoke(group),
61+
NodeModel node => await diagram.Options.Constraints.ShouldDeleteNode.Invoke(node),
62+
BaseLinkModel link => await diagram.Options.Constraints.ShouldDeleteLink.Invoke(link),
63+
_ => false,
64+
};
3965
}
4066
}

src/Blazor.Diagrams.Core/Models/Base/BaseLinkModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ protected BaseLinkModel(string id, Anchor source, Anchor target) : base(id)
3030
public Anchor Source { get; private set; }
3131
public Anchor Target { get; private set; }
3232
public Diagram? Diagram { get; internal set; }
33+
public Point[]? Route { get; private set; }
3334
public PathGeneratorResult? PathGeneratorResult { get; private set; }
3435
public bool IsAttached => Source is not PositionAnchor && Target is not PositionAnchor;
3536
public Router? Router { get; set; }
@@ -129,11 +130,13 @@ private void GeneratePath()
129130
var target = Target.GetPosition(this, route);
130131
if (source != null && target != null)
131132
{
133+
Route = route;
132134
PathGeneratorResult = pathGenerator.GetResult(Diagram, this, route, source, target);
133135
return;
134136
}
135137
}
136138

139+
Route = null;
137140
PathGeneratorResult = null;
138141
}
139142

0 commit comments

Comments
 (0)