Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic dragging around & cursor feedback calculation (Read 2417 times)
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
dragging around & cursor feedback calculation
Feb 26th, 2013 at 1:45pm
Print Post  
OK, a user drags our somewhat sizeable nodes around, and he will drop them so that they overlap - which we cannot allow.

So i feed back the cursor based on:

OverrideCursor =
(CanPlaceNode(MousePosition.X, MousePosition.Y, Selection.Nodes.Count)) ? Cursors.Hand : Cursors.No;

..which checks if geometry of the to-be-dropped node or nodes (selection) will overlap with some existing stuff, and shows a NO cursor when he drags.
This is placed in SelectionMoving handler.

===

Now, i noticed that the MousePosition (which we update from mouse moving handler) has an OFFSET to the nodes the user can drag around in diagram, i.e. he can fetch a node low or up, completely left or right and drag it so.

Is there a way to determine deltaX, deltaY difference between node's Upper Left corner & mouse drag point? That would help the CanPlaceNode method to better determine the potential overlap....

Maybe i have to store this deltas on the mouse down on a node (which is the onset of drag)?
Or is there some already better thought up solution?

cheers
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: dragging around & cursor feedback calculation
Reply #1 - Feb 26th, 2013 at 8:00pm
Print Post  
Why not just check Selection.Bounds and Node.Bounds? They should indicate the current position of items in most situations.
  
Back to top
 
IP Logged
 
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Re: dragging around & cursor feedback calculation
Reply #2 - Feb 27th, 2013 at 9:52am
Print Post  
so selection.bounds are updated along with the drag, too?

could not use it for drag of multiple nodes, as i arrange them to drop next to each other programatically. But its ok, i solved it per:

_dragGrabPnt = new Point(e.GetPosition(DocumentPlane).X - MouseNode.Bounds.X, e.GetPosition(DocumentPlane).Y - MouseNode.Bounds.Y);

in MousePressed aka drag begin; that way, i know the offset when a node is dragged around.

(pls close the thread Tongue)

cheers
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: dragging around & cursor feedback calculation
Reply #3 - Feb 27th, 2013 at 11:54am
Print Post  
Quote:
so selection.bounds are updated along with the drag, too?


Yes, this seems to show correct values:

Code
Select All
private void OnSelectionMoving(object sender, ValidationEventArgs e)
{
	Debug.WriteLine(diagram.Selection.Bounds);
} 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint