#region Setup using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using ChartForgeX; using ChartForgeX.Core; using ChartForgeX.Primitives; using ChartForgeX.Rendering; using ChartForgeX.Themes; using ChartForgeX.Topology; using ChartForgeX.Typography; using ChartForgeX.VisualArtifacts; using ChartForgeX.VisualBlocks; var mode = ThemeMode.Light; var theme = VisualTheme.Graphite(); var model = SequenceSourceDefaultsRecipe.Create("compact", mode); var context = new VisualRenderContext( new VisualLayoutOptions(new VisualSize(390, 820)), theme, mode, new VisualFrame("Sequence source defaults", "Measured tabs and mirrored participants", showLegend: false, showSurface: false)); var prepared = model.Prepare(context); File.WriteAllText("visual.svg", prepared.ToSvg()); File.WriteAllBytes("visual.png", prepared.ToPng()); File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Sequence).ToHtmlPage()); #endregion /// Creates native fragment tabs, mirrored participants and canonical lifeline strokes. public static class SequenceSourceDefaultsRecipe { /// Creates an explicitly tighter compact native view or a wide view of the same source facts. public static SequenceArtifact Create(string variant="wide",ThemeMode mode=ThemeMode.Light) { if(variant is not ("compact" or "wide"))throw new ArgumentOutOfRangeException(nameof(variant));var compact=variant=="compact";var model=SequenceArtifact.Create("sequence-source-defaults").Width(compact?390:1000).Height(820).AddParticipant("A","Review").AddParticipant("B","Archive").AddMessage("A","A","Check").AddMessage("A","B","Save");model.AddBlock(SequenceArtifactBlockKind.Loop,"Review work",0,1);model.AddNote(SequenceArtifactNotePlacement.Over,new[]{"A","B"},"Complete note");model.Notes[0].StepIndex=1; model.Layout=new SequenceLayoutPolicy(participantMinimumWidth:compact?64:150,participantMinimumHeight:65,participantSpacing:compact?8:50,fragmentMargin:10,fragmentLabelPadding:5,mirrorParticipants:true,messageAlignment:TextAlignment.Center,noteAlignment:TextAlignment.Center,selfMessageRouting:SequenceSelfMessageRouting.Curved,footerBottomMargin:1,fragmentTabMinimumWidth:50,fragmentTabMinimumHeight:20);model.Typography=new SequenceTypography(participant:new TextStyleOverride{FontSize=14},message:new TextStyleOverride{FontSize=compact?12:16},note:new TextStyleOverride{FontSize=14},fragment:new TextStyleOverride{FontSize=compact?12:16});model.Paint.LifelineStroke=new ChartStrokeStyle(width:.5,dash:Array.Empty());model.ThemeMode=mode;return model; } }