Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic begin link programmatically (Read 1811 times)
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
begin link programmatically
Sep 18th, 2008 at 1:27am
Print Post  
I need to be able to begin the link process in code and have the user finish the link definition by clicking on the second node. Specifically I am going to handle the dragdrop event on a node, use that node as the start node, create an arrow from that node and then have the user finish the process by  extending the arrow to another node and clicking on it.

Any suggestions on how to implement?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: begin link programmatically
Reply #1 - Sep 18th, 2008 at 6:52am
Print Post  
Code
Select All
private DiagramLink newLink = null;

private void diagramView_DragDrop(object sender, DragEventArgs e)
{
	PointF point = diagramView.ClientToDoc(
		diagramView.PointToClient(new Point(e.X, e.Y)));
	DiagramNode node = diagram.GetNodeAt(point);
	if (node != null)
	{
		e.Effect = DragDropEffects.Copy;

		newLink = diagram.Factory.CreateDiagramLink(node, point);
	}
}

private void diagramView_MouseMove(object sender, MouseEventArgs e)
{
	if (newLink != null)
	{
		diagram.Invalidate(newLink.GetRepaintRect(false));
		PointF point = diagramView.ClientToDoc(e.Location);

		PointCollection cp = newLink.ControlPoints;
		cp[cp.Count - 1] = point;
		newLink.UpdateFromPoints();
	}
}

private void diagramView_MouseUp(object sender, MouseEventArgs e)
{
	if (newLink != null)
	{
		PointF point = diagramView.ClientToDoc(e.Location);
		DiagramNode node = diagram.GetNodeAt(point);
		if (node != null)
			newLink.Destination = node;
		newLink.UpdateIntersections();
		newLink = null;
	}
}
 



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



Posts: 26
Joined: Aug 25th, 2008
Re: begin link programmatically
Reply #2 - Sep 18th, 2008 at 12:14pm
Print Post  
Perfect! Thanks for getting me on the right path!

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