Skip to content

Commit 09a7f09

Browse files
authored
Merge pull request #89 from RamyaSubramaniSF4537/ES-1048325-Examples
1048325: Added Examples
2 parents d74e92a + e904d28 commit 09a7f09

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@page "/AddAsyncMethod"
2+
3+
@using Syncfusion.Blazor.Diagram
4+
@using Syncfusion.Blazor.Buttons
5+
6+
<SfButton Content="Add Port and Annotation" OnClick="@AddPortAndAnnotationAsync" />
7+
8+
<SfDiagramComponent @ref="_diagram" Width="900px" Height="500px" Nodes="@_nodes" Connectors="@_connectors">
9+
</SfDiagramComponent>
10+
11+
@code
12+
{
13+
// Reference the diagram.
14+
private SfDiagramComponent _diagram;
15+
16+
// Initialize the nodes and connectors collections.
17+
private DiagramObjectCollection<Node> _nodes = new DiagramObjectCollection<Node>();
18+
private DiagramObjectCollection<Connector> _connectors = new DiagramObjectCollection<Connector>();
19+
20+
protected override void OnInitialized()
21+
{
22+
Node node = new Node()
23+
{
24+
ID = "node1",
25+
OffsetX = 300,
26+
OffsetY = 200,
27+
Width = 120,
28+
Height = 60,
29+
Style = new ShapeStyle() { Fill = "#6495ED", StrokeColor = "#6495ED" },
30+
Shape = new BasicShape() { Type = NodeShapes.Basic, Shape = NodeBasicShapes.Rectangle },
31+
};
32+
33+
_nodes.Add(node);
34+
}
35+
36+
private async Task AddPortAndAnnotationAsync()
37+
{
38+
Node node = _diagram.Nodes[0];
39+
40+
await node.Ports.AddAsync(new PointPort()
41+
{
42+
ID = "port1",
43+
Offset = new DiagramPoint() { X = 1, Y = 0.5 },
44+
Visibility = PortVisibility.Visible,
45+
Height = 10,
46+
Width = 10,
47+
Style = new ShapeStyle() { Fill = "#FFFFFF", StrokeColor = "#1F3A93" },
48+
Shape = PortShapes.Custom,
49+
// Sets the PathData for port.
50+
PathData = "M540.3643,137.9336L546.7973,159.7016L570.3633,159.7296L550.7723,171.9366L558.9053,194.9966L540.3643,179.4996L521.8223,194.9966L529.9553,171.9366L510.3633,159.7296L533.9313,159.7016L540.3643,137.9336z"
51+
});
52+
53+
await node.Annotations.AddAsync(new ShapeAnnotation()
54+
{
55+
Content = "Node 1",
56+
Offset = new DiagramPoint() { X = 0.5, Y = 0.5 }
57+
});
58+
}
59+
}

‎Diagram/Server/Pages/Methods/AddDiagramElements.razor‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,42 @@
8484
// Type of the connector
8585
Type = ConnectorSegmentType.Straight,
8686
};
87+
Swimlane swimlane = new Swimlane()
88+
{
89+
ID = "swimlane1",
90+
OffsetX = 650,
91+
OffsetY = 200,
92+
Height = 150,
93+
Width = 450,
94+
Header = new SwimlaneHeader()
95+
{
96+
Annotation = new ShapeAnnotation() { Content = "Sales Process" },
97+
Height = 50,
98+
},
99+
Lanes = new DiagramObjectCollection<Lane>()
100+
{
101+
new Lane()
102+
{
103+
ID = "lane1",
104+
Height = 100,
105+
Header = new SwimlaneHeader()
106+
{
107+
Width = 30,
108+
Annotation = new ShapeAnnotation() { Content = "Consumer" }
109+
},
110+
Children = new DiagramObjectCollection<Node>()
111+
{
112+
new Node(){Height = 50, Width = 50, LaneOffsetX = 100, LaneOffsetY = 30},
113+
new Node(){Height = 50, Width = 50, LaneOffsetX = 250, LaneOffsetY = 30},
114+
}
115+
}
116+
}
117+
};
87118
DiagramObjectCollection<NodeBase> nodeCollection = new DiagramObjectCollection<NodeBase>();
88119
nodeCollection.Add(node1);
89120
nodeCollection.Add(node2);
90121
nodeCollection.Add(Connector);
122+
nodeCollection.Add(swimlane);
91123
await _diagram.AddDiagramElementsAsync(nodeCollection);
92124
}
93125
}

0 commit comments

Comments
 (0)