Table of Contents

Class ShapeElement

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

Base class for shape elements that can be rendered on the canvas. Shapes are arbitrary visual elements that are not nodes or edges.

public abstract class ShapeElement : CanvasElement, ICanvasElement, INotifyPropertyChanged
Inheritance
ShapeElement
Implements
Derived
Inherited Members

Examples

// Creating a rectangle shape
var rect = new RectangleElement("rect-1")
{
    Position = new Point(100, 100),
    Width = 200,
    Height = 100,
    Fill = "#3498db",
    Stroke = "#2980b9"
};
graph.AddElement(rect);

Remarks

Shapes are the core building block for the canvas-first architecture. They allow rendering arbitrary content like annotations, swimlanes, diagrams, and other non-graph elements on the infinite canvas.

Shapes have a default Z-index of ZIndexShapes (100), placing them above backgrounds but below edges and nodes.

Constructors

ShapeElement(string)

Creates a new shape element with the specified ID.

protected ShapeElement(string id)

Parameters

id string

The unique identifier for this shape.

Properties

AllowedResizeHandles

Gets the resize handle positions that should be shown for this shape. Override in derived classes to customize which handles appear.

public virtual ResizeHandleMode AllowedResizeHandles { get; }

Property Value

ResizeHandleMode

Remarks

Default implementation returns all 8 handles (corners + edges). Shapes with non-rectangular geometry (cylinders, circles, etc.) should override this to return only meaningful handles.

Fill

Gets or sets the fill color of the shape.

public string? Fill { get; set; }

Property Value

string

Remarks

Color can be specified as hex (#RRGGBB or #AARRGGBB), named color, or null for no fill.

IsResizable

Gets or sets whether the shape can be resized by the user.

public bool IsResizable { get; set; }

Property Value

bool

Remarks

When true and the shape is selected, resize handles will be displayed allowing the user to drag and resize the shape.

Label

Gets or sets an optional label to display on or near the shape.

public string? Label { get; set; }

Property Value

string

Opacity

Gets or sets the opacity of the shape (0.0 to 1.0).

public double Opacity { get; set; }

Property Value

double

Rotation

Gets or sets the rotation angle in degrees.

public double Rotation { get; set; }

Property Value

double

Stroke

Gets or sets the stroke (border) color of the shape.

public string? Stroke { get; set; }

Property Value

string

Remarks

Color can be specified as hex (#RRGGBB or #AARRGGBB), named color, or null for no stroke.

StrokeWidth

Gets or sets the stroke width in pixels.

public double StrokeWidth { get; set; }

Property Value

double