Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom link serialization (Read 2088 times)
Francesco
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Apr 10th, 2017
Custom link serialization
Jul 3rd, 2017 at 3:35pm
Print Post  
I have a CustomDiagramLink, subclass of DiagramLink, I can save it through SaveToXml, but when I load I get a InvalidOperationException exception.
Here is written (Point 5) that I should call RegisterItemClass on the diagram
http://www.mindfusion.eu/onlinehelp/flowchartnet/Serialization_of_FlowChart_NET_...
But the Diagram class does not look to have RegisterItemClass

Here is written that a parameter-less constructor (or one with a diagram parameter) should be provided by the custom class.
http://www.mindfusion.eu/onlinehelp/flowchartnet/M_MindFusion_Diagramming_Diagra...
So, I have built a constructor with only a diagram parameter, and things seem to work. But is it correct?
Also, while the saved diagram could display proper arrowheads, the diagram loaded from a file does not show the arrowheads, even if I add this feature after loading the diagram from file!
(I do:
Diagram.LinkBaseShape = MindFusion.Diagramming.Wpf.ArrowHeads.Arrow;

and - even if it should not be necessary - in each link:
this.HeadShape = MindFusion.Diagramming.Wpf.ArrowHeads.Arrow;
)
What could I do?

I have none of these problems with Node's subclasses.
  
Back to top
 
IP Logged
 
Francesco
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Apr 10th, 2017
Re: Custom link serialization
Reply #1 - Jul 3rd, 2017 at 3:38pm
Print Post  
Sorry, I just came across this. So, I'll check it and let you know:
http://mindfusion.eu/Forum/YaBB.pl?num=1498704395
  
Back to top
 
IP Logged
 
Francesco
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Apr 10th, 2017
Re: Custom link serialization
Reply #2 - Jul 3rd, 2017 at 4:01pm
Print Post  
Yes, this example solved my problems
http://mindfusion.eu/Forum/YaBB.pl?num=1498704395
(even if I still had to create a CustomLink constructor with only the diagram as parameter - but this looks reasonable)
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Custom link serialization
Reply #3 - Jul 3rd, 2017 at 5:10pm
Print Post  
I think you will miss the arrowheads if you register the custom class with serialization format ID = 1 (last argument to RegisterItemClass). The base DiagramLink tries to parse arrowheads as integer values in format 1, later they were replaced by string identifiers. Problem is the same format ID is used for both yours and base class, so you should pass value larger than ours when registering (that's why the 100 in sample code you've linked). We plan to store separate identifiers for item classes from the hierarchy in upcoming revision of serialization schema to fix that.

Both no-args and (Diagram) constructors should work otherwise.
  
Back to top
 
IP Logged
 
Francesco
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 16
Joined: Apr 10th, 2017
Re: Custom link serialization
Reply #4 - Jul 3rd, 2017 at 6:31pm
Print Post  
Thank you!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint