Skip to content

Commit 914ffaf

Browse files
Merge pull request #95 from SatishRaj4377/WPF-946687-Sequence_Diagram_Example
WPF-946687-Updated the Sequence Diagram Example
2 parents d89d3cd + 83c1efb commit 914ffaf

15 files changed

+777
-0
lines changed

Samples/Sequence Diagram/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Sequence Diagram Sample
2+
This sample demonstrate How to create a Sequence Diagram using UMLSequenceDiagramModel.
3+
4+
__*Documentation*__: https://help.syncfusion.com/wpf/diagram/uml_sequence_diagram#Sequence-Diagram.md
5+
6+
## Project pre-requisites
7+
To run this application, you need to have the below two in your system
8+
9+
* [Visual Studio 2019](https://www.visualstudio.com/wpf-vs)
10+
* [Syncfusion.SfDiagram.WPF](https://www.nuget.org/packages/Syncfusion.SfDiagram.WPF/) nuget package. To install the package using NuGet Package Manager, refer this [link](https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio#nuget-package-manager).
11+
12+
## Deploying and running the sample
13+
* To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.
14+
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+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
5+
</startup>
6+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="SequenceDiagram.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:SequenceDiagram"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace SequenceDiagram
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
<Window x:Class="SequenceDiagram.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:SequenceDiagram"
7+
mc:Ignorable="d" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" xmlns:sys="clr-namespace:System;assembly=mscorlib"
8+
Title="Sequence Diagram" Height="450" Width="800" WindowState="Maximized">
9+
<Grid x:Name="grid">
10+
<Grid.ColumnDefinitions>
11+
<ColumnDefinition Width="9*" />
12+
<ColumnDefinition Width="4*" />
13+
</Grid.ColumnDefinitions>
14+
15+
<!-- SfDiagram control to render the diagram -->
16+
<syncfusion:SfDiagram x:Name="Diagram" Grid.Column="0">
17+
<syncfusion:SfDiagram.Model>
18+
<syncfusion:UMLSequenceDiagramModel SpaceBetweenParticipants="300">
19+
20+
<!-- Define Participants -->
21+
<syncfusion:UMLSequenceDiagramModel.Participants>
22+
<syncfusion:ParticipantCollection>
23+
<!-- Customer initiates the order -->
24+
<syncfusion:UMLSequenceParticipant ID="Customer" Content="Customer" IsActor="True" />
25+
26+
<!-- Order Processing System -->
27+
<syncfusion:UMLSequenceParticipant ID="OrderSystem" Content="Order System" IsActor="False" />
28+
29+
<!-- Payment Gateway -->
30+
<syncfusion:UMLSequenceParticipant ID="PaymentGateway" Content="Payment Gateway" IsActor="False" />
31+
</syncfusion:ParticipantCollection>
32+
</syncfusion:UMLSequenceDiagramModel.Participants>
33+
34+
<!-- Define Messages -->
35+
<syncfusion:UMLSequenceDiagramModel.Messages>
36+
<syncfusion:MessageCollection>
37+
<!-- Customer places an order -->
38+
<syncfusion:UMLSequenceMessage ID="MSG1"
39+
Content="Place Order"
40+
FromParticipantID="Customer"
41+
ToParticipantID="OrderSystem"
42+
Type="Synchronous" />
43+
44+
<!-- System checks if the item is in stock -->
45+
<syncfusion:UMLSequenceMessage ID="MSG2"
46+
Content="Check Stock Availability"
47+
FromParticipantID="OrderSystem"
48+
ToParticipantID="OrderSystem"
49+
Type="Synchronous" />
50+
51+
<!-- System confirms stock is available -->
52+
<syncfusion:UMLSequenceMessage ID="MSG3"
53+
Content="Stock Available"
54+
FromParticipantID="OrderSystem"
55+
ToParticipantID="Customer"
56+
Type="Reply" />
57+
58+
<!-- System requests payment processing -->
59+
<syncfusion:UMLSequenceMessage ID="MSG4"
60+
Content="Process Payment"
61+
FromParticipantID="OrderSystem"
62+
ToParticipantID="PaymentGateway"
63+
Type="Synchronous" />
64+
65+
<!-- Payment success message -->
66+
<syncfusion:UMLSequenceMessage ID="MSG5"
67+
Content="Payment Successful"
68+
FromParticipantID="PaymentGateway"
69+
ToParticipantID="OrderSystem"
70+
Type="Reply" />
71+
72+
<!-- System confirms order processing -->
73+
<syncfusion:UMLSequenceMessage ID="MSG6"
74+
Content="Order Confirmed and Shipped"
75+
FromParticipantID="OrderSystem"
76+
ToParticipantID="Customer"
77+
Type="Reply" />
78+
79+
<!-- Payment failure message -->
80+
<syncfusion:UMLSequenceMessage ID="MSG7"
81+
Content="Payment Failed"
82+
FromParticipantID="PaymentGateway"
83+
ToParticipantID="OrderSystem"
84+
Type="Reply" />
85+
86+
<!-- Retry payment message -->
87+
<syncfusion:UMLSequenceMessage ID="MSG8"
88+
Content="Retry Payment"
89+
FromParticipantID="OrderSystem"
90+
ToParticipantID="Customer"
91+
Type="Reply" />
92+
93+
</syncfusion:MessageCollection>
94+
</syncfusion:UMLSequenceDiagramModel.Messages>
95+
96+
<!-- Define Fragments -->
97+
<syncfusion:UMLSequenceDiagramModel.Fragments>
98+
<syncfusion:FragmentCollection>
99+
<!-- Loop Fragment: Retry payment attempts -->
100+
<syncfusion:UMLSequenceFragment ID="Frag3" Type="Loop">
101+
<syncfusion:UMLSequenceFragment.Conditions>
102+
<syncfusion:ConditionCollection>
103+
<syncfusion:UMLSequenceFragmentCondition Content="[while attempts less than 3]">
104+
<!--Nested Fragments Inside Loop Fragment-->
105+
<syncfusion:UMLSequenceFragmentCondition.Fragments>
106+
<syncfusion:FragmentCollection>
107+
<!-- Optional Fragment: Only executes if item is in stock -->
108+
<syncfusion:UMLSequenceFragment ID="Frag1" Type="Optional">
109+
<syncfusion:UMLSequenceFragment.Conditions>
110+
<syncfusion:ConditionCollection>
111+
<syncfusion:UMLSequenceFragmentCondition Content="[if item is in stock">
112+
<syncfusion:UMLSequenceFragmentCondition.MessageIds>
113+
<syncfusion:MessageIdCollection>
114+
<sys:String>MSG4</sys:String>
115+
</syncfusion:MessageIdCollection>
116+
</syncfusion:UMLSequenceFragmentCondition.MessageIds>
117+
</syncfusion:UMLSequenceFragmentCondition>
118+
</syncfusion:ConditionCollection>
119+
</syncfusion:UMLSequenceFragment.Conditions>
120+
</syncfusion:UMLSequenceFragment>
121+
122+
<!-- Alternative Fragment: Payment success or failure -->
123+
<syncfusion:UMLSequenceFragment ID="Frag2" Type="Alternative">
124+
<syncfusion:UMLSequenceFragment.Conditions>
125+
<syncfusion:ConditionCollection>
126+
<!-- If payment is successful -->
127+
<syncfusion:UMLSequenceFragmentCondition Content="[if payment is successful]">
128+
<syncfusion:UMLSequenceFragmentCondition.MessageIds>
129+
<syncfusion:MessageIdCollection>
130+
<sys:String>MSG5</sys:String>
131+
<sys:String>MSG6</sys:String>
132+
</syncfusion:MessageIdCollection>
133+
</syncfusion:UMLSequenceFragmentCondition.MessageIds>
134+
</syncfusion:UMLSequenceFragmentCondition>
135+
136+
<!-- If payment fails -->
137+
<syncfusion:UMLSequenceFragmentCondition Content="[if payment fails]">
138+
<syncfusion:UMLSequenceFragmentCondition.MessageIds>
139+
<syncfusion:MessageIdCollection>
140+
<sys:String>MSG7</sys:String>
141+
<sys:String>MSG8</sys:String>
142+
</syncfusion:MessageIdCollection>
143+
</syncfusion:UMLSequenceFragmentCondition.MessageIds>
144+
</syncfusion:UMLSequenceFragmentCondition>
145+
</syncfusion:ConditionCollection>
146+
</syncfusion:UMLSequenceFragment.Conditions>
147+
</syncfusion:UMLSequenceFragment>
148+
</syncfusion:FragmentCollection>
149+
</syncfusion:UMLSequenceFragmentCondition.Fragments>
150+
</syncfusion:UMLSequenceFragmentCondition>
151+
</syncfusion:ConditionCollection>
152+
</syncfusion:UMLSequenceFragment.Conditions>
153+
</syncfusion:UMLSequenceFragment>
154+
155+
156+
157+
</syncfusion:FragmentCollection>
158+
</syncfusion:UMLSequenceDiagramModel.Fragments>
159+
160+
</syncfusion:UMLSequenceDiagramModel>
161+
</syncfusion:SfDiagram.Model>
162+
</syncfusion:SfDiagram>
163+
164+
<StackPanel Grid.Column="1" Orientation="Vertical" Background="Beige">
165+
<Grid>
166+
<Grid.RowDefinitions>
167+
<RowDefinition Height="auto"/>
168+
<RowDefinition Height="*"/>
169+
<RowDefinition Height="auto"/>
170+
</Grid.RowDefinitions>
171+
<Label Content="Mermaid Text" Grid.Row="0" HorizontalAlignment="Center" FontWeight="SemiBold" FontSize="16"/>
172+
173+
<TextBox x:Name="MermaidTextBox" Grid.Row="1" TextWrapping="Wrap"
174+
BorderThickness="0" AcceptsReturn="True" Background="Beige"
175+
MaxHeight="600" Height="500"
176+
FontFamily="Consolas"
177+
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Padding="10"/>
178+
179+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2">
180+
181+
<Button x:Name="SaveDiagramFromMermaid" Content="Save Diagram As Mermaid" Width="190"
182+
Padding="10, 9" Click="SaveDiagramFromMermaid_Click" Foreground="#FF004C99" VerticalAlignment="Bottom"
183+
HorizontalAlignment="Stretch" Background="SkyBlue" BorderThickness="0" FontWeight="SemiBold"/>
184+
185+
<Button x:Name="LoadDiagramFromMermaid" Content="Load Diagram From Mermaid" Width="190" Margin="5 0 0 0"
186+
Padding="10, 9" Click="LoadDiagramFromMermaid_Click" Foreground="#FF004C99" VerticalAlignment="Bottom"
187+
HorizontalAlignment="Stretch" Background="SkyBlue" BorderThickness="0" FontWeight="SemiBold"/>
188+
189+
</StackPanel>
190+
</Grid>
191+
</StackPanel>
192+
</Grid>
193+
</Window>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Syncfusion.UI.Xaml.Diagram;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using System.Windows.Data;
10+
using System.Windows.Documents;
11+
using System.Windows.Input;
12+
using System.Windows.Media;
13+
using System.Windows.Media.Imaging;
14+
using System.Windows.Navigation;
15+
using System.Windows.Shapes;
16+
17+
namespace SequenceDiagram
18+
{
19+
/// <summary>
20+
/// Interaction logic for MainWindow.xaml
21+
/// </summary>
22+
public partial class MainWindow : Window
23+
{
24+
public MainWindow()
25+
{
26+
InitializeComponent();
27+
}
28+
29+
private void LoadDiagramFromMermaid_Click(object sender, RoutedEventArgs e)
30+
{
31+
if (!string.IsNullOrEmpty(MermaidTextBox.Text))
32+
{
33+
Diagram.LoadDiagramFromMermaid(MermaidTextBox.Text.ToString());
34+
}
35+
}
36+
37+
private void SaveDiagramFromMermaid_Click(object sender, RoutedEventArgs e)
38+
{
39+
if (Diagram.Model != null)
40+
MermaidTextBox.Text = Diagram.SaveDiagramAsMermaid();
41+
}
42+
}
43+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyTitle("SequenceDiagram")]
11+
[assembly: AssemblyDescription("")]
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyCompany("")]
14+
[assembly: AssemblyProduct("SequenceDiagram")]
15+
[assembly: AssemblyCopyright("Copyright © 2025")]
16+
[assembly: AssemblyTrademark("")]
17+
[assembly: AssemblyCulture("")]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[assembly: ComVisible(false)]
23+
24+
//In order to begin building localizable applications, set
25+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
26+
//inside a <PropertyGroup>. For example, if you are using US english
27+
//in your source files, set the <UICulture> to en-US. Then uncomment
28+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
29+
//the line below to match the UICulture setting in the project file.
30+
31+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32+
33+
34+
[assembly:ThemeInfo(
35+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36+
//(used if a resource is not found in the page,
37+
// or application resource dictionaries)
38+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39+
//(used if a resource is not found in the page,
40+
// app, or any theme specific resource dictionaries)
41+
)]
42+
43+
44+
// Version information for an assembly consists of the following four values:
45+
//
46+
// Major Version
47+
// Minor Version
48+
// Build Number
49+
// Revision
50+
//
51+
[assembly: AssemblyVersion("1.0.0.0")]
52+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)