Class ElementHitInfo
Unified hit test result for all canvas elements. Used for standardized tagging of controls and hit test payloads across both visual-tree and direct-rendering modes.
public sealed class ElementHitInfo
- Inheritance
-
ElementHitInfo
- Inherited Members
Remarks
This replaces disparate tagging approaches: - Control.Tag = Node - Control.Tag = Edge - Control.Tag = (Node, Port, bool)
With a single unified payload that supports all element types and handles.
Constructors
ElementHitInfo(ICanvasElement)
Creates a hit info for a simple element (node, edge, shape).
public ElementHitInfo(ICanvasElement element)
Parameters
elementICanvasElement
ElementHitInfo(ICanvasElement, string)
Creates a hit info for an element with a handle (e.g., resize handle).
public ElementHitInfo(ICanvasElement element, string handle)
Parameters
elementICanvasElementhandlestring
ElementHitInfo(Node, string, bool)
Creates a hit info for a node port.
public ElementHitInfo(Node node, string portId, bool isOutput)
Parameters
Properties
AsEdge
Convenience property: gets the element as an Edge if applicable.
public Edge? AsEdge { get; }
Property Value
AsNode
Convenience property: gets the element as a Node if applicable.
public Node? AsNode { get; }
Property Value
AsShape
Convenience property: gets the element as a ShapeElement if applicable.
public ShapeElement? AsShape { get; }
Property Value
Element
The canvas element that was hit.
public ICanvasElement Element { get; }
Property Value
Handle
Optional handle identifier (e.g., "resize", "rotate"). Null if the main element was hit.
public string? Handle { get; }
Property Value
IsHandle
Convenience property: true if this is a handle hit.
public bool IsHandle { get; }
Property Value
IsOutputPort
For port hits, indicates whether this is an output port (true) or input port (false).
public bool IsOutputPort { get; }
Property Value
IsPort
Convenience property: true if this is a port hit.
public bool IsPort { get; }
Property Value
PortId
Optional port identifier for node port hits. Null if not a port hit.
public string? PortId { get; }
Property Value
Methods
FromElement(ICanvasElement)
Creates an ElementHitInfo for a regular element hit.
public static ElementHitInfo FromElement(ICanvasElement element)
Parameters
elementICanvasElement
Returns
FromHandle(ICanvasElement, string)
Creates an ElementHitInfo for an element handle hit.
public static ElementHitInfo FromHandle(ICanvasElement element, string handle)
Parameters
elementICanvasElementhandlestring
Returns
FromPort(Node, string, bool)
Creates an ElementHitInfo for a node port hit.
public static ElementHitInfo FromPort(Node node, string portId, bool isOutput)
Parameters
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.