Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic CopyToClipboard  (with a ShapeNode derived cl (Read 2750 times)
jpinera
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 4th, 2011
CopyToClipboard  (with a ShapeNode derived cl
Jul 6th, 2011 at 1:34pm
Print Post  
I have a derived class from ShapeNode. When I select a node (based on that derived class) from the DiagramView and I try to copy to the clipboard (using CopyToClipboard method) an exception is raised. I supose that the problem can be that this is a derived class and there is not way to create a new instace of this class.

How can I copy nodes based on a derived class?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CopyToClipboard  (with a ShapeNode derived cl
Reply #1 - Jul 6th, 2011 at 2:38pm
Print Post  
You must override the Clone method and implement the binary serialization methods - SaveTo and LoadFrom.
  
Back to top
 
IP Logged
 
jpinera
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 4th, 2011
Re: CopyToClipboard  (with a ShapeNode derived cl
Reply #2 - Jul 6th, 2011 at 4:21pm
Print Post  
I overrided Clone method and I implement serialization methods. But is not working. When I copy a node, I see how methods SaveTo and Clone are called.
But when I paste the node, LoadFrom is not called. A new node is pasted, but this node is based on ShapeNode class instead my derived class.

I added to my class a default contructor, copy constructor and a constructor that has a ShapeNode objects as parameter.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CopyToClipboard  (with a ShapeNode derived cl
Reply #3 - Jul 6th, 2011 at 4:23pm
Print Post  
Also call the RegisterItemClass method from your application init code.
  
Back to top
 
IP Logged
 
jpinera
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 4th, 2011
Re: CopyToClipboard  (with a ShapeNode derived cl
Reply #4 - Jul 7th, 2011 at 6:34am
Print Post  
Smiley,

I did not call RegisterItemClass. Once I called it, nodes has been correctly copy and pasted.

One last question, can I copy and paste the diagramLinks?. I override Clone and serialization methods for my DiagramLink-based class, but when I try to copy and paste a gruop with nodes and links, it does not work.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CopyToClipboard  (with a ShapeNode derived cl
Reply #5 - Jul 7th, 2011 at 7:29am
Print Post  
Yes, but by default they are pasted only if both their end nodes were also copied. Use the overload that takes an "unconnectedLinks" parameter to paste links whose ends were not copied. However that will also disconnect the link; you will have to reattach it to its original nodes if you expect coping+pasting a single link to create repeating link between the same pair of nodes.

Also if you are using a custom link class, the same things apply here - you must override Clone, implement SaveTo and LoadFrom, and register the class for serialization.

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


I love YaBB 1G - SP1!

Posts: 10
Joined: Jul 4th, 2011
Re: CopyToClipboard  (with a ShapeNode derived cl
Reply #6 - Jul 7th, 2011 at 9:28am
Print Post  
Thanks a lot, now it working fine !!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint