|
| 1 | +@page "/" |
| 2 | + |
| 3 | +@using Syncfusion.Blazor.Diagram |
| 4 | + |
| 5 | +<div style="display: flex; height: 800px;"> |
| 6 | + |
| 7 | + <div style="width: 75%; padding-right: 1rem;"> |
| 8 | + <SfDiagramComponent @ref="@diagramComponent" ID="diagram" Height="100%" Model="@umlModel"> |
| 9 | + </SfDiagramComponent> |
| 10 | + </div> |
| 11 | + |
| 12 | + |
| 13 | + <div style="width: 25%; display: flex; flex-direction: column;"> |
| 14 | + <textarea style="flex: 1; resize: none;" placeholder="Mermaid data goes here...">@mermaidData</textarea> |
| 15 | + <div style="margin-top: 1rem;"> |
| 16 | + <button @onclick="save" style="margin-bottom: 0.5rem; width: 100%;">Save</button> |
| 17 | + <button @onclick="LoadFromMermaid" style="width: 100%;margin-bottom: 0.5rem;">Load from mermaid</button> |
| 18 | + <button @onclick="ClearDiagram" style="width: 100%;">Clear</button> |
| 19 | + </div> |
| 20 | + </div> |
| 21 | +</div> |
| 22 | + |
| 23 | +@code { |
| 24 | + UmlSequenceDiagramModel umlModel; |
| 25 | + SfDiagramComponent diagramComponent; |
| 26 | + string mermaidData = ""; |
| 27 | + |
| 28 | + private void save() |
| 29 | + { |
| 30 | + mermaidData = diagramComponent.SaveDiagramAsMermaid(); |
| 31 | + StateHasChanged(); |
| 32 | + } |
| 33 | + |
| 34 | + private async Task LoadFromMermaid() |
| 35 | + { |
| 36 | + await diagramComponent.LoadDiagramFromMermaidAsync(mermaidData); |
| 37 | + } |
| 38 | + |
| 39 | + private void ClearDiagram() |
| 40 | + { |
| 41 | + diagramComponent.Clear(); |
| 42 | + } |
| 43 | + |
| 44 | + protected override void OnInitialized() |
| 45 | + { |
| 46 | + umlModel = new UmlSequenceDiagramModel() |
| 47 | + { |
| 48 | + // Participants Collection |
| 49 | + Participants = new List<UmlSequenceParticipant> |
| 50 | + { |
| 51 | + new UmlSequenceParticipant { ID = "User", Content = "User", IsActor = false, }, |
| 52 | + new UmlSequenceParticipant { ID = "Application", Content = "Application", IsActor = false, }, |
| 53 | + new UmlSequenceParticipant { ID = "Database", Content = "Database", IsActor = false, ShowDestructionMarker = true} |
| 54 | + }, |
| 55 | + |
| 56 | + // Sequence Messages |
| 57 | + Messages = new List<UmlSequenceMessage> |
| 58 | + { |
| 59 | + new UmlSequenceMessage { ID = "MSG1", Content = "Database initiates delete process.", FromParticipantID = "Database", ToParticipantID = "Application"}, |
| 60 | + new UmlSequenceMessage { ID = "MSG2", Content = "Application deletes User.", FromParticipantID = "Application", ToParticipantID = "User", MessageType = UmlSequenceMessageType.Delete }, |
| 61 | + new UmlSequenceMessage { ID = "MSG3", Content = "Database deletes Application.", FromParticipantID = "Database", ToParticipantID = "Application", MessageType = UmlSequenceMessageType.Delete }, |
| 62 | + |
| 63 | + } |
| 64 | + }; |
| 65 | + } |
| 66 | +} |
0 commit comments