Table of Contents

Class Node

Namespace
FlowGraph.Core
Assembly
FlowGraph.Core.dll

Represents a node in the flow graph. Uses a Definition (immutable) + State (mutable) composition pattern. Implements ICanvasElement for unified element handling.

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

Remarks

The node's structural properties (Id, Type, Label, Ports, capability flags) are stored in the Definition record. Runtime state (position, size, selection) is stored in the State object.

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

Constructors

Node()

Creates a node with default definition. For backward compatibility.

public Node()

Node(NodeDefinition, INodeState?)

Creates a node with the specified definition and optional state.

public Node(NodeDefinition definition, INodeState? state = null)

Parameters

definition NodeDefinition

The immutable node definition.

state INodeState

The mutable node state. If null, a new NodeState is created.

Properties

AllowedResizeHandles

Specifies which resize handles should be displayed when this node is selected.

public ResizeHandleMode AllowedResizeHandles { get; set; }

Property Value

ResizeHandleMode

Data

Custom user data associated with the node.

public object? Data { get; set; }

Property Value

object

Definition

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

public NodeDefinition Definition { get; set; }

Property Value

NodeDefinition

GroupPadding

Custom padding around group children when calculating group bounds. Only applies when IsGroup is true. If null, uses the default from settings.

public double? GroupPadding { get; set; }

Property Value

double?

Height

The height of the node. Null means auto-sized.

public double? Height { get; set; }

Property Value

double?

Id

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

public string Id { get; }

Property Value

string

Inputs

Input ports for this node. For full immutability, use Definition.Inputs directly.

public List<Port> Inputs { get; set; }

Property Value

List<Port>

IsCollapsed

Whether the group is collapsed (only applicable when IsGroup is true).

public bool IsCollapsed { get; set; }

Property Value

bool

IsConnectable

Whether this node can have new connections. Default is true.

public bool IsConnectable { get; set; }

Property Value

bool

IsDeletable

Whether this node can be deleted. Default is true.

public bool IsDeletable { get; set; }

Property Value

bool

IsDraggable

Whether this node can be dragged. Default is true.

public bool IsDraggable { get; set; }

Property Value

bool

IsDragging

Whether this node is currently being dragged.

public bool IsDragging { get; set; }

Property Value

bool

IsGroup

Whether this node is a group container.

public bool IsGroup { get; set; }

Property Value

bool

IsHighlighted

Whether this node is highlighted for emphasis (e.g., search results, analysis feedback). Unlike selection, highlighting is purely visual and doesn't affect operations.

public bool IsHighlighted { get; set; }

Property Value

bool

IsResizable

Whether this node can be resized. Default is true.

public bool IsResizable { get; set; }

Property Value

bool

IsSelectable

Whether this node can be selected. Default is true.

public bool IsSelectable { get; set; }

Property Value

bool

IsSelected

Whether this node is currently selected.

public bool IsSelected { get; set; }

Property Value

bool

IsVisible

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

public bool IsVisible { get; set; }

Property Value

bool

Label

Optional display label for the node.

public string? Label { get; set; }

Property Value

string

Outputs

Output ports for this node. For full immutability, use Definition.Outputs directly.

public List<Port> Outputs { get; set; }

Property Value

List<Port>

ParentGroupId

The ID of the parent group node, if this node is part of a group.

public string? ParentGroupId { get; set; }

Property Value

string

Position

The position of the node in canvas space.

public Point Position { get; set; }

Property Value

Point

State

The mutable runtime state of this node (position, size, selection).

public INodeState State { get; set; }

Property Value

INodeState

Type

The type/category of the node (e.g., "process", "decision", "input").

public string Type { get; set; }

Property Value

string

Width

The width of the node. Null means auto-sized.

public double? Width { get; set; }

Property Value

double?

ZIndex

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

public int ZIndex { get; set; }

Property Value

int

Methods

CreateStateSnapshot()

Creates a snapshot of the current state.

public NodeState CreateStateSnapshot()

Returns

NodeState

GetBounds()

Gets the bounding rectangle of this node in canvas coordinates.

public Rect GetBounds()

Returns

Rect

Move(double, double)

Moves the node by the specified delta.

public void Move(double deltaX, double deltaY)

Parameters

deltaX double
deltaY double

OnPropertyChanged(string?)

Raises the PropertyChanged event.

protected virtual void OnPropertyChanged(string? propertyName)

Parameters

propertyName string

RestoreState(INodeState)

Restores state from a snapshot.

public void RestoreState(INodeState snapshot)

Parameters

snapshot INodeState

SetPosition(double, double)

Sets the node's position.

public void SetPosition(double x, double y)

Parameters

x double
y double

SetSize(double?, double?)

Sets the node's size.

public void SetSize(double? width, double? height)

Parameters

width double?
height double?

Events

BoundsChanged

Raised when the node's bounds (position or size) change. Useful for spatial index invalidation and layout systems.

public event EventHandler<BoundsChangedEventArgs>? BoundsChanged

Event Type

EventHandler<BoundsChangedEventArgs>

PositionChanged

Raised when the node's position (X, Y) changes. More efficient than PropertyChanged for position-specific listeners.

public event EventHandler<PositionChangedEventArgs>? PositionChanged

Event Type

EventHandler<PositionChangedEventArgs>

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler