Table of Contents

Class SimplifiedNodeRenderer

Namespace
FlowGraph.Avalonia.Rendering.NodeRenderers
Assembly
FlowGraph.Avalonia.dll

A simplified node renderer optimized for large graphs. Uses minimal visual elements for better performance with 500+ nodes.

public class SimplifiedNodeRenderer : INodeRenderer
Inheritance
SimplifiedNodeRenderer
Implements
Inherited Members

Methods

CreateNodeVisual(Node, NodeRenderContext)

Creates the visual representation for a node.

public Control CreateNodeVisual(Node node, NodeRenderContext context)

Parameters

node Node

The node data to render.

context NodeRenderContext

The rendering context with theme, scale, and settings.

Returns

Control

A Control representing the node visual.

GetHeight(Node, FlowCanvasSettings)

Gets the default height of the node in canvas units (before scaling). Return null to use the default height from settings.

public double? GetHeight(Node node, FlowCanvasSettings settings)

Parameters

node Node
settings FlowCanvasSettings

Returns

double?

GetMinHeight(Node, FlowCanvasSettings)

Gets the minimum height for resizing. Return null for no minimum.

public double? GetMinHeight(Node node, FlowCanvasSettings settings)

Parameters

node Node
settings FlowCanvasSettings

Returns

double?

GetMinWidth(Node, FlowCanvasSettings)

Gets the minimum width for resizing. Return null for no minimum.

public double? GetMinWidth(Node node, FlowCanvasSettings settings)

Parameters

node Node
settings FlowCanvasSettings

Returns

double?

GetWidth(Node, FlowCanvasSettings)

Gets the default width of the node in canvas units (before scaling). Return null to use the default width from settings.

public double? GetWidth(Node node, FlowCanvasSettings settings)

Parameters

node Node
settings FlowCanvasSettings

Returns

double?

UpdateSelection(Control, Node, NodeRenderContext)

Updates the visual state when selection changes.

public void UpdateSelection(Control visual, Node node, NodeRenderContext context)

Parameters

visual Control

The node's visual control.

node Node

The node data.

context NodeRenderContext

The rendering context.

UpdateSize(Control, Node, NodeRenderContext, double, double)

Updates the size of an existing node visual.

public void UpdateSize(Control visual, Node node, NodeRenderContext context, double width, double height)

Parameters

visual Control

The node's visual control.

node Node

The node data.

context NodeRenderContext

The rendering context.

width double

The new width in canvas units.

height double

The new height in canvas units.

Remarks

IMPORTANT: Implementations MUST update ALL child elements within the visual, not just the root container. Failing to update child elements will cause the visual to appear unchanged during resize operations until a full re-render occurs.

For composite visuals (e.g., a Grid containing Rectangles, Borders, or Canvases), iterate through children and update their Width/Height properties accordingly.

public void UpdateSize(Control visual, Node node, NodeRenderContext context, double width, double height)
{
    var scaledWidth = width * context.Scale;
    var scaledHeight = height * context.Scale;

    if (visual is Grid grid)
    {
        grid.Width = scaledWidth;
        grid.Height = scaledHeight;

        // CRITICAL: Also update all child elements
        foreach (var child in grid.Children)
        {
            if (child is Rectangle rect)
            {
                rect.Width = scaledWidth;
                rect.Height = scaledHeight;
            }
        }
    }
}