Articles in this section
Category / Section

How do I extend the functionality of the Essential Diagram TextNode and RichTextNode classes?

1 min read

How do I extend the functionality of the Essential Diagram TextNode and RichTextNode classes?

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 it's TextTool.TextFactory/RichTextTool.RichTextFactory property with a delegate that creates the derived TextNode/RichTextNode type. A sample factory delegate is shown below,

C#

// 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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied