Skip to content

Commit 1891a9c

Browse files
Merge pull request #146 from ParameshwaranSF4845/970731-MindMapSample
970731: Adding mindmap orientation example
2 parents 4e2ffaa + 429dd50 commit 1891a9c

34 files changed

+909
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<base href="/" />
8+
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" />
9+
<link rel="stylesheet" href="@Assets["app.css"]" />
10+
<link rel="stylesheet" href="@Assets["MindMapOrientation.styles.css"]" />
11+
<ImportMap />
12+
<link rel="icon" type="image/png" href="favicon.png" />
13+
<HeadOutlet @rendermode="InteractiveServer" />
14+
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
15+
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
16+
</head>
17+
18+
<body>
19+
<Routes @rendermode="InteractiveServer" />
20+
<script src="_framework/blazor.web.js"></script>
21+
</body>
22+
23+
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="page">
4+
<main>
5+
<article class="content px-4">
6+
@Body
7+
</article>
8+
</main>
9+
</div>
10+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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 ::deep .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
text-decoration: none;
28+
}
29+
30+
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
31+
text-decoration: underline;
32+
}
33+
34+
.top-row ::deep a:first-child {
35+
overflow: hidden;
36+
text-overflow: ellipsis;
37+
}
38+
39+
@media (max-width: 640.98px) {
40+
.top-row {
41+
justify-content: space-between;
42+
}
43+
44+
.top-row ::deep a, .top-row ::deep .btn-link {
45+
margin-left: 0;
46+
}
47+
}
48+
49+
@media (min-width: 641px) {
50+
.page {
51+
flex-direction: row;
52+
}
53+
54+
.sidebar {
55+
width: 250px;
56+
height: 100vh;
57+
position: sticky;
58+
top: 0;
59+
}
60+
61+
.top-row {
62+
position: sticky;
63+
top: 0;
64+
z-index: 1;
65+
}
66+
67+
.top-row.auth ::deep a:first-child {
68+
flex: 1;
69+
text-align: right;
70+
width: 0;
71+
}
72+
73+
.top-row, article {
74+
padding-left: 2rem !important;
75+
padding-right: 1.5rem !important;
76+
}
77+
}
78+
79+
#blazor-error-ui {
80+
color-scheme: light only;
81+
background: lightyellow;
82+
bottom: 0;
83+
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
84+
box-sizing: border-box;
85+
display: none;
86+
left: 0;
87+
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
88+
position: fixed;
89+
width: 100%;
90+
z-index: 1000;
91+
}
92+
93+
#blazor-error-ui .dismiss {
94+
cursor: pointer;
95+
position: absolute;
96+
right: 0.75rem;
97+
top: 0.5rem;
98+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
@page "/"
2+
3+
@using Syncfusion.Blazor.Diagram
4+
5+
<SfDiagramComponent @ref="diagram" Height="600px" NodeCreating="OnNodeCreating" ConnectorCreating="OnConnectorCreating">
6+
<RulerSettings>
7+
<HorizontalRuler></HorizontalRuler>
8+
<VerticalRuler></VerticalRuler>
9+
</RulerSettings>
10+
<DataSourceSettings ID="Id" ParentID="ParentId" DataSource="DataSource">
11+
</DataSourceSettings>
12+
<Layout Type="LayoutType.MindMap" @bind-Orientation="SelectedOrientation" GetBranch="GetBranch" HorizontalSpacing="50">
13+
<LayoutMargin Top="20" Left="20"></LayoutMargin>
14+
</Layout>
15+
</SfDiagramComponent>
16+
17+
@code {
18+
private SfDiagramComponent? diagram;
19+
public LayoutOrientation SelectedOrientation { get; set; } = LayoutOrientation.Vertical;
20+
public List<OrientationItem> LayoutOrientationOptions { get; set; } = new()
21+
{
22+
new OrientationItem { Text = "Vertical", Value = LayoutOrientation.Vertical },
23+
new OrientationItem { Text = "Horizontal", Value = LayoutOrientation.Horizontal },
24+
new OrientationItem { Text = "Left to Right", Value = LayoutOrientation.LeftToRight },
25+
new OrientationItem { Text = "Right to Left", Value = LayoutOrientation.RightToLeft }
26+
};
27+
28+
public List<MindMapDetails> DataSource { get; set; } = new()
29+
{
30+
new MindMapDetails { Id = "1", Label = "Project Planning", ParentId = "", Branch = "Root" },
31+
new MindMapDetails { Id = "2", Label = "Requirements", ParentId = "1", Branch = "Right" },
32+
new MindMapDetails { Id = "3", Label = "Design", ParentId = "1", Branch = "Right" },
33+
new MindMapDetails { Id = "5", Label = "Stakeholder Analysis", ParentId = "2", Branch = "SubRight" },
34+
new MindMapDetails { Id = "6", Label = "Documentation", ParentId = "2", Branch = "SubRight" },
35+
new MindMapDetails { Id = "7", Label = "UI Design", ParentId = "3", Branch = "SubRight" },
36+
new MindMapDetails { Id = "8", Label = "Database Design", ParentId = "3", Branch = "SubRight" }
37+
};
38+
39+
private BranchType GetBranch(IDiagramObject obj)
40+
{
41+
if (obj is not Node node)
42+
return BranchType.Left;
43+
if (node.Data is not MindMapDetails mindMapData || string.IsNullOrWhiteSpace(mindMapData.Branch))
44+
return BranchType.Left;
45+
return Enum.TryParse(mindMapData.Branch, out BranchType branchType)
46+
? branchType
47+
: BranchType.SubLeft;
48+
}
49+
50+
// Method triggered by button click at runtime to set diagram orientation to vertical.
51+
private void ChangeLayoutOrientation()
52+
{
53+
diagram.Layout.Orientation = LayoutOrientation.Vertical;
54+
}
55+
56+
private void OnNodeCreating(IDiagramObject obj)
57+
{
58+
if (obj is not Node node)
59+
return;
60+
// Apply default node styling.
61+
node.Height = 100;
62+
node.Width = 100;
63+
node.BackgroundColor = "#6BA5D7";
64+
node.Style = new ShapeStyle
65+
{
66+
Fill = "#6495ED",
67+
StrokeWidth = 1,
68+
StrokeColor = "white"
69+
};
70+
node.Shape = new BasicShape { Type = NodeShapes.Basic };
71+
// Add annotation with label from data.
72+
if (node.Data is MindMapDetails mindMapData && !string.IsNullOrWhiteSpace(mindMapData.Label))
73+
{
74+
node.Annotations = new DiagramObjectCollection<ShapeAnnotation>
75+
{
76+
new ShapeAnnotation { Content = mindMapData.Label }
77+
};
78+
}
79+
}
80+
81+
private void OnConnectorCreating(IDiagramObject obj)
82+
{
83+
if (obj is not Connector connector)
84+
return;
85+
connector.Type = ConnectorSegmentType.Bezier;
86+
connector.Style = new ShapeStyle
87+
{
88+
StrokeColor = "#6495ED",
89+
StrokeWidth = 2
90+
};
91+
connector.TargetDecorator = new DecoratorSettings
92+
{
93+
Shape = DecoratorShape.None
94+
};
95+
}
96+
97+
public class OrientationItem
98+
{
99+
public string Text { get; set; } = string.Empty;
100+
public LayoutOrientation Value { get; set; }
101+
}
102+
103+
public class MindMapDetails
104+
{
105+
public string Id { get; set; } = string.Empty;
106+
public string Label { get; set; } = string.Empty;
107+
public string ParentId { get; set; } = string.Empty;
108+
public string Branch { get; set; } = string.Empty;
109+
public string Fill { get; set; } = string.Empty;
110+
}
111+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Router AppAssembly="typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
4+
<FocusOnNavigate RouteData="routeData" Selector="h1" />
5+
</Found>
6+
</Router>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@using System.Net.Http
2+
@using System.Net.Http.Json
3+
@using Microsoft.AspNetCore.Components.Forms
4+
@using Microsoft.AspNetCore.Components.Routing
5+
@using Microsoft.AspNetCore.Components.Web
6+
@using static Microsoft.AspNetCore.Components.Web.RenderMode
7+
@using Microsoft.AspNetCore.Components.Web.Virtualization
8+
@using Microsoft.JSInterop
9+
@using MindMapOrientation
10+
@using MindMapOrientation.Components
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: 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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using MindMapOrientation.Components;
2+
using Syncfusion.Blazor;
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
// Add services to the container.
6+
builder.Services.AddRazorComponents()
7+
.AddInteractiveServerComponents();
8+
builder.Services.AddSyncfusionBlazor();
9+
10+
var app = builder.Build();
11+
12+
// Configure the HTTP request pipeline.
13+
if (!app.Environment.IsDevelopment())
14+
{
15+
app.UseExceptionHandler("/Error", createScopeForErrors: true);
16+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
17+
app.UseHsts();
18+
}
19+
20+
app.UseHttpsRedirection();
21+
22+
23+
app.UseAntiforgery();
24+
25+
app.MapStaticAssets();
26+
app.MapRazorComponents<App>()
27+
.AddInteractiveServerRenderMode();
28+
29+
app.Run();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "http://localhost:5128",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": true,
17+
"applicationUrl": "https://localhost:7001;http://localhost:5128",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)