Class HeaderedNodeRendererBase
- Namespace
- FlowGraph.Avalonia.Rendering.NodeRenderers
- Assembly
- FlowGraph.Avalonia.dll
Base class for nodes with a header section and content area (React Flow style). Structure: Outer border (rounded) -> Header (semi-transparent) + Body (solid white) Uses true container resize (like React Flow, Rete.js, Node-RED) - content stays fixed size, container grows/shrinks to provide more/less space.
public abstract class HeaderedNodeRendererBase : DataNodeRendererBase, IEditableNodeRenderer, IDataNodeRenderer, INodeRenderer
- Inheritance
-
HeaderedNodeRendererBase
- Implements
- Derived
- Inherited Members
Fields
BodyPanelTag
protected const string BodyPanelTag = "BodyPanel"
Field Value
ContentPanelTag
protected const string ContentPanelTag = "ContentPanel"
Field Value
HeaderLabelTag
protected const string HeaderLabelTag = "HeaderLabel"
Field Value
HeaderPanelTag
protected const string HeaderPanelTag = "HeaderPanel"
Field Value
MainPanelTag
protected const string MainPanelTag = "MainPanel"
Field Value
OuterBorderTag
protected const string OuterBorderTag = "OuterBorder"
Field Value
Properties
BorderThickness
Gets the border thickness for the outer node border.
protected virtual double BorderThickness { get; }
Property Value
ContentVerticalPadding
Vertical padding for content inside the body.
protected virtual double ContentVerticalPadding { get; }
Property Value
CornerRadius
The corner radius for the outer node border.
protected virtual double CornerRadius { get; }
Property Value
HeaderFontSize
The font size for the header label.
protected virtual double HeaderFontSize { get; }
Property Value
HeaderVerticalPadding
Vertical padding for the header area.
protected virtual double HeaderVerticalPadding { get; }
Property Value
HorizontalPadding
Horizontal padding for content inside the header and body.
protected virtual double HorizontalPadding { get; }
Property Value
SelectedBorderThickness
Gets the selected border thickness.
protected virtual double SelectedBorderThickness { get; }
Property Value
Methods
CreateContent(Node, INodeProcessor?, NodeRenderContext)
Creates the content area control(s).
protected abstract Control CreateContent(Node node, INodeProcessor? processor, NodeRenderContext context)
Parameters
nodeNodeprocessorINodeProcessorcontextNodeRenderContext
Returns
- Control
CreateDataBoundVisual(Node, INodeProcessor?, NodeRenderContext)
Creates the visual with data binding context.
public override Control CreateDataBoundVisual(Node node, INodeProcessor? processor, NodeRenderContext context)
Parameters
nodeNodeThe node to render.
processorINodeProcessorThe node's data processor (may be null for display-only nodes).
contextNodeRenderContextThe render context.
Returns
- Control
A control bound to the node's data.
CreateNodeVisual(Node, NodeRenderContext)
Creates the visual representation for a node.
public override 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.
GetBodyBackgroundBrush(ThemeResources)
Gets the body background brush from theme, with optional override.
protected virtual IBrush GetBodyBackgroundBrush(ThemeResources theme)
Parameters
themeThemeResources
Returns
- IBrush
GetDefaultLabel()
Gets the default label to display when the node has no label set.
protected virtual string GetDefaultLabel()
Returns
GetHeaderBackgroundBrush(ThemeResources)
Gets the header background brush from theme, with optional override.
protected virtual IBrush GetHeaderBackgroundBrush(ThemeResources theme)
Parameters
themeThemeResources
Returns
- IBrush
GetHeaderTextBrush(ThemeResources)
Gets the header text brush from theme, with optional override.
protected virtual IBrush GetHeaderTextBrush(ThemeResources theme)
Parameters
themeThemeResources
Returns
- IBrush
GetNodeBorderBrush(ThemeResources)
Gets the node border brush from theme, with optional override.
protected virtual IBrush GetNodeBorderBrush(ThemeResources theme)
Parameters
themeThemeResources
Returns
- IBrush
GetShadowColor(ThemeResources)
Gets the shadow color from theme, with optional override.
protected virtual Color GetShadowColor(ThemeResources theme)
Parameters
themeThemeResources
Returns
- Color
UpdateSelection(Control, Node, NodeRenderContext)
Updates the visual state when selection changes.
public override 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 override 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;
}
}
}
}