Skip to content

Commit 9a136ea

Browse files
committed
959721: ZoomPanWithDoLayout
1 parent ae6fe9c commit 9a136ea

14 files changed

+305
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@namespace ZoomPanWithDoLayout
2+
<Router AppAssembly="@typeof(App).Assembly">
3+
<Found Context="routeData">
4+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
5+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
6+
</Found>
7+
<NotFound>
8+
<PageTitle>Not found</PageTitle>
9+
<LayoutView Layout="@typeof(MainLayout)">
10+
<p role="alert">Sorry, there's nothing at this address.</p>
11+
</LayoutView>
12+
</NotFound>
13+
</Router>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@inherits LayoutComponentBase
2+
@namespace ZoomPanWithDoLayout
3+
<main> @Body </main>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@page "/"
2+
@using Syncfusion.Blazor.Diagram
3+
4+
5+
<SfDiagramComponent @ref="@diagram" Height="600px" Nodes="@nodes" Connectors="@connectors" NodeCreating="@OnNodeCreating" ConnectorCreating="@OnConnectorCreating" InteractionController="DiagramInteractions.ZoomPan">
6+
<Layout Type="LayoutType.HierarchicalTree" @bind-HorizontalSpacing="@HorizontalSpacing" @bind-VerticalSpacing="@VerticalSpacing">
7+
</Layout>
8+
<SnapSettings>
9+
<HorizontalGridLines LineColor="white" LineDashArray="2,2">
10+
</HorizontalGridLines>
11+
<VerticalGridLines LineColor="white" LineDashArray="2,2">
12+
</VerticalGridLines>
13+
</SnapSettings>
14+
</SfDiagramComponent>
15+
<button @onclick="Dolayout">Dolayout</button>
16+
<button @onclick="ChangeLayout">Change Data Source</button>
17+
<button @onclick="NodeDrag">NodeDrag</button>
18+
<button @onclick="NodeRotate">NodeRotate</button>
19+
@code
20+
{
21+
SfDiagramComponent? diagram;
22+
23+
int left = 40;
24+
int top = 50;
25+
DiagramObjectCollection<Node> nodes = new DiagramObjectCollection<Node>();
26+
DiagramObjectCollection<Connector> connectors = new DiagramObjectCollection<Connector>();
27+
int HorizontalSpacing = 40;
28+
int VerticalSpacing = 40;
29+
30+
private void OnNodeCreating(IDiagramObject obj)
31+
{
32+
Node node = obj as Node;
33+
node.Height = 40;
34+
// node.Constraints = NodeConstraints.Default & ~NodeConstraints.Select;
35+
36+
node.Width = 100;
37+
node.Style = new ShapeStyle() { Fill = "darkcyan", StrokeWidth = 3, StrokeColor = "Black" };
38+
node.Annotations[0].Style = new TextStyle() { Color = "white", Bold = true };
39+
}
40+
41+
private void OnConnectorCreating(IDiagramObject connector)
42+
{
43+
(connector as Connector).Type = ConnectorSegmentType.Orthogonal;
44+
}
45+
46+
protected override void OnInitialized()
47+
{
48+
nodes = new DiagramObjectCollection<Node>()
49+
{
50+
new Node() { ID="node1", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Steve-Ceo"} }, },
51+
new Node() { ID="node2", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Kevin-Manager"} }, },
52+
new Node() { ID="node3", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Peter-Manager"} }, },
53+
new Node() { ID="node4", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Jim-CSE"} }, },
54+
new Node() { ID="node5", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Martin-CSE"} } , },
55+
new Node() { ID="node6", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="John-Manager"} } , },
56+
new Node() { ID="node7", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Mary-CSE"} } , },
57+
};
58+
connectors = new DiagramObjectCollection<Connector>()
59+
{
60+
new Connector() { ID="connector1", SourceID="node1", TargetID="node2" },
61+
new Connector() { ID="connector2", SourceID="node1", TargetID="node3" },
62+
new Connector() { ID="connector3", SourceID="node2", TargetID="node4" },
63+
new Connector() { ID="connector4", SourceID="node2", TargetID="node5" },
64+
new Connector() { ID="connector5", SourceID="node3", TargetID="node6" },
65+
new Connector() { ID="connector6", SourceID="node3", TargetID="node7" },
66+
};
67+
}
68+
69+
private async Task ChangeLayout()
70+
{
71+
nodes = new DiagramObjectCollection<Node>()
72+
{
73+
new Node() { ID="node1", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Steve-Ceo"} }, },
74+
new Node() { ID="node2", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Kevin-Manager"} }, },
75+
new Node() { ID="node3", Annotations = new DiagramObjectCollection<ShapeAnnotation>() { new ShapeAnnotation{Content="Peter-Manager"} }, },
76+
};
77+
78+
connectors = new DiagramObjectCollection<Connector>()
79+
{
80+
new Connector() { ID="connector1", SourceID="node1", TargetID="node2" },
81+
new Connector() { ID="connector2", SourceID="node1", TargetID="node3" },
82+
};
83+
84+
}
85+
private async Task Dolayout()
86+
{
87+
await diagram?.DoLayoutAsync();
88+
}
89+
90+
private async void NodeDrag()
91+
{
92+
diagram.BeginUpdate();
93+
diagram.Nodes[0].OffsetX = 400;
94+
await diagram.EndUpdateAsync();
95+
}
96+
97+
private async Task NodeRotate()
98+
{
99+
diagram.BeginUpdate();
100+
diagram.Nodes[0].RotationAngle = 40;
101+
await diagram.EndUpdateAsync();
102+
}
103+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@page "/"
2+
@using Microsoft.AspNetCore.Components.Web
3+
@namespace ZoomPanWithDoLayout.Pages
4+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
5+
6+
<!DOCTYPE html>
7+
<html lang="en">
8+
<head>
9+
<meta charset="utf-8" />
10+
<base href="~/" />
11+
<link href="css/site.css" rel="stylesheet" />
12+
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.3.css" rel="stylesheet" />
13+
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
14+
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
15+
</head>
16+
<body>
17+
<component type="typeof(App)" render-mode="ServerPrerendered" />
18+
19+
<div id="blazor-error-ui">
20+
<environment include="Staging,Production">
21+
An error has occurred. This application may no longer respond until reloaded.
22+
</environment>
23+
<environment include="Development">
24+
An unhandled exception has occurred. See browser dev tools for details.
25+
</environment>
26+
<a href="" class="reload">Reload</a>
27+
<a class="dismiss">🗙</a>
28+
</div>
29+
30+
<script src="_framework/blazor.server.js"></script>
31+
</body>
32+
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.AspNetCore.Components;
2+
using Microsoft.AspNetCore.Components.Web;
3+
using Syncfusion.Blazor;
4+
var builder = WebApplication.CreateBuilder(args);
5+
builder.Services.AddRazorPages();
6+
builder.Services.AddServerSideBlazor();
7+
builder.Services.AddSyncfusionBlazor();
8+
builder.Services.AddSignalR(e => {
9+
e.MaximumReceiveMessageSize = 102400000;
10+
});
11+
var app = builder.Build();
12+
13+
if (!app.Environment.IsDevelopment())
14+
{
15+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
16+
app.UseHsts();
17+
}
18+
19+
app.UseHttpsRedirection();
20+
21+
app.UseStaticFiles();
22+
23+
app.UseRouting();
24+
25+
app.MapBlazorHub();
26+
app.MapFallbackToPage("/_Host");
27+
28+
app.Run();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"iisSettings": {
3+
"iisExpress": {
4+
"applicationUrl": "http://localhost:18318",
5+
"sslPort": 44368
6+
}
7+
},
8+
"profiles": {
9+
"http": {
10+
"commandName": "Project",
11+
"dotnetRunMessages": true,
12+
"launchBrowser": true,
13+
"applicationUrl": "http://localhost:5048",
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"https": {
19+
"commandName": "Project",
20+
"dotnetRunMessages": true,
21+
"launchBrowser": true,
22+
"applicationUrl": "https://localhost:7088;http://localhost:5048",
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
},
27+
"IIS Express": {
28+
"commandName": "IISExpress",
29+
"launchBrowser": true,
30+
"environmentVariables": {
31+
"ASPNETCORE_ENVIRONMENT": "Development"
32+
}
33+
}
34+
}
35+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.Blazor.Diagram" Version="*" />
11+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>https</ActiveDebugProfile>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.Blazor.Diagram" Version="*" />
11+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>https</ActiveDebugProfile>
5+
</PropertyGroup>
6+
</Project>

0 commit comments

Comments
 (0)