Class GroupNodeRenderer
- Namespace
- FlowGraph.Avalonia.Rendering.NodeRenderers
- Assembly
- FlowGraph.Avalonia.dll
Renderer for group nodes that contain other nodes. Uses a translucent background similar to React Flow's grouping style. Supports inline label editing via IEditableNodeRenderer.
IMPORTANT: This renderer uses constants from GraphRenderModel to ensure 100% visual parity with DirectCanvasRenderer.
public class GroupNodeRenderer : IEditableNodeRenderer, INodeRenderer
- Inheritance
-
GroupNodeRenderer
- Implements
- Inherited Members
Methods
BeginEdit(Control, Node, NodeRenderContext, Action<string>, Action)
Enters edit mode - replaces the label TextBlock with a TextBox.
public void BeginEdit(Control visual, Node node, NodeRenderContext context, Action<string> onCommit, Action onCancel)
Parameters
visualControlnodeNodecontextNodeRenderContextonCommitAction<string>onCancelAction
CreateNodeVisual(Node, NodeRenderContext)
Creates the visual representation for a node.
public Control CreateNodeVisual(Node node, NodeRenderContext context)
Parameters
nodeNodeThe node data to render.
contextNodeRenderContextThe rendering context with theme, scale, and settings.
Returns
- Control
A Control representing the node visual.
EndEdit(Control, Node, NodeRenderContext)
Exits edit mode - removes the TextBox and shows the label.
public void EndEdit(Control visual, Node node, NodeRenderContext context)
Parameters
visualControlnodeNodecontextNodeRenderContext
GetHeight(Node, FlowCanvasSettings)
Gets the default height of the node in canvas units (before scaling). Return null to use the default height from settings.
public double? GetHeight(Node node, FlowCanvasSettings settings)
Parameters
nodeNodesettingsFlowCanvasSettings
Returns
GetMinHeight(Node, FlowCanvasSettings)
Gets the minimum height for resizing. Return null for no minimum.
public double? GetMinHeight(Node node, FlowCanvasSettings settings)
Parameters
nodeNodesettingsFlowCanvasSettings
Returns
GetMinWidth(Node, FlowCanvasSettings)
Gets the minimum width for resizing. Return null for no minimum.
public double? GetMinWidth(Node node, FlowCanvasSettings settings)
Parameters
nodeNodesettingsFlowCanvasSettings
Returns
GetWidth(Node, FlowCanvasSettings)
Gets the default width of the node in canvas units (before scaling). Return null to use the default width from settings.
public double? GetWidth(Node node, FlowCanvasSettings settings)
Parameters
nodeNodesettingsFlowCanvasSettings
Returns
IsEditing(Control)
Gets whether the node is currently in edit mode.
public bool IsEditing(Control visual)
Parameters
visualControl
Returns
UpdateCollapsedState(Control, Node, NodeRenderContext)
public void UpdateCollapsedState(Control visual, Node node, NodeRenderContext context)
Parameters
visualControlnodeNodecontextNodeRenderContext
UpdateSelection(Control, Node, NodeRenderContext)
Updates the visual state when selection changes.
public void UpdateSelection(Control visual, Node node, NodeRenderContext context)
Parameters
visualControlThe node's visual control.
nodeNodeThe node data.
contextNodeRenderContextThe rendering context.
UpdateSize(Control, Node, NodeRenderContext, double, double)
Updates the size of an existing node visual.
public void UpdateSize(Control visual, Node node, NodeRenderContext context, double width, double height)
Parameters
visualControlThe node's visual control.
nodeNodeThe node data.
contextNodeRenderContextThe rendering context.
widthdoubleThe new width in canvas units.
heightdoubleThe new height in canvas units.
Remarks
IMPORTANT: Implementations MUST update ALL child elements within the visual, not just the root container. Failing to update child elements will cause the visual to appear unchanged during resize operations until a full re-render occurs.
For composite visuals (e.g., a Grid containing Rectangles, Borders, or Canvases), iterate through children and update their Width/Height properties accordingly.
public void UpdateSize(Control visual, Node node, NodeRenderContext context, double width, double height)
{
var scaledWidth = width * context.Scale;
var scaledHeight = height * context.Scale;
if (visual is Grid grid)
{
grid.Width = scaledWidth;
grid.Height = scaledHeight;
// CRITICAL: Also update all child elements
foreach (var child in grid.Children)
{
if (child is Rectangle rect)
{
rect.Width = scaledWidth;
rect.Height = scaledHeight;
}
}
}
}