Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to move a disconnected link with a node? (Read 3190 times)
Homam
Junior Member
**
Offline


I Love MindFusion!

Posts: 67
Joined: Feb 7th, 2012
How to move a disconnected link with a node?
Feb 7th, 2012 at 11:58am
Print Post  
Hi,

I have a link related with a node from the origin only and it's disconnected from the destination.

The problem is that the link doesn't move with its related node while it's moving. I noticed that the diagram creates a dummy node for the destination of a the disconnected link, so, I tried to move it using Move method. but the link still doesn't move.
Any help!

Thanks in advance
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to move a disconnected link with a node?
Reply #1 - Feb 7th, 2012 at 1:26pm
Print Post  
Hi,

You could implement that with some event handling:

Code
Select All
private Dictionary<DiagramLink, PointCollection> originalPoints;
private RectangleF startPos;

private void diagram_NodeStartModifying(object sender, NodeValidationEventArgs e)
{
	startPos = e.Node.Bounds;

	originalPoints = new Dictionary<DiagramLink, PointCollection>();
	foreach (DiagramLink link in e.Node.GetAllLinks())
		originalPoints[link] = link.ControlPoints.Clone();
}

private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
	float dx = e.Node.Bounds.X - startPos.X;
	float dy = e.Node.Bounds.Y - startPos.Y;

	foreach (DiagramLink link in e.Node.OutgoingLinks)
	{
		if (link.Destination is DummyNode)
		{
			PointCollection points = originalPoints[link];
			for (int i = 1; i < points.Count; i++)
			{
				PointF p = points[i];
				p.X += dx;
				p.Y += dy;
				link.ControlPoints[i] = p;
			}
			link.UpdateFromPoints();
		}
	}
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Homam
Junior Member
**
Offline


I Love MindFusion!

Posts: 67
Joined: Feb 7th, 2012
Re: How to move a disconnected link with a node?
Reply #2 - Feb 11th, 2012 at 9:12am
Print Post  
Thanks it works well.
  
Back to top
 
IP Logged
 
Homam
Junior Member
**
Offline


I Love MindFusion!

Posts: 67
Joined: Feb 7th, 2012
Re: How to move a disconnected link with a node?
Reply #3 - Feb 19th, 2012 at 11:10am
Print Post  
There is a problem, it's shown in the attached sample.

Please try the following:

1. Add a shape to the diagram
2. Before linking the free arrow, try to move the shape
3. Try to link the arrow to another shape..

The arrow will not move. I think there is a problem in the segment count, or something related to it.

Thank in advance,

Homam/
  

WorkflowDesigner2_001.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to move a disconnected link with a node?
Reply #4 - Feb 21st, 2012 at 8:00am
Print Post  
It seems this happens because the last two points coincide after auto-routing the unconnected link. The hit-testing code tries to move the next-to-last point but it can't be moved for two-segment cascading link. You could disable auto-routing until the link is connected: add link.AutoRoute = false at the end of AddProcessLink, and your LinkModified handler already has code to enable AutoRoute when connected.

You might also change the handles' hit-test priority by handling the HitTestAdjustmentHandles event, and first check the end points before looping over the intermediate control points. We'll change the standard hit-test code to work like that for the next release.

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