Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Creating Links From ControlPoints (Read 2400 times)
BudMan
YaBB Newbies
*
Offline


Credidi me felem vidisse

Posts: 45
Joined: Jul 14th, 2007
Creating Links From ControlPoints
Apr 5th, 2010 at 10:53pm
Print Post  
Is it possible to construct a link using just control points and the Links.Add method? I have tried to do this with code like the following:


       Dim pt1, pt2 As PointF
       Dim lnk As New DiagramLink(dgm)

       pt1 = New PointF(40, 40)
       lnk.ControlPoints.Add(pt1)

       pt2 = New PointF(60, 60)
       lnk.ControlPoints.Add(pt2)

       lnk.Pen = New MindFusion.Drawing.Pen(Color.Red, 1)
       dgm.Links.Add(lnk)

This does not work. Yet I know the Add() method works for nodes. Is the same not possible for links? Or do I have to use the Factory.CreateDiagramLink() method?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Creating Links From ControlPoints
Reply #1 - Apr 6th, 2010 at 6:08am
Print Post  
You can use the Factory methods that take PointF arguments. If you need to add a custom link instance:

Code
Select All
Dim lnk As New DiagramLink(diag)
lnk.Origin = Nothing' create a DummyConnectionPoint
lnk.Destination = Nothing' create a DummyConnectionPoint

lnk.ControlPoints.Clear()
lnk.ControlPoints.Add(New PointF(40, 40))
lnk.ControlPoints.Add(New PointF(60, 60))
lnk.UpdateFromPoints(False, True)

lnk.Pen = New MindFusion.Drawing.Pen(Color.Red, 1)
diag.Links.Add(lnk) 



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


Credidi me felem vidisse

Posts: 45
Joined: Jul 14th, 2007
Re: Creating Links From ControlPoints
Reply #2 - Apr 12th, 2010 at 3:42pm
Print Post  
Thanks, Stoyo, that worked great. The user can now manually re-route links to suit and save the new controlpoints in a database.

The only problem is the ArrowHead often points in the wrong direction when the diagram is re-opened. For example, say FlowChart initially draws a link with the last segment pointing to the left. The user then changes the link so the last segment points down and saves to a database. Often when the diagram is re-loaded, the new route is shown correctly but the ArrowHead itself still points to the left(or right), not down. That is, the way it was when it originally drew the link.

I know I could avold this by using the Circle as the LinkHeadShape, but hope you can tell how to correctly render the arrow.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Creating Links From ControlPoints
Reply #3 - Apr 12th, 2010 at 3:45pm
Print Post  
Do you call UpdateFromPoints after restoring points from the database?
  
Back to top
 
IP Logged
 
BudMan
YaBB Newbies
*
Offline


Credidi me felem vidisse

Posts: 45
Joined: Jul 14th, 2007
Re: Creating Links From ControlPoints
Reply #4 - Apr 12th, 2010 at 4:35pm
Print Post  
Perfect! Thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint