Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic pasting the nodes on the cursor position (Read 3564 times)
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
pasting the nodes on the cursor position
Aug 18th, 2012 at 5:22am
Print Post  
Dear Stoyo,

       i am copying some nodes and want to paste the nodes on the cursor postion. but it is pasting different location. the code i am using is

            Point p = diagramView.PointToClient(Cursor.Position);
            PointF oldcurpos = diagramView.DocToClient(p);

            pasteDX = Convert.ToInt32(oldcurpos.X);
            pasteDY = Convert.ToInt32(oldcurpos.Y);
            
            diagramView.PasteFromClipboard(pasteDX, pasteDY, true);
kindly help
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: pasting the nodes on the cursor position
Reply #1 - Aug 20th, 2012 at 8:22am
Print Post  
The dx,dy parameters of PasteFromClipboard designate offset from the original position of the pasted items. If you need them pasted at a specific position, you will have to calculate that offset by subtracting the original Selection.Bounds.Location from the  paste location.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
Re: pasting the nodes on the cursor position
Reply #2 - Aug 20th, 2012 at 11:01am
Print Post  
thanks Stoyan,

i have used the following code

            Point p = diagramView.PointToClient(Cursor.Position);
            PointF oldcurpos = diagramView.DocToClient(p);

            pasteDX = Convert.ToInt32(oldcurpos.X - diagram.Selection.Bounds.Location.X);
            pasteDY = Convert.ToInt32(oldcurpos.Y - diagram.Selection.Bounds.Location.Y);
            
            diagramView.PasteFromClipboard(pasteDX, pasteDY, true);

this code is working in the same file and the nodes are selected

1.  but i have unselected the node and paste. then it is pasting in some other position.

2.  if i paste in another file also it is pasting in some other position.

kindly help
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: pasting the nodes on the cursor position
Reply #3 - Aug 21st, 2012 at 6:51am
Print Post  
Do not use the current selection position, but save Selection.Bounds before calling CopyToClipboard and then use the saved position to calculate offset when pasting.
  
Back to top
 
IP Logged
 
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
Re: pasting the nodes on the cursor position
Reply #4 - Aug 21st, 2012 at 9:08am
Print Post  
Thanks alot stoyan
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint