Articles in this section
Category / Section

What are my options for creating a custom symbol? How do I make it respond to mouse events?

2 mins read

What are my options for creating a custom symbol? How do I make it respond to mouse events?

The symbol can be defined using the Essential Diagram SymbolDesigner utility, in which case, the various drawing tools in the designer may be used for creating the shapes that will make up the symbol. Symbols built using the SymbolDesigner are saved as symbol palette files and loaded into an application using symbol palettes from which it can be dragged and dropped onto the diagram as shown in the ‘Diagram\Samples\In Depth\DiagramBuilder’ sample, or used directly through the Syncfusion.Windows.Forms.Diagram.SymbolPalette API for creating instances of the symbol. The ‘Samples\Quick Start\Text Symbols\Multiline’ sample shows similar symbols designed using the SymbolDesigner utility.

The entire symbol may also be defined using the Essential Diagram API. This approach involves defining a subclass of the Syncfusion.Windows.Forms.Diagram.Symbol class in your application (or in a library module), and creating and adding the above listed nodes as children of this symbol class. The ‘Samples\Quick Start\DynamicSymbol’ sample shows a programmatically defined symbol, and referring to this implementation will give a good idea on how to go about creating the symbol.

As for responding to mouse events - highlighting a section of the symbol when it is clicked on for instance - this is especially easy to do when defining the symbol programmatically. All that you have to do is override the custom Symbol’s OnClick method, check whether one of the text rectangles was clicked by examining the method’s NodeMouseEventArgs param, and if so provide a suitable highlight for the node by changing its FillStyle or any of the other style properties. In fact, the custom symbol used by the ‘Quick Start\DynamicSymbol’ sample shows node highlighting in response to mouse click events.

Mouse events may be handled for symbols defined using the SymbolDesigner as well. This is done by either sub-classing the symbol as shown in the ‘Samples\Quick Start\CustomSymbol’ sample, and providing an override for the symbol’s OnClick method, or by simply handling the Diagram.NodeClick event in your application, and determining whether one of the text rectangles in the symbol was clicked on, and if so, change the node’s FillStyle property to reflect the clicked state.

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