Table of Contents

Interface IDirectNodeRenderer

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

Interface for custom node renderers that support direct DrawingContext rendering. Implement this interface in addition to INodeRenderer to provide custom drawing logic for the high-performance DirectCanvasRenderer mode.

public interface IDirectNodeRenderer

Examples

public class MyCustomRenderer : INodeRenderer, IDirectNodeRenderer
{
    // INodeRenderer implementation for visual tree mode
    public Control CreateNodeVisual(Node node, NodeRenderContext context) { ... }

    // IDirectNodeRenderer implementation for direct mode
    public void DrawNode(DrawingContext context, Node node, DirectNodeRenderContext ctx)
    {
        // Draw custom shape
        var geometry = new EllipseGeometry(ctx.ScreenBounds);
        context.DrawGeometry(ctx.Background, ctx.BorderPen, geometry);

        // Draw label
        if (!ctx.IsEditing)
        {
            // Draw text...
        }
    }
}

Remarks

When DirectCanvasRenderer renders a node, it first checks if the node's renderer implements IDirectNodeRenderer. If so, it delegates to DrawNode(DrawingContext, Node, DirectNodeRenderContext). Otherwise, it uses the built-in default drawing logic.

Implementations should: - Draw node background and border - Draw node label (unless editingNodeId matches) - NOT draw ports (handled by DirectCanvasRenderer for consistency)

Methods

DrawNode(DrawingContext, Node, DirectNodeRenderContext)

Draws the node directly to a DrawingContext.

void DrawNode(DrawingContext context, Node node, DirectNodeRenderContext renderContext)

Parameters

context DrawingContext

The Avalonia drawing context.

node Node

The node to draw.

renderContext DirectNodeRenderContext

Context with pre-calculated screen bounds, brushes, and state.