Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problems with pasting custom shapenodes (Read 3270 times)
lindborg
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 30th, 2008
Problems with pasting custom shapenodes
Nov 24th, 2008 at 3:51pm
Print Post  
I have created a custom Shapenode, a circle. But when I am copy and pasting this shape node the shape becomes a square. Can someone point me in the right direction? This is rather annoying Wink
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problems with pasting custom shapenodes
Reply #1 - Nov 24th, 2008 at 4:08pm
Print Post  
You will have to add a copy constructor, and if you have any custom fields, also override the SaveTo and LoadFrom methods.

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


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 30th, 2008
Re: Problems with pasting custom shapenodes
Reply #2 - Nov 25th, 2008 at 8:08am
Print Post  
Thanks Stoyo, but do you have some example code that explains?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problems with pasting custom shapenodes
Reply #3 - Nov 25th, 2008 at 8:41am
Print Post  
The IconNodes sample shows how to override SaveTo and LoadFrom. A copy constructor for the node class there would look like this:

Code
Select All
public IconNode(IconNode prototype) : base(prototype)
{
	label = prototype.label;
	icon = prototype.icon;
}
 



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


I love YaBB 1G - SP1!

Posts: 2
Joined: Nov 25th, 2008
Re: Problems with pasting custom shapenodes
Reply #4 - Nov 25th, 2008 at 11:04am
Print Post  
I'm tying to copy a ShapeNode using the CopyToClipboard and PasteFromClipboard methods using the code below.

Code
Select All
diagram1.DefaultShape = new Shape(new ElementTemplate[] {
   new ArcTemplate(0, 0, 100, 100, 0, 360, Color.Black, DashStyle.DashDot, 1f),
   new ArcTemplate(20, 20, 60, 60, 0, 360, Color.Black, DashStyle.DashDot, 1f)
   }, FillMode.Alternate);
ShapeNode s1 = diagram1.Factory.CreateShapeNode(10, 10, 10, 10);
diagram1.Selection.AddItem(s1);
diagramView1.CopyToClipboard(true);
diagramView1.PasteFromClipboard(25, 25);
 



In this case the FillMode of the Shape is not copied correctly. Is this something that will be fixed in future releases, or is there any known workaround?
And is there other properties on Shape that will not be copied correctly?

Or am I doing something wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problems with pasting custom shapenodes
Reply #5 - Nov 25th, 2008 at 3:19pm
Print Post  
We'll fix this in the next release.
  
Back to top
 
IP Logged
 
JohanMeridium
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Nov 25th, 2008
Re: Problems with pasting custom shapenodes
Reply #6 - Nov 26th, 2008 at 7:37am
Print Post  
Thanks, thats great!

After some more testing I found that setting some other prooerties on the Shape will make it dissappear when doing the copy.

Try the example above but set shape.Id to something. Then the circle Shape will be replaced by a square one.

Any suggestions on how we could workaroud this?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problems with pasting custom shapenodes
Reply #7 - Nov 26th, 2008 at 9:21am
Print Post  
If the shape has some ID assigned to it, only its ID is copied to the clipboard. When pasting it to a diagram in another process, a shape with the same ID must already be defined, or otherwise the node is reset to a rectangle.

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