Table of Contents

Interface ICanvasElement

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

Base interface for all elements that can be placed on the canvas. Represents any positioned, sized, and selectable content in the coordinate system.

public interface ICanvasElement : INotifyPropertyChanged
Inherited Members

Remarks

This interface defines the contract for all visual elements in FlowGraph, including nodes, edges, shapes, annotations, and any custom element types.

The coordinate system uses canvas coordinates (not screen coordinates). Use FlowCanvas.CanvasToScreen and FlowCanvas.ScreenToCanvas for conversions.

Properties

Height

Gets or sets the height of this element, if applicable.

double? Height { get; set; }

Property Value

double?

Remarks

Some elements (like edges) may not have a meaningful height. Returns null if the element has no explicit height.

Id

Gets the unique identifier for this element.

string Id { get; }

Property Value

string

Remarks

IDs are immutable after creation and used for lookups, serialization, and change tracking.

IsSelectable

Gets or sets whether this element can be selected by user interaction.

bool IsSelectable { get; }

Property Value

bool

Remarks

When false, clicking on the element will not select it.

IsSelected

Gets or sets whether this element is currently selected.

bool IsSelected { get; set; }

Property Value

bool

IsVisible

Gets or sets whether this element is visible.

bool IsVisible { get; }

Property Value

bool

Remarks

Invisible elements are not rendered but remain in the element collection.

Position

Gets or sets the position of this element in canvas coordinates.

Point Position { get; set; }

Property Value

Point

Remarks

The position typically represents the top-left corner of the element's bounding box, but this may vary by element type.

Type

Gets the type identifier for this element.

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.).

Width

Gets or sets the width of this element, if applicable.

double? Width { get; set; }

Property Value

double?

Remarks

Some elements (like edges) may not have a meaningful width. Returns null if the element has no explicit width.

ZIndex

Gets the Z-index for rendering order.

int ZIndex { get; }

Property Value

int

Remarks

Higher values render on top. Default values by type:

  • Backgrounds: 0
  • Shapes: 100
  • Edges: 200
  • Nodes: 300

Methods

GetBounds()

Gets the bounding rectangle of this element in canvas coordinates.

Rect GetBounds()

Returns

Rect

The bounds as a Rect.