Class CanvasRenderService
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
retainedRendererCanvasElementManagerThe retained mode (visual tree) renderer.
getDirectRendererFunc<DirectCanvasRenderer>Function to get the direct renderer (may be null if not initialized).
getIsDirectRenderingModeFunc<bool>Function to check if direct rendering mode is active.
renderEdgesActionActionAction to re-render edges.
refreshActionActionAction to force a full refresh.
getThemeFunc<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
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
nodeNodeThe 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
nodeNodeThe node that was resized.
UpdateNodePosition(Node)
Updates the visual position of a node. Works in both rendering modes.
public void UpdateNodePosition(Node node)
Parameters
nodeNodeThe node to update.
UpdateNodeSelection(Node)
Updates the selection state of a node. Works in both rendering modes.
public void UpdateNodeSelection(Node node)
Parameters
nodeNodeThe node to update.
UpdateNodeSize(Node)
Updates the visual size of a node. Works in both rendering modes.
public void UpdateNodeSize(Node node)
Parameters
nodeNodeThe 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
nodeNodeThe node to update.
UpdateResizeHandlePositions(Node)
Updates the resize handle positions for a node. Works in both rendering modes.
public void UpdateResizeHandlePositions(Node node)
Parameters
nodeNodeThe node to update handles for.