Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drag Beyond Bounds (Read 2328 times)
dolfandon
Junior Member
**
Offline



Posts: 51
Location: Northern Virginia
Joined: Mar 12th, 2009
Drag Beyond Bounds
Aug 11th, 2011 at 6:59pm
Print Post  
We noticed in our app that you can now drag the nodes beyond the bounds at the top and left of the diagram. This didn't happen before in earlier versions. I'm not sure if this is an interaction with a Silverlight update or the latest version of the 3.5 diagram control. Is this a way to turn that off or limit it?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Beyond Bounds
Reply #1 - Aug 12th, 2011 at 6:43am
Print Post  
I can't think of the reason for this to happen, but you can easily prevent it by handling the Diagram.NodeModifying event and using the following code in the event handler:

Code
Select All
if (e.Node.Bounds.X < diagram.Bounds.Left ||
      e.Node.Bounds.Y < diagram.Bounds.Top)
{
      e.Cancel = true;
} 


I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
dolfandon
Junior Member
**
Offline



Posts: 51
Location: Northern Virginia
Joined: Mar 12th, 2009
Re: Drag Beyond Bounds
Reply #2 - Aug 12th, 2011 at 3:40pm
Print Post  
Thanks, that seems to work fine although I modified it a little so that it doesn't actually drag the node outside the bounds. Any hints how I would do this for a link anchor point. I looked at link modifying but can't find anything that gives me the position of the anchor point as it is being dragged. By the way. This happens in all the demos on the site.

Code
Select All
            if (e.Node.Bounds.X < currentDiagram.Bounds.Left || e.Node.Bounds.Y < currentDiagram.Bounds.Top)
            {
                if (e.Node.Bounds.X < currentDiagram.Bounds.Left)
                {
                    e.Node.Bounds = new Rect( currentDiagram.Bounds.Left, e.Node.Bounds.Y, e.Node.Bounds.Width, e.Node.Bounds.Height);
                }
                if (e.Node.Bounds.Y < currentDiagram.Bounds.Top)
                {
                    e.Node.Bounds = new Rect(e.Node.Bounds.X, currentDiagram.Bounds.Top, e.Node.Bounds.Width, e.Node.Bounds.Height);
                }
                e.Cancel = true;
            } 

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Drag Beyond Bounds
Reply #3 - Aug 13th, 2011 at 10:16am
Print Post  
Handle the LinkModifying event. You can access the coordinates of the point being dragged through the folowing line:

Code
Select All
Point point = e.Link.ControlPoints[e.AdjustmentHandle]; 


Make sure to invoke Link.UpdateFromPoints after manually modifying the points of the link.

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