Table of Contents

Class Edge

Namespace
FlowGraph.Core
Assembly
FlowGraph.Core.dll

Represents a connection between two nodes. Uses a Definition (immutable) + State (mutable) composition pattern. Implements ICanvasElement for unified element handling.

public class Edge : ICanvasElement, INotifyPropertyChanged
Inheritance
Edge
Implements
Inherited Members
Extension Methods

Remarks

The edge's structural properties (Source, Target, ports, type, markers) are stored in the Definition record. Runtime state (selection, waypoints) is stored in the State object.

For backward compatibility, pass-through properties are provided that delegate to either Definition or State as appropriate.

Constructors

Edge()

Creates an edge with default definition. For backward compatibility.

public Edge()

Edge(EdgeDefinition, IEdgeState?)

Creates an edge with the specified definition and optional state.

public Edge(EdgeDefinition definition, IEdgeState? state = null)

Parameters

definition EdgeDefinition

The immutable edge definition.

state IEdgeState

The mutable edge state. If null, a new EdgeState is created.

Properties

AutoRoute

Whether automatic routing is enabled.

public bool AutoRoute { get; set; }

Property Value

bool

Definition

The immutable definition of this edge (identity, connections, visual type). Use with expressions to modify: edge.Definition = edge.Definition with { Label = "x" };

public EdgeDefinition Definition { get; set; }

Property Value

EdgeDefinition

Id

Unique identifier for the edge. Immutable - to change, replace the Definition.

public string Id { get; }

Property Value

string

IsLocked

Whether this edge is locked, preventing deletion and reconnection via UI.

public bool IsLocked { get; set; }

Property Value

bool

Remarks

When true, the edge cannot be deleted or reconnected through user interaction. Programmatic changes are still allowed.

IsSelectable

Whether this edge can be selected by user interaction.

public bool IsSelectable { get; set; }

Property Value

bool

IsSelected

Whether this edge is currently selected.

public bool IsSelected { get; set; }

Property Value

bool

IsVisible

Gets or sets whether this edge is visible in the canvas. Delegates to State.IsVisible.

public bool IsVisible { get; set; }

Property Value

bool

Label

Optional label for the edge.

public string? Label { get; set; }

Property Value

string

MarkerEnd

The marker at the end of the edge.

public EdgeMarker MarkerEnd { get; set; }

Property Value

EdgeMarker

MarkerStart

The marker at the start of the edge.

public EdgeMarker MarkerStart { get; set; }

Property Value

EdgeMarker

Source

The ID of the source node. To modify, use: edge.Definition = edge.Definition with { Source = "x" };

public string Source { get; set; }

Property Value

string

SourcePort

The ID of the source port. To modify, use: edge.Definition = edge.Definition with { SourcePort = "x" };

public string SourcePort { get; set; }

Property Value

string

State

The mutable runtime state of this edge (selection, waypoints).

public IEdgeState State { get; set; }

Property Value

IEdgeState

Style

Visual style for the edge including colors, dash patterns, and effects.

public EdgeStyle? Style { get; set; }

Property Value

EdgeStyle

Target

The ID of the target node. To modify, use: edge.Definition = edge.Definition with { Target = "x" };

public string Target { get; set; }

Property Value

string

TargetPort

The ID of the target port. To modify, use: edge.Definition = edge.Definition with { TargetPort = "x" };

public string TargetPort { get; set; }

Property Value

string

Type

The visual type of the edge. To modify, use: edge.Definition = edge.Definition with { Type = EdgeType.Straight };

public EdgeType Type { get; set; }

Property Value

EdgeType

Waypoints

Optional waypoints for custom edge routing.

public List<Point>? Waypoints { get; set; }

Property Value

List<Point>

ZIndex

Gets or sets the Z-index for rendering order. Delegates to State.ZIndex. Default is CanvasElement.ZIndexEdges (200).

public int ZIndex { get; set; }

Property Value

int

Methods

GetBounds()

Gets the bounding rectangle of this edge. For edges without waypoints, returns an empty rect at origin.

public Rect GetBounds()

Returns

Rect

OnPropertyChanged(string?)

Raises the PropertyChanged event.

protected virtual void OnPropertyChanged(string? propertyName)

Parameters

propertyName string

Reconnect(string, string)

Reconnects this edge to a different target node and port.

public void Reconnect(string newTarget, string newTargetPort)

Parameters

newTarget string
newTargetPort string

ReconnectSource(string, string)

Reconnects this edge from a different source node and port.

public void ReconnectSource(string newSource, string newSourcePort)

Parameters

newSource string
newSourcePort string

Events

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler