DrawmateLib 1.0.0

dotnet add package DrawmateLib --version 1.0.0
                    
NuGet\Install-Package DrawmateLib -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DrawmateLib" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DrawmateLib" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DrawmateLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DrawmateLib --version 1.0.0
                    
#r "nuget: DrawmateLib, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DrawmateLib@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DrawmateLib&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DrawmateLib&version=1.0.0
                    
Install as a Cake Tool

DrawmateLib

NuGet License: MIT

A .NET library for programmatically generating draw.io (diagrams.net) XML diagrams using a fluent builder API.

Installation

dotnet add package DrawmateLib

Quick Start

using DrawmateLib.Builders;
using DrawmateLib.DocumentContexts;

var drawmateContext = new DrawmateContext();
var styleBuilder = new MxStyleBuilder();
var cellBuilder = new MxCellBuilder();

// Create a rectangle
var rectangle = cellBuilder
    .Create("My Box", styleBuilder.Create().Rectangle().Build(true).Value)
    .WithGeometry(100m, 100m, 120, 60)
    .Build();

// Create an ellipse
var ellipse = cellBuilder
    .Create("My Circle", styleBuilder.Ellipse().WithAspect("fixed").Build(true).Value)
    .WithGeometry(300m, 100m, 80, 80)
    .Build();

// Connect them with an edge
var edge = cellBuilder
    .Create("", styleBuilder.Create().AsEdge().Build(false).Value)
    .AsEdge(rectangle.Id, ellipse.Id)
    .Build();

drawmateContext.AddMxCell(rectangle);
drawmateContext.AddMxCell(ellipse);
drawmateContext.AddMxCell(edge);
drawmateContext.SaveDiagram("output.drawio.xml");

API Overview

DrawmateContext

The entry point for building a diagram. Manages the XML document tree and exposes methods to add cells and save the output.

Method Description
AddMxCell(MxCell) Adds a single cell to the diagram
AddMxCells(IEnumerable<MxCell>) Adds multiple cells at once
SaveDiagram(string path) Writes the diagram XML to a file

MxCellBuilder

Fluent builder for creating MxCell objects (shapes and edges).

Method Description
Create(label, styleName) Starts a new cell with the given label and style string
WithGeometry(x, y, width, height) Positions and sizes the cell
AsEdge(sourceId, targetId) Configures the cell as a directed edge
WithCustomParent(parentId) Sets a non-default parent cell
Build() Produces the final MxCell

MxStyleBuilder

Fluent builder for constructing draw.io style strings.

Method Description
Create() Resets and starts a new style
Rectangle() Applies a sharp-cornered rectangle style
Ellipse() Applies an ellipse style
Rhombus() Applies a rhombus (diamond) style
Triangle() Applies a triangle style
TextBox() Applies a plain text style
AsEdge() Applies an orthogonal edge style
WithFillColor(color) Sets the fill color (e.g. "#ffffff")
WithStrokeColor(color) Sets the stroke/border color
WithRounded(bool) Toggles rounded corners
WithAlignment(string) Sets horizontal text alignment
WithVerticalAlignment(string) Sets vertical text alignment
WithAspect(string) Sets the aspect attribute (e.g. "fixed")
WithShape(string) Sets a custom shape name
Build(withCommonAttributes) Returns the built MxGraphStyle

Use MxStyleConstants for pre-defined values for colors, alignments, and shape names.

License

MIT © Aaron Newman, lando-tech

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 135 7/8/2026