Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic serialize/deserialize a diagram with a an extented shapeNode class (Read 1765 times)
Shiju
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Jun 29th, 2012
serialize/deserialize a diagram with a an extented shapeNode class
Aug 2nd, 2012 at 8:40am
Print Post  
Hi
    Can you please provide sample source code which demonstrate how to serialize/deserialize a diagram with a my own CustomShapeNode class which is inherited from 'ShapeNode'.
       Also I want to show a context menu when i right click on my 'CustomShapeNode' class. What's the easiest way to achieve this? I see ShapeNode class has a 'ContextMenu' property.

thanks,
Shiju
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: serialize/deserialize a diagram with a an extented shapeNode class
Reply #1 - Aug 2nd, 2012 at 11:03am
Print Post  
Hi,

You can find serialization of derived node types demonstrated in Tutorial 4. In short, call RegisterItemClass method to map your class to a string id used in XML files, and override the SaveToXml and LoadFromXml methods of the base node type to serialize your additional properties.

To show a context menu, handle the NodeClicked event and set ContextMenu.IsOpen from inside an if block:

Code
Select All
if (e.Button == MouseButton.Right && e.Node is CustomShapeNode)
    ...
 



Check the TreeLayout example for a sample event handler.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint