Table of Contents

Class GroupNodeRenderer

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

Renderer for group nodes that contain other nodes. Uses a translucent background similar to React Flow's grouping style. Supports inline label editing via IEditableNodeRenderer.

IMPORTANT: This renderer uses constants from GraphRenderModel to ensure 100% visual parity with DirectCanvasRenderer.

public class GroupNodeRenderer : IEditableNodeRenderer, INodeRenderer
Inheritance
GroupNodeRenderer
Implements
Inherited Members

Methods

BeginEdit(Control, Node, NodeRenderContext, Action<string>, Action)

Enters edit mode - replaces the label TextBlock with a TextBox.

public void BeginEdit(Control visual, Node node, NodeRenderContext context, Action<string> onCommit, Action onCancel)

Parameters

visual Control
node Node
context NodeRenderContext
onCommit Action<string>
onCancel Action

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.

EndEdit(Control, Node, NodeRenderContext)

Exits edit mode - removes the TextBox and shows the label.

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

Parameters

visual Control
node Node
context NodeRenderContext

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?

IsEditing(Control)

Gets whether the node is currently in edit mode.

public bool IsEditing(Control visual)

Parameters

visual Control

Returns

bool

UpdateCollapsedState(Control, Node, NodeRenderContext)

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

Parameters

visual Control
node Node
context NodeRenderContext

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;
            }
        }
    }
}