Bezier Connection


I’ve added a link to my View connecting two ports and I wan’t the link to be a bezier link and editable.
I configure the link by the following code my view class.

protected override void OnLinkCreated(GoSelectionEventArgs evt)
GoLink link = evt.GoObject as GoLink;
if (link != null)
link.ToArrowStyle = GoStrokeArrowheadStyle.Polygon;
link.ToArrowLength = 10;
link.ToArrowWidth = 10;
link.ToArrowShaftLength = 8;
link.ToArrow = true;
link.Style = GoStrokeStyle.Bezier;
link.Selectable = true;
link.Reshapable = true;
link.Deletable = true;
link.AutoRescales = false;

This makes the link a bezier link. Wha is missing are the “handle points” that allow the user to stretch the link. How can i add these handlepoints or is there any way of adding the automatically. Maybe someone can post some lines of code that demonstrate how to configure a bezier link correctly.


The easiest thing to do is to change the properties of the prototype link that is copied each time the user draws a new link:
goView1.NewGoLink.Style = GoStrokeStyle.Bezier;
goView1.NewGoLink.ToArrow… = …
The Selectable/Resizable/Reshapable/Deletable properties all default to true. I’m not sure why you are setting AutoRescales to false, since most applications would want it to be true, but perhaps you have a good reason.
If the GoView.NewLinkPrototype were a GoLabeledLink instead of the default GoLink, you would need to say something like:
goView1.NewGoLabeledLink.Style = …

I’ve overloaded the NewLinkPrototype and added the following code.

public override GoObject NewLinkPrototype
GoLink retVal = base.NewLinkPrototype as GoLink;

              if (retVal != null)
                  retVal.Style = GoStrokeStyle.Bezier;
                  retVal.ToArrowStyle = GoStrokeArrowheadStyle.Polygon;
                  retVal.ToArrowLength = 10;
                  retVal.ToArrowWidth = 10;
                  retVal.ToArrowShaftLength = 8;
                  retVal.ToArrow = true;
              return retVal;
              base.NewLinkPrototype = value;

This makes the link a Bezier Link, but there are still no handle points to “reshape” the Link. Maybe there is still something missing.

By overriding that property, it means that you will be assigning those GoLink properties every time any code gets the value of GoView.NewLinkPrototype. That’s an unusual way of doing that initialization.
Normally one sets those GoView.NewGoLink properties when one initializes the GoView. You might modify some of those properties in some command (e.g. “from now on all newly drawn links will be blue”).
You haven’t said anything about the ports to which these links are connected. If their GoPort.FromSpot and .ToSpot properties are not set to GoObject.NoSpot, then that’s right – they won’t have resize handles at the control points of the Bezier stroke. That’s intentional.
I suppose it depends on the kinds of nodes you are linking, but perhaps you should set GoPort.FromSpot and GoPort.ToSpot to be GoObject.NoSpot on all those ports.

Hi Walter,

first of all thanks for your support. I’ve changed the FromSpot and ToSpot property of my ports to NoSpot and now the resize handles are displayed and I can move them to change the connection. But when I’m moving the port (the shape that contains the port), the connection is reshaped automatically. I’ve allready tried several settings in the view and link, but nothing worked.
Maybe you know what settings are wrong.

Try setting GoLink.AdjustingStyle to a value other than the default value: GoLinkAdjustingStyle.Calculate.