Table of Contents

Class InputStateContext

Namespace
FlowGraph.Avalonia.Input
Assembly
FlowGraph.Avalonia.dll

Shared context passed to all input states. Contains references to canvas components and raises events.

public class InputStateContext
Inheritance
InputStateContext
Inherited Members

Constructors

InputStateContext(FlowCanvasSettings, ViewportState, CanvasElementManager)

public InputStateContext(FlowCanvasSettings settings, ViewportState viewport, CanvasElementManager graphRenderer)

Parameters

settings FlowCanvasSettings
viewport ViewportState
graphRenderer CanvasElementManager

Properties

ApplyViewportTransformCallback

Callback to apply viewport transforms. Set by FlowCanvas.

public Action? ApplyViewportTransformCallback { get; set; }

Property Value

Action

CollisionProvider

Optional collision provider for preventing node overlap during drag. Applied after SnapProvider. Returns offset to prevent collision. Set by FlowCanvas.

public ICollisionProvider? CollisionProvider { get; set; }

Property Value

ICollisionProvider

ConnectionValidator

Optional connection validator for validating new connections. Set by FlowCanvas.

public IConnectionValidator? ConnectionValidator { get; set; }

Property Value

IConnectionValidator

Coordinates

Type-safe coordinate helper that abstracts rendering mode differences. Use this instead of ViewportToCanvas/CanvasToViewport for new code.

public IInputCoordinates Coordinates { get; }

Property Value

IInputCoordinates

DirectRenderer

public DirectCanvasRenderer? DirectRenderer { get; set; }

Property Value

DirectCanvasRenderer

Dispatcher

Reference to the InputDispatcher for processor-based input handling. Set by FlowCanvas during initialization.

public InputDispatcher? Dispatcher { get; set; }

Property Value

InputDispatcher

Remarks

This enables IdleState to delegate to the InputDispatcher instead of doing manual pattern matching on source control tags.

Graph

public Graph? Graph { get; set; }

Property Value

Graph

GraphRenderer

public CanvasElementManager GraphRenderer { get; }

Property Value

CanvasElementManager

MainCanvas

public Canvas? MainCanvas { get; set; }

Property Value

Canvas

RenderTarget

Mode-agnostic render target for creating temporary visuals. Handles container selection and coordinate conversion internally.

public IRenderTarget RenderTarget { get; }

Property Value

IRenderTarget

RootPanel

public Panel? RootPanel { get; set; }

Property Value

Panel

Settings

public FlowCanvasSettings Settings { get; }

Property Value

FlowCanvasSettings

ShapeVisualManager

Shape visual manager for updating shape selection state. Set by FlowCanvas.

public ShapeVisualManager? ShapeVisualManager { get; set; }

Property Value

ShapeVisualManager

SnapProvider

Optional snap provider for providing snap offsets during drag operations. External systems (like helper lines, guides) can register as a snap provider to influence node positions during drag without directly setting positions. Set by FlowCanvas.

public ISnapProvider? SnapProvider { get; set; }

Property Value

ISnapProvider

Theme

public ThemeResources? Theme { get; set; }

Property Value

ThemeResources

Viewport

public ViewportState Viewport { get; }

Property Value

ViewportState

Methods

ApplyViewportTransform()

Applies the current viewport state to the MainCanvas transform. This enables O(1) pan/zoom updates instead of O(n) re-rendering. For DirectRendering mode, triggers a redraw since it bypasses the visual tree.

public void ApplyViewportTransform()

CanvasToViewport(Point)

public Point CanvasToViewport(Point canvasPoint)

Parameters

canvasPoint Point

Returns

Point

RaiseBoxSelectionChanged(Rect)

public void RaiseBoxSelectionChanged(Rect bounds)

Parameters

bounds Rect

RaiseConnectEnd(Node?, Port?, Node?, Port?, bool)

public void RaiseConnectEnd(Node? sourceNode, Port? sourcePort, Node? targetNode, Port? targetPort, bool completed)

Parameters

sourceNode Node
sourcePort Port
targetNode Node
targetPort Port
completed bool

RaiseConnectStart(Node, Port, bool)

public void RaiseConnectStart(Node sourceNode, Port sourcePort, bool isOutput)

Parameters

sourceNode Node
sourcePort Port
isOutput bool

RaiseConnectionCompleted(Node, Port, Node, Port)

public void RaiseConnectionCompleted(Node sourceNode, Port sourcePort, Node targetNode, Port targetPort)

Parameters

sourceNode Node
sourcePort Port
targetNode Node
targetPort Port

RaiseCopy()

public void RaiseCopy()

RaiseCut()

public void RaiseCut()

RaiseDeleteSelected()

public void RaiseDeleteSelected()

RaiseDeselectAll()

public void RaiseDeselectAll()

RaiseDuplicate()

public void RaiseDuplicate()

RaiseEdgeClicked(Edge, bool)

public void RaiseEdgeClicked(Edge edge, bool ctrlHeld)

Parameters

edge Edge
ctrlHeld bool

RaiseEdgeDisconnected(Edge)

public void RaiseEdgeDisconnected(Edge edge)

Parameters

edge Edge

RaiseEdgeLabelEditRequested(Edge, Point)

Raises the EdgeLabelEditRequested event and returns whether it was handled.

public bool RaiseEdgeLabelEditRequested(Edge edge, Point screenPosition)

Parameters

edge Edge
screenPosition Point

Returns

bool

RaiseEdgeReconnected(Edge, Edge)

public void RaiseEdgeReconnected(Edge oldEdge, Edge newEdge)

Parameters

oldEdge Edge
newEdge Edge

RaiseGridRender()

public void RaiseGridRender()

RaiseGroup()

public void RaiseGroup()

RaiseGroupCollapseToggle(string)

public void RaiseGroupCollapseToggle(string groupId)

Parameters

groupId string

RaiseNodeDragStart(IReadOnlyList<Node>, Point)

public void RaiseNodeDragStart(IReadOnlyList<Node> nodes, Point startPosition)

Parameters

nodes IReadOnlyList<Node>
startPosition Point

RaiseNodeDragStop(IReadOnlyList<Node>, bool)

public void RaiseNodeDragStop(IReadOnlyList<Node> nodes, bool cancelled)

Parameters

nodes IReadOnlyList<Node>
cancelled bool

RaiseNodeLabelEditRequested(Node, Point)

Raises the NodeLabelEditRequested event and returns whether it was handled.

public bool RaiseNodeLabelEditRequested(Node node, Point screenPosition)

Parameters

node Node
screenPosition Point

Returns

bool

RaiseNodeResized(Node, double, double, double, double, Point, Point)

public void RaiseNodeResized(Node node, double oldWidth, double oldHeight, double newWidth, double newHeight, Point oldPos, Point newPos)

Parameters

node Node
oldWidth double
oldHeight double
newWidth double
newHeight double
oldPos Point
newPos Point

RaiseNodeResizing(Node, double, double, Point)

public void RaiseNodeResizing(Node node, double newWidth, double newHeight, Point newPos)

Parameters

node Node
newWidth double
newHeight double
newPos Point

RaiseNodesDragged(Dictionary<string, Point>, Dictionary<string, Point>)

public void RaiseNodesDragged(Dictionary<string, Point> oldPositions, Dictionary<string, Point> newPositions)

Parameters

oldPositions Dictionary<string, Point>
newPositions Dictionary<string, Point>

RaiseNodesDragging(IReadOnlyList<string>)

public void RaiseNodesDragging(IReadOnlyList<string> nodeIds)

Parameters

nodeIds IReadOnlyList<string>

RaisePaste()

public void RaisePaste()

RaiseRedo()

public void RaiseRedo()

RaiseSelectAll()

public void RaiseSelectAll()

RaiseSelectionChanged()

public void RaiseSelectionChanged()

RaiseShapeResized(ShapeElement, double, double, double, double, Point, Point)

Raises the ShapeResized event after shape resize is complete.

public void RaiseShapeResized(ShapeElement shape, double oldWidth, double oldHeight, double newWidth, double newHeight, Point oldPos, Point newPos)

Parameters

shape ShapeElement
oldWidth double
oldHeight double
newWidth double
newHeight double
oldPos Point
newPos Point

RaiseShapeResizing(ShapeElement, double, double, Point)

Raises the ShapeResizing event during shape resize operation.

public void RaiseShapeResizing(ShapeElement shape, double newWidth, double newHeight, Point newPos)

Parameters

shape ShapeElement
newWidth double
newHeight double
newPos Point

RaiseShapeTextEditRequested(ShapeElement, Point)

Raises the ShapeTextEditRequested event and returns whether it was handled.

public bool RaiseShapeTextEditRequested(ShapeElement shape, Point screenPosition)

Parameters

shape ShapeElement
screenPosition Point

Returns

bool

RaiseStateChanged(string, string)

public void RaiseStateChanged(string oldState, string newState)

Parameters

oldState string
newState string

RaiseUndo()

public void RaiseUndo()

RaiseUngroup()

public void RaiseUngroup()

UpdateSettings(FlowCanvasSettings)

Updates the settings used by this context.

public void UpdateSettings(FlowCanvasSettings settings)

Parameters

settings FlowCanvasSettings

The new settings to use.

ViewportToCanvas(Point)

public Point ViewportToCanvas(Point viewportPoint)

Parameters

viewportPoint Point

Returns

Point

Events

BoxSelectionChanged

public event EventHandler<BoxSelectionEventArgs>? BoxSelectionChanged

Event Type

EventHandler<BoxSelectionEventArgs>

ConnectEnd

public event EventHandler<ConnectEndEventArgs>? ConnectEnd

Event Type

EventHandler<ConnectEndEventArgs>

ConnectStart

public event EventHandler<ConnectStartEventArgs>? ConnectStart

Event Type

EventHandler<ConnectStartEventArgs>

ConnectionCompleted

public event EventHandler<ConnectionCompletedEventArgs>? ConnectionCompleted

Event Type

EventHandler<ConnectionCompletedEventArgs>

CopyRequested

public event EventHandler? CopyRequested

Event Type

EventHandler

CutRequested

public event EventHandler? CutRequested

Event Type

EventHandler

DeleteSelectedRequested

public event EventHandler? DeleteSelectedRequested

Event Type

EventHandler

DeselectAllRequested

public event EventHandler? DeselectAllRequested

Event Type

EventHandler

DuplicateRequested

public event EventHandler? DuplicateRequested

Event Type

EventHandler

EdgeClicked

public event EventHandler<EdgeClickedEventArgs>? EdgeClicked

Event Type

EventHandler<EdgeClickedEventArgs>

EdgeDisconnected

public event EventHandler<EdgeDisconnectedEventArgs>? EdgeDisconnected

Event Type

EventHandler<EdgeDisconnectedEventArgs>

EdgeLabelEditRequested

public event EventHandler<EdgeLabelEditRequestedEventArgs>? EdgeLabelEditRequested

Event Type

EventHandler<EdgeLabelEditRequestedEventArgs>

EdgeReconnected

public event EventHandler<EdgeReconnectedEventArgs>? EdgeReconnected

Event Type

EventHandler<EdgeReconnectedEventArgs>

GridRenderRequested

public event EventHandler? GridRenderRequested

Event Type

EventHandler

GroupCollapseToggleRequested

public event EventHandler<GroupToggleCollapseEventArgs>? GroupCollapseToggleRequested

Event Type

EventHandler<GroupToggleCollapseEventArgs>

GroupRequested

public event EventHandler? GroupRequested

Event Type

EventHandler

NodeDragStart

public event EventHandler<NodeDragStartEventArgs>? NodeDragStart

Event Type

EventHandler<NodeDragStartEventArgs>

NodeDragStop

public event EventHandler<NodeDragStopEventArgs>? NodeDragStop

Event Type

EventHandler<NodeDragStopEventArgs>

NodeLabelEditRequested

public event EventHandler<NodeLabelEditRequestedEventArgs>? NodeLabelEditRequested

Event Type

EventHandler<NodeLabelEditRequestedEventArgs>

NodeResized

public event EventHandler<NodeResizedEventArgs>? NodeResized

Event Type

EventHandler<NodeResizedEventArgs>

NodeResizing

public event EventHandler<NodeResizingEventArgs>? NodeResizing

Event Type

EventHandler<NodeResizingEventArgs>

NodesDragged

public event EventHandler<NodesDraggedEventArgs>? NodesDragged

Event Type

EventHandler<NodesDraggedEventArgs>

NodesDragging

public event EventHandler<NodesDraggingEventArgs>? NodesDragging

Event Type

EventHandler<NodesDraggingEventArgs>

PasteRequested

public event EventHandler? PasteRequested

Event Type

EventHandler

RedoRequested

public event EventHandler? RedoRequested

Event Type

EventHandler

SelectAllRequested

public event EventHandler? SelectAllRequested

Event Type

EventHandler

SelectionChangeRequested

public event EventHandler? SelectionChangeRequested

Event Type

EventHandler

ShapeResized

public event EventHandler<ShapeResizedEventArgs>? ShapeResized

Event Type

EventHandler<ShapeResizedEventArgs>

ShapeResizing

public event EventHandler<ShapeResizingEventArgs>? ShapeResizing

Event Type

EventHandler<ShapeResizingEventArgs>

ShapeTextEditRequested

public event EventHandler<ShapeTextEditRequestedEventArgs>? ShapeTextEditRequested

Event Type

EventHandler<ShapeTextEditRequestedEventArgs>

StateChanged

public event EventHandler<StateChangedEventArgs>? StateChanged

Event Type

EventHandler<StateChangedEventArgs>

UndoRequested

public event EventHandler? UndoRequested

Event Type

EventHandler

UngroupRequested

public event EventHandler? UngroupRequested

Event Type

EventHandler