FlowChart.NET 5 lets you inherit from the base node and link classes, add your own properties, implement custom drawing, serialization, undo/redo etc.
This sample shows how you can define and use your own item types -
https://mindfusion.org/_samples/IconNodes.zipIt shows some of the new API members for working with items and handling their events. Here are some points of notice -
* Now you can add new items by calling diagram.Nodes.Add(node) or diagram.Links.Add(link)
* There's just one set of node events, as opposed to the type-specific ones from the previous releases, e.g. NodeCreated instead of BoxCreated / TableCreated / ControlHostCreated
* You must call the Diagram.RegisterItemClass method in order to enable serialization for custom types. The method takes a type, a string id used in binary and XML formats, and revision id, as follows
Diagram.RegisterItemClass(typeof(IconNode), "IconNode", 1);
The method must be invoked in the initialization phase of the application. Afterwards the control saves the string id before saving items to binary or XML files. When loading, it creates items from the appropriate type based on the specified mapping.
* You can specify what items are created interactively by the users when they draw with the mouse by setting CustomNodeType and CustomLinkType, e.g.
diagramView.CustomNodeType = typeof(IconNode);
diagramView.Behavior = Behavior.Custom;
* You can implement your custom serialization logic by overriding the SaveTo and LoadFrom methods.
I hope we've made it easy enough to use custom item types. Please let us know if you have any suggestions how we could improve this further.
g.
p.s. XML serialization is not implemented yet.