Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic copy paste/move selected items (Read 6695 times)
toto22
YaBB Newbies
*
Offline



Posts: 6
Joined: Nov 19th, 2008
copy paste/move selected items
Nov 19th, 2008 at 1:07pm
Print Post  
Is it possible to paste nodes from clipboard at a specific location, the PasteFromClipboard method takes an offset position and not the exact location.

The other option I had was to paste nodes with 0 offset and use the move operation, this works fine when I have a single node copy/paste operation but incase of multiple selections I don’t see any method to move an entire selection. Is it possible to move all the selected items?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: copy paste/move selected items
Reply #1 - Nov 19th, 2008 at 1:38pm
Print Post  
It's a bit hackish, but you could do that by simulating users moving the selection to the specified position:

Code
Select All
private void MoveSelection(Point newPosition)
{
	Point oldPosition = diagram.Selection.Bounds.Location;
	InteractionState ist = new InteractionState(diagram.Selection, 8, Action.Modify);
	ist.Start(oldPosition, diagram);
	ist.Update(newPosition, diagram);
	ist.Complete(newPosition, diagram);
}
 



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



Posts: 6
Joined: Nov 19th, 2008
Re: copy paste/move selected items
Reply #2 - Nov 19th, 2008 at 5:19pm
Print Post  
thanks for the code.

what about the paste from clipboard, is it possible to paste nodes starting at a specific location?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: copy paste/move selected items
Reply #3 - Nov 19th, 2008 at 5:44pm
Print Post  
If you know the original position of the items, you could calculate the offset from it to the position where you want the copies to appear and call PasteFromClipboard with that offset. Otherwise, you will have to call that MoveSelection method after PasteFromClipboard.

Stoyan
  
Back to top
 
IP Logged
 
IgorS
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 13
Joined: Sep 22nd, 2008
Re: copy paste/move selected items
Reply #4 - Nov 25th, 2008 at 1:28pm
Print Post  
Hi, Stoyan.
This code does't seem to be working properly with links. Nodes are moved correctly, but links somehow get absolutely wrong bounds.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: copy paste/move selected items
Reply #5 - Nov 25th, 2008 at 3:09pm
Print Post  
Perhaps the links are auto-routed? What happens if you set AutoRoute = false for the selected links?

Stoyan
  
Back to top
 
IP Logged
 
IgorS
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 13
Joined: Sep 22nd, 2008
Re: copy paste/move selected items
Reply #6 - Nov 26th, 2008 at 8:36am
Print Post  
No, they aren't. I solved this by calling
link.ReassignAnchorPoints();
for each pasted link in Selection after moving it.

By the way. Can check if clipbord contains diagram items? I tried Clipboard.GetDataObject().GetData(typeof(Selection)) and Clipboard.GetDataObject().GetData(typeof(DiagramItemCollelection)) but both returned null..
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: copy paste/move selected items
Reply #7 - Nov 26th, 2008 at 9:27am
Print Post  
Use GetDataObject().GetDataPresent(typeof(MemoryStream)).

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


I love YaBB 1G - SP1!

Posts: 13
Joined: Sep 22nd, 2008
Re: copy paste/move selected items
Reply #8 - Nov 27th, 2008 at 3:18pm
Print Post  
Yep, it did Smiley Thanks a lot.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint