Class Node
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
definitionNodeDefinitionThe immutable node definition.
stateINodeStateThe 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
Data
Custom user data associated with the node.
public object? Data { get; set; }
Property Value
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
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
Height
The height of the node. Null means auto-sized.
public double? Height { get; set; }
Property Value
Id
Unique identifier for the node. Immutable - to change, replace the Definition.
public string Id { get; }
Property Value
Inputs
Input ports for this node. For full immutability, use Definition.Inputs directly.
public List<Port> Inputs { get; set; }
Property Value
IsCollapsed
Whether the group is collapsed (only applicable when IsGroup is true).
public bool IsCollapsed { get; set; }
Property Value
IsConnectable
Whether this node can have new connections. Default is true.
public bool IsConnectable { get; set; }
Property Value
IsDeletable
Whether this node can be deleted. Default is true.
public bool IsDeletable { get; set; }
Property Value
IsDraggable
Whether this node can be dragged. Default is true.
public bool IsDraggable { get; set; }
Property Value
IsDragging
Whether this node is currently being dragged.
public bool IsDragging { get; set; }
Property Value
IsGroup
Whether this node is a group container.
public bool IsGroup { get; set; }
Property Value
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
IsResizable
Whether this node can be resized. Default is true.
public bool IsResizable { get; set; }
Property Value
IsSelectable
Whether this node can be selected. Default is true.
public bool IsSelectable { get; set; }
Property Value
IsSelected
Whether this node is currently selected.
public bool IsSelected { get; set; }
Property Value
IsVisible
Gets or sets whether this node is visible in the canvas. Delegates to State.IsVisible.
public bool IsVisible { get; set; }
Property Value
Label
Optional display label for the node.
public string? Label { get; set; }
Property Value
Outputs
Output ports for this node. For full immutability, use Definition.Outputs directly.
public List<Port> Outputs { get; set; }
Property Value
ParentGroupId
The ID of the parent group node, if this node is part of a group.
public string? ParentGroupId { get; set; }
Property Value
Position
The position of the node in canvas space.
public Point Position { get; set; }
Property Value
State
The mutable runtime state of this node (position, size, selection).
public INodeState State { get; set; }
Property Value
Type
The type/category of the node (e.g., "process", "decision", "input").
public string Type { get; set; }
Property Value
Width
The width of the node. Null means auto-sized.
public double? Width { get; set; }
Property Value
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
Methods
CreateStateSnapshot()
Creates a snapshot of the current state.
public NodeState CreateStateSnapshot()
Returns
GetBounds()
Gets the bounding rectangle of this node in canvas coordinates.
public Rect GetBounds()
Returns
Move(double, double)
Moves the node by the specified delta.
public void Move(double deltaX, double deltaY)
Parameters
OnPropertyChanged(string?)
Raises the PropertyChanged event.
protected virtual void OnPropertyChanged(string? propertyName)
Parameters
propertyNamestring
RestoreState(INodeState)
Restores state from a snapshot.
public void RestoreState(INodeState snapshot)
Parameters
snapshotINodeState
SetPosition(double, double)
Sets the node's position.
public void SetPosition(double x, double y)
Parameters
SetSize(double?, double?)
Sets the node's size.
public void SetSize(double? width, double? height)
Parameters
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
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
PropertyChanged
Occurs when a property value changes.
public event PropertyChangedEventHandler? PropertyChanged