Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Switching tree branches by dragging (Read 4985 times)
taciosd
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jan 4th, 2010
Switching tree branches by dragging
Jan 7th, 2013 at 4:34pm
Print Post  
Hi,
My chart is configured with tree style, and i want the user to be able to drag one branch of the tree and switch it with another one.
Does anyone know how to accomplish this in a smooth way?

Ps.: In the attached image, i want to switch the red branch with the green one.

Thanks.
  

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Switching tree branches by dragging
Reply #1 - Jan 7th, 2013 at 8:16pm
Print Post  
Hi,

The order of branches in TreeLayout depends on the order of links in boxes' OutgoingArrows collection. You can call box.OutgoingArrows.ChangeIndex() to move an arrow to a new position in the collection, and hence the whole branch after TreeLayout is applied again. E.g. handle the ObjectModified event, raised when a node has been moved, and change the position of the link connecting the moved node to its parent in the tree.

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


I love YaBB 1G - SP1!

Posts: 4
Joined: Jan 4th, 2010
Re: Switching tree branches by dragging
Reply #2 - Jan 10th, 2013 at 4:33pm
Print Post  
Thank you, I will try this.
But i'm working with C++, do you know how can i identify if the LPDISPATCH parameter in the ObjectModified event is a BoxItem or an ArrowItem (or something else)?

I already tried many type castings, but in none of them i can be sure if the type conversion succeded.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Switching tree branches by dragging
Reply #3 - Jan 10th, 2013 at 5:54pm
Print Post  
You could compare it with the flowchart's ActiveBox / ActiveArrow properties:

if (obj == m_FlowChart.GetActiveBox())
...

or otherwise #import "flowchartx32.dll" and call QueryInterface(IID_IBox) on the IDispatch pointer.

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


I love YaBB 1G - SP1!

Posts: 4
Joined: Jan 4th, 2010
Re: Switching tree branches by dragging
Reply #4 - Jan 10th, 2013 at 6:27pm
Print Post  
Thank you, it worked great!  Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Switching tree branches by dragging
Reply #5 - Feb 26th, 2013 at 3:32pm
Print Post  
That should now be easier with this version:
http://mindfusion.eu/Forum/YaBB.pl?num=1361892178

When the user moves a node, just reapply TreeLayout with PreserveOrder enabled.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint