Table of Contents

Class RenderTargetAdapter

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

Implementation of IRenderTarget that provides mode-aware temporary visual rendering for interaction states.

This adapter automatically selects the correct container and coordinate space:

  • Visual Tree mode: MainCanvas with canvas coordinates (MatrixTransform handles viewport)
  • Direct Rendering mode: RootPanel with viewport coordinates (self-transformed)
public sealed class RenderTargetAdapter : IRenderTarget
Inheritance
RenderTargetAdapter
Implements
Inherited Members

Constructors

RenderTargetAdapter(ViewportState, Panel?, Canvas?, DirectCanvasRenderer?)

Creates a new RenderTargetAdapter.

public RenderTargetAdapter(ViewportState viewport, Panel? rootPanel, Canvas? mainCanvas, DirectCanvasRenderer? directRenderer)

Parameters

viewport ViewportState
rootPanel Panel
mainCanvas Canvas
directRenderer DirectCanvasRenderer

Properties

IsDirectRenderingMode

Whether we're currently in Direct Rendering mode.

public bool IsDirectRenderingMode { get; }

Property Value

bool

Methods

CreateConnectionPreview(CanvasPoint, CanvasPoint, IBrush, double, double[]?)

Creates a temporary bezier connection line for previewing connections.

The line is styled with dashed strokes and reduced opacity to indicate it's a preview rather than a committed connection.

public IConnectionPreviewHandle CreateConnectionPreview(CanvasPoint start, CanvasPoint end, IBrush stroke, double strokeThickness, double[]? dashArray = null)

Parameters

start CanvasPoint

Start point in canvas coordinates (port position).

end CanvasPoint

End point in canvas coordinates (cursor or snap target).

stroke IBrush

Stroke brush for the line.

strokeThickness double

Stroke thickness (in screen pixels, not canvas units).

dashArray double[]

Optional dash pattern. Defaults to [5, 3] for preview style.

Returns

IConnectionPreviewHandle

A handle that can be used to update or dispose the preview line.

CreateSelectionBox(CanvasRect, IBrush?, IBrush, double)

Creates a temporary selection rectangle.

Used during box selection to show the selection area.

public ISelectionBoxHandle CreateSelectionBox(CanvasRect bounds, IBrush? fill, IBrush stroke, double strokeThickness)

Parameters

bounds CanvasRect

Rectangle bounds in canvas coordinates.

fill IBrush

Optional fill brush (typically semi-transparent).

stroke IBrush

Stroke brush for the border.

strokeThickness double

Border thickness (in screen pixels).

Returns

ISelectionBoxHandle

A handle that can be used to update or dispose the selection box.

Invalidate()

Invalidates the render target, triggering a redraw.

In Visual Tree mode, this may do nothing (elements update automatically). In Direct Rendering mode, this calls InvalidateVisual() on the renderer.

public void Invalidate()