Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Paste a selected object at mouse position (Read 3039 times)
suwit
Guest


Paste a selected object at mouse position
Nov 2nd, 2005 at 3:30pm
Print Post  
Hello, Shocked
Is it posible to implement paste selected object at current mouse position (right click copy and paste a t  Mouse x,y ),
Thanks,
Suwit A.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Paste a selected object at mouse position
Reply #1 - Nov 2nd, 2005 at 4:31pm
Print Post  
Hello,

The arguments of the PasteFromClipboard method specify the offset of the pasted items from the original ones. So when calling CopyToClipboard, you could save in a variable the bounding rectangle of the selection; then when calling Paste, set the x and y offset arguments to be the difference between the saved top-left point and the current mouse position.

HTH
Stoyan
  
Back to top
 
IP Logged
 
suwit
Guest


Re: Paste a selected object at mouse position
Reply #2 - Nov 3rd, 2005 at 12:24pm
Print Post  
Hello, ???
i found that PasteFromClipboard(x,y) shift my position out from actual potision.

Pls help,
Swt.

below is my code
-------------------------------------------------------------
gb_pointf ->Last Mouse position (OnMouseDown)
---------------------------------------------------------
PointF pp = this._flowChart.ClientToDoc(gb_pointf);
int x = Convert.ToInt32(pp.X);
int y = Convert.ToInt32(pp.Y);
_flowChart.PasteFromClipboard( x, y );
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Paste a selected object at mouse position
Reply #3 - Nov 3rd, 2005 at 12:39pm
Print Post  
x and y must specify the difference between the coordinates of the original items and the pasted ones. So try this:

RectangleF selrc = fc.Selection.BoundingRect;
PointF oldpos = new PointF(selrc.X, selrc.Y);
fc.CopyToClipboard(...);

PointF currentPos = ... //the current position of mouse
dx = currentPos.X - oldpos.X;
dy = currentPos.Y - oldpos.Y;
fc.PasteFromClipboard(dx, dy);
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint