using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;
// Optional exact gallery typography; copy the gallery's fonts directory beside this program.
FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Regular.ttf", 400);
FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Bold.ttf", 700);
var mode = VisualThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = FlowRecipe.Create("expanded", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(900, 600)), theme, mode,
new VisualFrame("Assessment workflow", "Typed lanes, decisions and branched routes", showLegend: false, showSurface: false), FontSpec.FromFamily("CFX Proof Carlito"));
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.Flow).ToHtmlPage());
/// Creates a branched assessment workflow with typed lanes and semantic statuses.
public static class FlowRecipe {
/// Creates the expanded workflow model.
/// Use wide or expanded for the workflow.
/// The rendering mode; diagram colors are resolved when the model is prepared.
public static FlowArtifact Create(string variant = "wide", VisualThemeMode mode = VisualThemeMode.Light) {
if (variant is not ("wide" or "expanded"))
throw new ArgumentOutOfRangeException(nameof(variant), variant, "Use wide or expanded.");
return FlowArtifact.Create("assessment-flow").WithSize(900, 600)
.AddLane("service", "Service").AddLane("review", "Review")
.AddStep("received", "Request received", FlowArtifactStepKind.Start, "service")
.AddStep("decision", "Automatic checks pass?", FlowArtifactStepKind.Decision, "service")
.ConfigureStep("decision", step => step.Width = 200)
.AddStep("manual", "Review observations", FlowArtifactStepKind.Process, "review", VisualStatus.Warning)
.AddStep("complete", "Assessment complete", FlowArtifactStepKind.End, "service", VisualStatus.Positive)
.AddConnector("received", "decision", "Evaluate")
.AddConnector("decision", "manual", "Review required")
.AddConnector("decision", "complete", "Passed")
.AddConnector("manual", "complete", "Accepted");
}
}