Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Dragging an anchor! (Read 6880 times)
nikulin_andrey
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Dec 1st, 2006
Dragging an anchor!
Jan 26th, 2007 at 3:39pm
Print Post  
hi,

Is there any way to implement dragging of anchor around a box by mouse?

User will be able to change anchor location.

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging an anchor!
Reply #1 - Jan 26th, 2007 at 5:02pm
Print Post  
Hi,

There is no built-in support for that. I guess you could implement it using a custom Behavior class. First take a look at this topic:

http://mindfusion.org/cgi/Forum/YaBB.pl?board=fcnet_disc;action=display;num=1153...

It shows both how to override Behavior and detect whether the mouse is over an anchor point. You can modify that code so that StartDraw returns a new Box object representing the dragged point. When the user drops the box (BoxModified event), update the anchor point position and delete the box. This result from Behavior.StartDraw-

return new InteractionState(theAnchorBox, 8, Action.Modify);

will directly start moving the box along with the mouse pointer. You could allow this if the Shift flag in Control.ModifierKeys is set, otherwise let the user start drawing an arrow.

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


I love YaBB 1G - SP1!

Posts: 26
Joined: Dec 1st, 2006
Re: Dragging an anchor!
Reply #2 - Jan 29th, 2007 at 12:31pm
Print Post  
Ok Thanks. Seems to be working.

What is the proper way redraw arrow if i have changed an anchor location from the code?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging an anchor!
Reply #3 - Jan 29th, 2007 at 1:20pm
Print Post  
Set the new coordinates for

arrow.ControlPoints[0]

or

arrow.ControlPoints[arrow.ControlPoints.Count-1]

depending on which end of the arrow is affected, and call

arrow.UpdateFromPoints();
  
Back to top
 
IP Logged
 
nikulin_andrey
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Dec 1st, 2006
Re: Dragging an anchor!
Reply #4 - Jan 29th, 2007 at 1:22pm
Print Post  
Thanks
  
Back to top
 
IP Logged
 
nikulin_andrey
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Dec 1st, 2006
Re: Dragging an anchor!
Reply #5 - Jan 30th, 2007 at 8:16am
Print Post  
After I moved an anchor I am updating arrow from control points but there is a new problem.

If the arrow style is cascade when I change one of the ends the arrow style is still cascade but one of the arrow part is polyline.

How to handle this properly?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging an anchor!
Reply #6 - Jan 30th, 2007 at 8:42am
Print Post  
Try setting the CascadeOrientation to Horizontal or Vertical, depending on the first segment orientation.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging an anchor!
Reply #7 - Jan 30th, 2007 at 9:04am
Print Post  
Or just set the coordinates of the point next to the first or last one.
  
Back to top
 
IP Logged
 
nikulin_andrey
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Dec 1st, 2006
Re: Dragging an anchor!
Reply #8 - Jan 30th, 2007 at 9:41am
Print Post  
No. It doesnt solve the problem. The last part of arrow is still polyline.

Is there any way to resolve that?
  
Back to top
 
IP Logged
 
nikulin_andrey
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Dec 1st, 2006
Re: Dragging an anchor!
Reply #9 - Jan 30th, 2007 at 9:43am
Print Post  
When I am moving a box the arrow follow the box and style stay cascade.

How to do the same when I move the anchor point?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging an anchor!
Reply #10 - Jan 30th, 2007 at 11:54am
Print Post  
You might update the arrow's Origin or Destination so that it links to the anchor box. Setting these properties will probably reset the arrow coordinates. To work around this, save the point coordinates before changing the Origin/Destination, and restore them after that. Now while a user moves the anchor box, the arrow should follow the box. Upon BoxModified, update the Origin or Destination property again so that the arrow links to the original box.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging an anchor!
Reply #11 - Jan 30th, 2007 at 12:06pm
Print Post  
If you don't need the arrow to update itself while the box is moving, just handle BoxModified and update the two points that define the arrow's first or last segment.

The control won't update automatically the coordinates of ControlPoints[1] if you set ControlPoints[0].  The next-to-the-last point must have either the same X or the same Y coordinate as the last one, depending on the arrow's direction. So after setting ControlPoints[0], also set ControlPoints[1] to preserve the horizontal/vertical orientation of the segment.
  
Back to top
 
IP Logged
 
nikulin_andrey
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Dec 1st, 2006
Re: Dragging an anchor!
Reply #12 - Jan 30th, 2007 at 1:12pm
Print Post  
Great, it works.    Grin
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging an anchor!
Reply #13 - Jan 30th, 2007 at 2:28pm
Print Post  
8)
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint