Class ShapeVisualManager
- Namespace
- FlowGraph.Avalonia.Rendering.ShapeRenderers
- Assembly
- FlowGraph.Avalonia.dll
Manages the visual representation of shape elements on the canvas.
public class ShapeVisualManager
- Inheritance
-
ShapeVisualManager
- Inherited Members
Remarks
ShapeVisualManager follows the same pattern as NodeVisualManager and EdgeVisualManager, providing consistent management of visual-to-model mappings for shape elements.
It handles: - Creating visuals for shape elements - Positioning visuals in canvas coordinates - Updating visuals when properties change - Removing visuals when shapes are removed
Constructors
ShapeVisualManager(Canvas)
Creates a new ShapeVisualManager for the specified canvas.
public ShapeVisualManager(Canvas canvas)
Parameters
canvasCanvasThe canvas to manage shape visuals on.
Methods
AddOrUpdateShape(ShapeElement)
Adds or updates a shape visual on the canvas.
public void AddOrUpdateShape(ShapeElement shape)
Parameters
shapeShapeElementThe shape element to render.
Clear()
Removes all shape visuals from the canvas.
public void Clear()
GetShapeIds()
Gets all tracked shape IDs.
public IEnumerable<string> GetShapeIds()
Returns
GetVisual(string)
Gets the visual for a shape by ID.
public Control? GetVisual(string shapeId)
Parameters
shapeIdstringThe shape ID.
Returns
- Control
The visual control, or null if not found.
RefreshAll()
Updates all shape visuals (e.g., after zoom change).
public void RefreshAll()
RemoveShape(string)
Removes a shape visual from the canvas.
public void RemoveShape(string shapeId)
Parameters
shapeIdstringThe ID of the shape to remove.
SetRenderContext(RenderContext)
Sets the render context for coordinate transformations and settings.
public void SetRenderContext(RenderContext context)
Parameters
contextRenderContextThe render context to use.
SetTheme(ThemeResources)
Sets the theme for rendering resize handles.
public void SetTheme(ThemeResources theme)
Parameters
themeThemeResources
UpdateResizeHandlePositions()
Updates the resize handle positions for all tracked shapes. Call this during shape dragging to keep resize handles in sync with shape positions.
public void UpdateResizeHandlePositions()
UpdateSelection(string, bool)
Updates the selection state of a shape visual.
public void UpdateSelection(string shapeId, bool isSelected)