Skip to content

Commit 051236a

Browse files
965210: Missing Public API Sample in Blazor UG Documentation
1 parent 0ed7612 commit 051236a

28 files changed

+1221
-0
lines changed
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@namespace PrintUsingClipBounds
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>
14+
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
@page "/"
2+
@using Syncfusion.Blazor.Diagram
3+
@using Syncfusion.Blazor.Buttons
4+
5+
<SfButton Content="Print" OnClick="@OnPrint" />
6+
<SfDiagramComponent Height="600px" @ref="@diagram" NodeCreating="NodeCreating" ConnectorCreating="ConnectorCreating">
7+
<PageSettings MultiplePage="true" Width="@width" Height="@height" Orientation="@orientation" ShowPageBreaks="@showPageBreak">
8+
<PageMargin Left="@left" Right="@right" Top="@top" Bottom="@bottom"></PageMargin>
9+
</PageSettings>
10+
<DataSourceSettings DataSource="DataSource" ID="Id" ParentID="Manager"></DataSourceSettings>
11+
<Layout @bind-Type="type" @bind-HorizontalSpacing="@HorizontalSpacing" @bind-FixedNode="@FixedNode" @bind-Orientation="@oreintation" @bind-VerticalSpacing="@VerticalSpacing" @bind-HorizontalAlignment="@horizontalAlignment" @bind-VerticalAlignment="@verticalAlignment">
12+
<LayoutMargin @bind-Top="@lTop" @bind-Bottom="@lBottom" @bind-Right="@lRight" @bind-Left="@lLeft"></LayoutMargin>
13+
</Layout>
14+
<SnapSettings></SnapSettings>
15+
</SfDiagramComponent>
16+
17+
@code {
18+
19+
//Reference the diagram
20+
SfDiagramComponent diagram;
21+
double left = 10;
22+
double top = 10;
23+
double right = 10;
24+
double bottom = 10;
25+
double width = 410;
26+
double height = 550;
27+
28+
bool multiplePage = true;
29+
bool showPageBreak = true;
30+
DiagramPrintExportRegion region = DiagramPrintExportRegion.ClipBounds;
31+
PageOrientation orientation = PageOrientation.Landscape;
32+
//Method to prin the diagram
33+
private async Task OnPrint()
34+
{
35+
DiagramPrintSettings print = new DiagramPrintSettings();
36+
print.ClipBounds = new DiagramRect() { Height = 300, Width = 500, X = 300, Y = 200 };
37+
print.Region = region;
38+
print.FitToPage = multiplePage;
39+
print.Orientation = orientation;
40+
await diagram.PrintAsync(print);
41+
}
42+
43+
double lTop = 50;
44+
double lBottom = 50;
45+
double lRight = 50;
46+
double lLeft = 50;
47+
LayoutType type = LayoutType.OrganizationalChart;
48+
LayoutOrientation oreintation = LayoutOrientation.TopToBottom;
49+
HorizontalAlignment horizontalAlignment = HorizontalAlignment.Auto;
50+
VerticalAlignment verticalAlignment = VerticalAlignment.Auto;
51+
int HorizontalSpacing = 30;
52+
int VerticalSpacing = 30;
53+
private string FixedNode = null;
54+
public class HierarchicalDetails
55+
{
56+
public string Id { get; set; }
57+
public string Role { get; set; }
58+
public string Manager { get; set; }
59+
public string ChartType { get; set; }
60+
public string Color { get; set; }
61+
}
62+
public List<HierarchicalDetails> DataSource = new List<HierarchicalDetails>()
63+
{
64+
new HierarchicalDetails() { Id= "parent", Role= "Board", Color= "#71AF17" },
65+
new HierarchicalDetails() { Id= "1", Role= "General Manager", Manager= "parent", ChartType= "right", Color= "#71AF17" },
66+
new HierarchicalDetails() { Id= "11", Role= "Assistant Manager", Manager= "1", Color= "#71AF17" },
67+
new HierarchicalDetails() { Id= "2", Role= "Human Resource Manager", Manager= "1", ChartType= "right", Color= "#1859B7" },
68+
new HierarchicalDetails() { Id= "3", Role= "Trainers", Manager= "2", Color= "#2E95D8" },
69+
new HierarchicalDetails() { Id= "4", Role= "Recruiting Team", Manager= "2", Color= "#2E95D8" },
70+
new HierarchicalDetails() { Id= "5", Role= "Finance Asst. Manager", Manager= "2", Color= "#2E95D8" },
71+
new HierarchicalDetails() { Id= "6", Role= "Design Manager", Manager= "1",ChartType= "right", Color= "#1859B7" },
72+
new HierarchicalDetails() { Id= "7", Role= "Design Supervisor", Manager= "6", Color= "#2E95D8" },
73+
new HierarchicalDetails() { Id= "8", Role= "Development Supervisor", Manager= "6", Color= "#2E95D8" },
74+
new HierarchicalDetails() { Id= "9", Role= "Drafting Supervisor", Manager= "6", Color= "#2E95D8" },
75+
new HierarchicalDetails() { Id= "10", Role= "Operation Manager", Manager= "1", ChartType= "right", Color= "#1859B7" },
76+
new HierarchicalDetails() { Id= "11", Role= "Statistic Department", Manager= "10", Color= "#2E95D8" },
77+
new HierarchicalDetails() { Id= "12", Role= "Logistic Department", Manager= "10", Color= "#2E95D8" },
78+
new HierarchicalDetails() { Id= "16", Role= "Marketing Manager", Manager= "1", ChartType= "right", Color= "#1859B7" },
79+
new HierarchicalDetails() { Id= "17", Role= "Oversea sales Manager", Manager= "16", Color= "#2E95D8" },
80+
new HierarchicalDetails() { Id= "18", Role= "Petroleum Manager", Manager= "16", Color= "#2E95D8" },
81+
new HierarchicalDetails() { Id= "20", Role= "Service Dept. Manager", Manager= "16", Color= "#2E95D8" },
82+
new HierarchicalDetails() { Id= "21", Role= "Quality Department", Manager= "16", Color= "#2E95D8" }
83+
84+
};
85+
86+
private void NodeCreating(IDiagramObject obj)
87+
{
88+
Node node = obj as Node;
89+
if (node.Data is System.Text.Json.JsonElement)
90+
{
91+
node.Data = System.Text.Json.JsonSerializer.Deserialize<HierarchicalDetails>(node.Data.ToString());
92+
}
93+
HierarchicalDetails hierarchicalData = node.Data as HierarchicalDetails;
94+
node.Width = 150;
95+
node.Height = 50;
96+
node.Style.Fill = hierarchicalData.Color;
97+
// node.IsVisible = false;
98+
node.Annotations = new DiagramObjectCollection<ShapeAnnotation>()
99+
{
100+
new ShapeAnnotation()
101+
{
102+
Content = hierarchicalData.Role,
103+
Style =new TextStyle(){Color = "white"}
104+
}
105+
};
106+
}
107+
private void ConnectorCreating(IDiagramObject connector)
108+
{
109+
(connector as Connector).Type = ConnectorSegmentType.Orthogonal;
110+
(connector as Connector).TargetDecorator.Shape = DecoratorShape.None;
111+
}
112+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page "/"
2+
@namespace PrintUsingClipBounds.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@{
5+
Layout = "_Layout";
6+
}
7+
8+
<component type="typeof(App)" render-mode="ServerPrerendered" />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@using Microsoft.AspNetCore.Components.Web
2+
@namespace PrintUsingClipBounds.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
5+
<!DOCTYPE html>
6+
<html lang="en">
7+
<head>
8+
<meta charset="utf-8" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
10+
<base href="~/" />
11+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
12+
<link href="css/site.css" rel="stylesheet" />
13+
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
14+
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
15+
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
16+
</head>
17+
<body>
18+
@RenderBody()
19+
20+
21+
22+
<script src="_framework/blazor.server.js"></script>
23+
</body>
24+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk.Web">
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Syncfusion.Blazor.Diagram" Version="*" />
10+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<Folder Include="wwwroot\" />
14+
</ItemGroup>
15+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk.Web">
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Syncfusion.Blazor.Diagram" Version="*" />
10+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<Folder Include="wwwroot\" />
14+
</ItemGroup>
15+
</Project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
using Microsoft.AspNetCore.Components;
3+
using Microsoft.AspNetCore.Components.Web;
4+
using Syncfusion.Blazor;
5+
6+
var builder = WebApplication.CreateBuilder(args);
7+
8+
// Add services to the container.
9+
builder.Services.AddRazorPages();
10+
builder.Services.AddServerSideBlazor();
11+
builder.Services.AddSyncfusionBlazor();
12+
13+
var app = builder.Build();
14+
15+
// Configure the HTTP request pipeline.
16+
if (!app.Environment.IsDevelopment())
17+
{
18+
app.UseExceptionHandler("/Error");
19+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
20+
app.UseHsts();
21+
}
22+
23+
app.UseHttpsRedirection();
24+
25+
app.UseStaticFiles();
26+
27+
app.UseRouting();
28+
29+
app.MapBlazorHub();
30+
app.MapFallbackToPage("/_Host");
31+
32+
app.Run();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:11920",
7+
"sslPort": 44341
8+
}
9+
},
10+
"profiles": {
11+
"PrintUsingClipBounds": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:7204;http://localhost:5236",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"IIS Express": {
21+
"commandName": "IISExpress",
22+
"launchBrowser": true,
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
}
27+
}
28+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@namespace PrintUsingClipBounds.Shared
2+
@inherits LayoutComponentBase
3+
4+
<PageTitle>PrintUsingClipBounds</PageTitle>
5+
6+
<div class="page">
7+
<div class="sidebar">
8+
<NavMenu />
9+
</div>
10+
11+
12+
<main>
13+
14+
<article class="content px-4">
15+
@Body
16+
</article>
17+
</main>
18+
</div>

0 commit comments

Comments
 (0)