How to extend functionality of TextNode and RichTextNode classes in WinForms Diagram?
The first step is to create the custom Text or RichText node types in your application by subclassing the base Essential® Diagram TextNode or RichTextNode classes. Once the custom text node has been defined, you will have to initialize the Diagram Text/RichTextTool to use this class in place of the default TextNode/RichTextNode. This is done by accessing the TextTool/RichTextTool from the Diagram's Controller using the Controller.GetTool(string toolName) with 'TextTool'/'RichTextTool' as the tool name, and initializing its TextTool.TextFactory/RichTextTool.RichTextFactory property with a delegate that creates the derived TextNode/RichTextNode type. A sample factory delegate is shown below:
// Factory method for creating rich text nodes for the RichTextTool.
protected RichTextNode MyRichTextFactory(RectangleF bounds, string text)
{
Syncfusion.Windows.Forms.Diagram.RichTextNode rtfNode = new MyRichTextNode("Rich Text");
rtfNode.Bounds = bounds;
return rtfNode;
}
VB
' Factory method for creating rich text nodes for the RichTextTool.
Protected Function MyRichTextFactory(ByVal bounds As RectangleF, ByVal text As String) As RichTextNode
Dim rtfNode As Syncfusion.Windows.Forms.Diagram.RichTextNode = New MyRichTextNode("Rich Text")
rtfNode.Bounds = bounds
Return rtfNode
End Function
Conclusion
I hope you enjoyed learning about how to extend the functionality of TextNode and RichTextNode classes in WinForms Diagram.
You can refer to our WinForms Diagram feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Diagram documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!