Table of Contents

Class CanvasRenderService

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

Unified graph render service that abstracts the difference between retained mode (CanvasElementManager) and direct rendering mode (DirectCanvasRenderer).

This service ensures that all rendering operations work correctly regardless of which rendering mode is active, solving the recurring issue of handlers only implementing one rendering path.

public class CanvasRenderService : ICanvasRenderService
Inheritance
CanvasRenderService
Implements
Inherited Members

Constructors

CanvasRenderService(CanvasElementManager, Func<DirectCanvasRenderer?>, Func<bool>, Action, Action, Func<ThemeResources>)

Creates a new GraphRenderService.

public CanvasRenderService(CanvasElementManager retainedRenderer, Func<DirectCanvasRenderer?> getDirectRenderer, Func<bool> getIsDirectRenderingMode, Action renderEdgesAction, Action refreshAction, Func<ThemeResources> getTheme)

Parameters

retainedRenderer CanvasElementManager

The retained mode (visual tree) renderer.

getDirectRenderer Func<DirectCanvasRenderer>

Function to get the direct renderer (may be null if not initialized).

getIsDirectRenderingMode Func<bool>

Function to check if direct rendering mode is active.

renderEdgesAction Action

Action to re-render edges.

refreshAction Action

Action to force a full refresh.

getTheme Func<ThemeResources>

Function to get the current theme resources.

Properties

IsDirectRenderingMode

Gets whether the renderer is currently in direct rendering mode.

public bool IsDirectRenderingMode { get; }

Property Value

bool

Methods

Invalidate()

Invalidates the render and schedules a repaint. For retained mode, this updates visuals. For direct mode, this triggers InvalidateVisual().

public void Invalidate()

Refresh()

Forces an immediate refresh/re-render of all graph elements. Use sparingly as this can be expensive.

public void Refresh()

RenderEdges()

Re-renders all edges. Call this after node position/size changes.

public void RenderEdges()

UpdateNodeAfterMove(Node)

Updates all visual aspects of a node after a move operation. This is more efficient than calling individual update methods. In direct mode, this triggers a single invalidation. In retained mode, this updates position, handles, and edges.

public void UpdateNodeAfterMove(Node node)

Parameters

node Node

The node that was moved.

UpdateNodeAfterResize(Node)

Updates all visual aspects of a node after a resize operation. This is more efficient than calling individual update methods. In direct mode, this triggers a single invalidation. In retained mode, this updates size, position, handles, and edges.

public void UpdateNodeAfterResize(Node node)

Parameters

node Node

The node that was resized.

UpdateNodePosition(Node)

Updates the visual position of a node. Works in both rendering modes.

public void UpdateNodePosition(Node node)

Parameters

node Node

The node to update.

UpdateNodeSelection(Node)

Updates the selection state of a node. Works in both rendering modes.

public void UpdateNodeSelection(Node node)

Parameters

node Node

The node to update.

UpdateNodeSize(Node)

Updates the visual size of a node. Works in both rendering modes.

public void UpdateNodeSize(Node node)

Parameters

node Node

The node to update.

UpdateNodeStyle(Node)

Updates the custom style of a node based on its Data property. Call this when node.Data changes and may affect visual appearance.

public void UpdateNodeStyle(Node node)

Parameters

node Node

The node to update.

UpdateResizeHandlePositions(Node)

Updates the resize handle positions for a node. Works in both rendering modes.

public void UpdateResizeHandlePositions(Node node)

Parameters

node Node

The node to update handles for.