|
| 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> |
0 commit comments