Skip to content

Commit 6a2d7b6

Browse files
Merge pull request #141 from BalaVigneshRaviChandran/ES-965210-APIExplanation
965210: Missing Public API Sample in Blazor UG Documentation
2 parents 549b357 + 051236a commit 6a2d7b6

File tree

298 files changed

+12973
-0
lines changed

Some content is hidden

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

298 files changed

+12973
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@namespace CurrentSelection
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: 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: 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>net9.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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@page "/"
2+
@using Syncfusion.Blazor.Diagram
3+
@using Syncfusion.Blazor.Buttons
4+
@using SelectionChangedEventArgs = Syncfusion.Blazor.Diagram.SelectionChangedEventArgs
5+
6+
<SfButton Content="GetSelectionInfo" OnClick="GetSelectionInfo"></SfButton>
7+
<SfDiagramComponent @ref="diagram" Height="600px" Nodes="@NodeCollection" Connectors="@ConnectorCollection" SelectionChanged="OnSelectionChanged">
8+
</SfDiagramComponent>
9+
@code {
10+
SfDiagramComponent diagram;
11+
//Initailize the diagram's nodes collection
12+
public DiagramObjectCollection<Node> NodeCollection = new DiagramObjectCollection<Node>();
13+
//Initailize the diagram's connector collection
14+
public DiagramObjectCollection<Connector> ConnectorCollection = new DiagramObjectCollection<Connector>();
15+
protected override void OnInitialized()
16+
{
17+
Node node1 = new Node()
18+
{
19+
OffsetX = 100,
20+
OffsetY = 200,
21+
Height = 100,
22+
Width = 100,
23+
ID = "node1",
24+
};
25+
NodeCollection.Add(node1);
26+
Connector connector1 = new Connector()
27+
{
28+
ID = "connector1",
29+
SourcePoint = new DiagramPoint() { X = 300, Y = 100 },
30+
TargetPoint = new DiagramPoint() { X = 400, Y = 300 },
31+
Type = ConnectorSegmentType.Orthogonal
32+
};
33+
ConnectorCollection.Add(connector1);
34+
}
35+
//Event to notify selection changing event after selected the nodes/conenctors in diagram.
36+
private void OnSelectionChanged(SelectionChangedEventArgs args)
37+
{
38+
if (diagram.SelectionSettings.Nodes.Count > 0)
39+
{
40+
Node selectedNode = diagram.SelectionSettings.Nodes[0];
41+
//Here you can modified the selected node.
42+
}
43+
if (diagram.SelectionSettings.Connectors.Count > 0)
44+
{
45+
Connector selectedConnector = diagram.SelectionSettings.Connectors[0];
46+
//Here you can modified the selected connector.
47+
}
48+
}
49+
50+
// Method to get current selection information
51+
private void GetSelectionInfo()
52+
{
53+
// Get selected nodes
54+
var selectedNodes = diagram.SelectionSettings.Nodes;
55+
foreach (var node in selectedNodes)
56+
{
57+
Console.WriteLine($"Selected Node ID: {node.ID}");
58+
Console.WriteLine($"Node OffsetX: {node.OffsetX}");
59+
Console.WriteLine($"Node OffsetY: {node.OffsetY}");
60+
Console.WriteLine($"Node Width: {node.Width}");
61+
Console.WriteLine($"Node Height: {node.Height}");
62+
Console.WriteLine($"Node Rotation: {node.RotationAngle}");
63+
}
64+
65+
// Get selected connectors
66+
var selectedConnectors = diagram.SelectionSettings.Connectors;
67+
foreach (var connector in selectedConnectors)
68+
{
69+
Console.WriteLine($"Selected Connector ID: {connector.ID}");
70+
Console.WriteLine($"Connector SourcePoint: X={connector.SourcePoint.X}, Y={connector.SourcePoint.Y}");
71+
Console.WriteLine($"Connector TargetPoint: X={connector.TargetPoint.X}, Y={connector.TargetPoint.Y}");
72+
}
73+
74+
// Get selection bounds information
75+
Console.WriteLine($"Selection OffsetX: {diagram.SelectionSettings.OffsetX}");
76+
Console.WriteLine($"Selection OffsetY: {diagram.SelectionSettings.OffsetY}");
77+
Console.WriteLine($"Selection Width: {diagram.SelectionSettings.Width}");
78+
Console.WriteLine($"Selection Height: {diagram.SelectionSettings.Height}");
79+
Console.WriteLine($"Selection Rotation: {diagram.SelectionSettings.RotationAngle}");
80+
Console.WriteLine($"Selection Pivot: {diagram.SelectionSettings.Pivot}");
81+
}
82+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page "/"
2+
@namespace CurrentSelection.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 CurrentSelection.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: 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+
"DiagramSelectionEvent": {
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 CurrentSelection.Shared
2+
@inherits LayoutComponentBase
3+
4+
<PageTitle>DiagramSelectionEvent</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>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
}
28+
29+
.top-row a:first-child {
30+
overflow: hidden;
31+
text-overflow: ellipsis;
32+
}
33+
34+
@media (max-width: 640.98px) {
35+
.top-row:not(.auth) {
36+
display: none;
37+
}
38+
39+
.top-row.auth {
40+
justify-content: space-between;
41+
}
42+
43+
.top-row a, .top-row .btn-link {
44+
margin-left: 0;
45+
}
46+
}
47+
48+
@media (min-width: 641px) {
49+
.page {
50+
flex-direction: row;
51+
}
52+
53+
.sidebar {
54+
width: 250px;
55+
height: 100vh;
56+
position: sticky;
57+
top: 0;
58+
}
59+
60+
.top-row {
61+
position: sticky;
62+
top: 0;
63+
z-index: 1;
64+
}
65+
66+
.top-row, article {
67+
padding-left: 2rem !important;
68+
padding-right: 1.5rem !important;
69+
}
70+
}

0 commit comments

Comments
 (0)