Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to Copy a CustomerLink whit DesignDiagram.CopySelection method? (Read 4073 times)
heyx
Junior Member
**
Offline


I Love MindFusion!

Posts: 69
Joined: Oct 9th, 2014
How to Copy a CustomerLink whit DesignDiagram.CopySelection method?
Feb 28th, 2015 at 5:14am
Print Post  
hi,
I use Diagram.CopySelection method to Copy Items which I have Selected in Diagram.
But every time the CustomerLink never been copyed ? is something wrong there ?
and I use this code  Register the link
Code
Select All
Diagram.RegisterItemClass(typeof(EvLinkWithParam), "Evget:EvLinkWithParam", 100);
 


customerLink(EvLinkWithParam) con't be copyed !
  

error_003.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to Copy a CustomerLink whit DesignDiagram.CopySelection method?
Reply #1 - Mar 2nd, 2015 at 9:09am
Print Post  
Hi,

If you are copying links that are not connected to nodes, pass true to the bool unconnectedLinks parameter of CopySelection. Your custom class must also override the DiagramItem.Clone method.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
heyx
Junior Member
**
Offline


I Love MindFusion!

Posts: 69
Joined: Oct 9th, 2014
Re: How to Copy a CustomerLink whit DesignDiagram.CopySelection method?
Reply #2 - Mar 3rd, 2015 at 6:33am
Print Post  
hi Stoyan,
I have try to override the clone method in Link.
like this:
Code
Select All
        public override DiagramItem Clone(bool clipboard)
        {
            EvLinkWithParam cloneLink = new EvLinkWithParam();
            cloneLink.EvConditionColors = this.EvConditionColors;
            cloneLink.EvBindParam = this.EvBindParam;
            //....Set Customer Properties Value to new Link
            //how to get the link‘s default Properties to it(like startpoint,segment...and so on).
            return cloneLink;
        }
 


and I find that when I clone node,there is some property value gone.
  

effect_003.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to Copy a CustomerLink whit DesignDiagram.CopySelection method?
Reply #3 - Mar 3rd, 2015 at 6:02pm
Print Post  
Hi,

Overriding Clone in the link class won't help for copying properties of nodes. You must also implement Clone or a copy constructor for the custom node classes  too (EvBaseNode, etc).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
heyx
Junior Member
**
Offline


I Love MindFusion!

Posts: 69
Joined: Oct 9th, 2014
Re: How to Copy a CustomerLink whit DesignDiagram.CopySelection method?
Reply #4 - Mar 4th, 2015 at 1:22am
Print Post  
hi Stoyan,
I know that the link and the node need implement Clone method, I just describe a effect:
  if i create a node when the project is running. I can clone it .
but once I save a node and reload it.then clone it.it create some errors:"input string was not in a correct format".
  so I send the printscreen to show you the error.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to Copy a CustomerLink whit DesignDiagram.CopySelection method?
Reply #5 - Mar 4th, 2015 at 8:52am
Print Post  
If the differences shown in the screenshot appear only after you load from a file, I suppose that means you haven't implemented SaveToXml and LoadFromXml in the custom classes. Custom properties aren't saved automatically in files, you must call methods such as WriteString,WriteInt,WriteFloat,etc and respective Read variants from overridden serialization methods in order to store custom values.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
heyx
Junior Member
**
Offline


I Love MindFusion!

Posts: 69
Joined: Oct 9th, 2014
Re: How to Copy a CustomerLink whit DesignDiagram.CopySelection method?
Reply #6 - Mar 4th, 2015 at 9:10am
Print Post  
hi Stoyan,
   I have implemented  the  SaveToXml and LoadFromXml in my Customer class earlier. I think maybe some properties don‘t deal and I will check them soon.
   thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint