Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Loading diagram with custom nodes from JSON on server side (Read 7000 times)
Ana
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: May 6th, 2014
Loading diagram with custom nodes from JSON on server side
May 6th, 2014 at 4:14pm
Print Post  
Hello,

I have a diagram with custom node types that are derived from ShapeNode. Is it possible to load diagram back on the server side from json for the purpose of diagram exporting or saving?
I tried using DiagramView.FromRequest and DiagramView.FromJson methods. In case where diagram is consisted only out of ShapeNodes and no derived types, these work all right. But, when diagram is consisted of node types that are child types ShapeNode type, these methods produce an error.
Can you recommend what is the best approach for this?


Thanks,
Ana


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Loading diagram with custom nodes from JSON on server side
Reply #1 - May 7th, 2014 at 7:08am
Print Post  
Hi,

You will have to implement respective custom classes in .NET too, create JSON converters to enable client-server transfer, and call the RegisterItemClass method to enable serialization. The CustomNodes sample project shows that.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Ana
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: May 6th, 2014
Re: Loading diagram with custom nodes from JSON on server side
Reply #2 - May 7th, 2014 at 10:54am
Print Post  
Hello,

Thanks for your replay, the client-server transfer works now that I made converters for custom node types and registered both custom node types and converters (as in sample project).
I can do the export of the diagram without producing that error, but I have another issue now. The exported diagram doesn't display nodes with custom shapes( I defined few custom Shapes on client side by defining outlines and decorations and they display nicely on the diagram, but when I try exporting of the diagram these nodes don't show at all).
Is there way to resolve this?


Thank you very much,
Ana
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Loading diagram with custom nodes from JSON on server side
Reply #3 - May 7th, 2014 at 1:37pm
Print Post  
Hi,

Shape definitions are not transferred to server side at this time, but node' shapes are serialized in JSON only by their ID. To see correct shapes in exported files, you will have to define them with same string identifiers in server code too before calling FromJson.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Ana
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: May 6th, 2014
Re: Loading diagram with custom nodes from JSON on server side
Reply #4 - May 8th, 2014 at 11:05am
Print Post  
Hello,

That works, if I define custom shapes ahead of FromJson call and then export, nodes with custom shapes appear.
Is it possible to set some additional options for decorations when defining custom shapes on the server side?
On the client side, I was able to to define some additional options like decorationPen or decorationBrush when defining custom shape. Is there something similar on the server side?
I tried to find a way using both ElementTemplate constructors and Visio-like formula constructors for shapes, but couldn't find a way to define decoration fill.


Thanks,
Ana
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Loading diagram with custom nodes from JSON on server side
Reply #5 - May 8th, 2014 at 3:30pm
Print Post  
Hi,

Try adding ShapeDecoration objects to Shape.ShapeDecorations; they provide Brush and Pen properties.

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