Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drag Drop Shapes (Read 4967 times)
SL_developer
YaBB Newbies
*
Offline


coding rocks

Posts: 43
Joined: Jul 26th, 2011
Drag Drop Shapes
Jul 27th, 2011 at 10:02am
Print Post  
Hi,

How To Drag & Drop shapes from one Diagram to another?
I refered sample drag n drop but its very difficult to understand.
please tell me some another sample in which we can drag n drop shapes.

Thanks
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Drop Shapes
Reply #1 - Jul 27th, 2011 at 10:48am
Print Post  
Hi,

The Drag & Drop sample is not really that complex. Here is some brief description on how it works:

The Page Structure
The sample contains two diagrams - the left one (named diagram) is the drag & drop source and the right one (named ddtarget) is the drag & drop target. On top of the two diagrams there is an invisible Canvas (named ddplane), which holds a Rectangle (named test). This rectangle is only displayed during dragging and is used to visually represent the dragged node.

The Drag&Drop Logic
1. The left diagram handles the MouseLeftButtonDown event. When this event occurs, the sample checks if the mouse is positioned over the blue rectangle in the top left corner of a node. If this condition is satisfied, the rectangle test is made visible and the sample enters dragging mode.

2. The left diagram also handles the MouseMove event, which is only used during dragging to update the position of the test rectangle in order to give the impression that the node is being dragged.

3. Finally, the left diagram handles the MouseLeftButtonUp event. When this event occurs during dragging and the mouse is positioned over the right diagram ddtarget, a new node is created in this diagram at the mouse position, which is effectively the drop action.

I hope this clarifies things a little.

Regards,
Meppy
  
Back to top
 
IP Logged
 
SL_developer
YaBB Newbies
*
Offline


coding rocks

Posts: 43
Joined: Jul 26th, 2011
Re: Drag Drop Shapes
Reply #2 - Jul 27th, 2011 at 12:38pm
Print Post  
Hi
Thanks for reply here,
now i understand how it works but the thing is that in drag n drop example there is a pre-defined default shape & i want all shapes at left hand side to drag at right side.
Once it drag, same shape should get draw at right diagram.
How can be this possible?


Thanks again
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Drop Shapes
Reply #3 - Jul 27th, 2011 at 12:59pm
Print Post  
Check this sample:

https://mindfusion.eu/_samples/_sample_DragDrop3.zip

It implements dragging of any shape.

Regards,
Meppy
  
Back to top
 
IP Logged
 
SL_developer
YaBB Newbies
*
Offline


coding rocks

Posts: 43
Joined: Jul 26th, 2011
Re: Drag Drop Shapes
Reply #4 - Jul 27th, 2011 at 1:07pm
Print Post  
Hi
this example looks good  Smiley  but why there is only droping of shapes once , if user want the same shape again what he will do?  ??? from where he will get the same shape at right side?

Please tell me what changes i will need in this example to achieve this?


Thanks
  
Back to top
 
IP Logged
 
SL_developer
YaBB Newbies
*
Offline


coding rocks

Posts: 43
Joined: Jul 26th, 2011
Re: Drag Drop Shapes
Reply #5 - Jul 27th, 2011 at 1:28pm
Print Post  
hey i found solution,how to do that,
i commented

//if (hits.Contains(test))
// hits.Remove(test);

line of code where you are removing.

Thanks for your kind support. Smiley Smiley Smiley
  
Back to top
 
IP Logged
 
SL_developer
YaBB Newbies
*
Offline


coding rocks

Posts: 43
Joined: Jul 26th, 2011
Re: Drag Drop Shapes
Reply #6 - Jul 28th, 2011 at 5:29am
Print Post  
Hi,
In above sample, how can i display only 2 or 3 shapes per line in left side diagram?

Thanks
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Drop Shapes
Reply #7 - Jul 28th, 2011 at 6:29am
Print Post  
In the MainPage constructor replace:

Code
Select All
if (x > 300)... 


with:

Code
Select All
int shapesPerRow = 3;
if (x > (shapesPerRow - 1) * (size + 5))... 


Regards,
Meppy
  
Back to top
 
IP Logged
 
SL_developer
YaBB Newbies
*
Offline


coding rocks

Posts: 43
Joined: Jul 26th, 2011
Re: Drag Drop Shapes
Reply #8 - Jul 28th, 2011 at 6:48am
Print Post  
Thank you  Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint