Table of Contents

Class TextElement

Namespace
FlowGraph.Core.Elements.Shapes
Assembly
FlowGraph.Core.dll

A text shape element for displaying standalone text on the canvas.

public class TextElement : ShapeElement, ICanvasElement, INotifyPropertyChanged
Inheritance
TextElement
Implements
Inherited Members

Examples

// Create a diagram title
var title = new TextElement("title-1")
{
    Position = new Point(50, 20),
    Text = "System Architecture",
    FontSize = 24,
    FontWeight = FontWeight.Bold,
    Fill = "#2c3e50"
};

// Create an annotation
var note = new TextElement("note-1")
{
    Position = new Point(200, 300),
    Text = "TODO: Add error handling",
    FontSize = 12,
    FontStyle = FontStyle.Italic,
    Fill = "#e74c3c"
};

Remarks

TextElement is useful for: - Annotations and comments - Diagram titles and labels - Swimlane headers - Free-form notes

Unlike node labels, TextElement exists independently and can be positioned anywhere on the canvas without being attached to a node.

Constructors

TextElement()

Creates a new text element with a generated ID.

public TextElement()

TextElement(string)

Creates a new text element with the specified ID.

public TextElement(string id)

Parameters

id string

The unique identifier for this text element.

Properties

FontFamily

Gets or sets the font family name.

public string FontFamily { get; set; }

Property Value

string

FontSize

Gets or sets the font size in points.

public double FontSize { get; set; }

Property Value

double

FontStyle

Gets or sets the font style (normal, italic, etc.).

public FontStyle FontStyle { get; set; }

Property Value

FontStyle

FontWeight

Gets or sets the font weight.

public FontWeight FontWeight { get; set; }

Property Value

FontWeight

MaxWidth

Gets or sets the maximum width for text wrapping. Null means no wrapping - text extends as needed.

public double? MaxWidth { get; set; }

Property Value

double?

Text

Gets or sets the text content to display.

public string Text { get; set; }

Property Value

string

TextAlignment

Gets or sets the text alignment within the element bounds.

public TextAlignment TextAlignment { get; set; }

Property Value

TextAlignment

Type

Gets the type identifier for this element.

public override string Type { get; }

Property Value

string

Remarks

Used by renderer registries to select the appropriate renderer. For nodes, this typically comes from the node definition's Type property. For shapes, this identifies the shape type (line, rectangle, text, etc.).