Custom location of a connection on a node

Hi,

Let’s say I have :
A -> B
B has ToSpot=“TopSide”.

This works fine, I’m able to connect the “A” node to the top of the “B” node.
However, I want to be able to connect the link everywhere on the top of the “B” node. Right now, I’m only able to connect the link to the top-center of the “B” node and when I mouse up, the link’s connection to the “B” node is confirmed and the connection is relocated somewhere else on the topside of the “B” node.

Is it possible to choose the location of a connection only on the top side of a node ?


Thanks for your help !

Do you mean to have the user specify the position along the top side of the node? Yes, this is possible, by computing the Link.Route.ToSpot to be the Spot that is at the closest point to where the mouse-up happened. (Presumably you would use a fractional Spot.X value so that if the Node were resized all of the link points would still make sense.) You could do this in a Diagram.LinkDrawn event, using this.Diagram.LastMousePointInModel along with the Link.ToNode.Bounds, given the DiagramEventArgs.Part that is the newly drawn Link.

The Sequential Function sample demonstrates a related behavior, and one that you might also want: where the user shifts the link point interactively rather than when drawing a new Link. See the DoReshape method in that sample.

Hi
Yes, the Sequential Function sample is exactly what I want to do.
So I get the code (LinkShiftingTool class) and modify it to fit in our system.
However, I want to be able to enlarge the distance between the node and the new adornment (the orange one which is build in the UpdateAdornement method).
I succeed.
However, the real point in the routing is not at the same location of the adornment.

I change that code (in the LinkingShiftingTool.UpdateAdornment):

      if (adornment != null) {
        Point loc = link.GetElementPoint(selelt, Spot.TopLeft);
        adornment.Location = loc;
        adornment.RotationAngle = link.GetAngle(selelt);
        adornment.Remeasure();
      }

by that one :

		if (adornment != null)
                    {
                        Point loc = link.GetElementPoint(path, Spot.TopLeft);
                        Point locAtNode = link.GetElementPoint(path, Spot.MiddleLeft);
                        var point = link.Route.Points.First(pts => pts.X == loc.X && pts.Y == loc.Y);
 
                        if (loc.X - locAtNode.X != 0)
                        {
                            loc.X -= 10;
                            point.X -= 10;
                        }
 
                        if (loc.Y - locAtNode.Y != 0)
                        {
                            loc.Y -= 10;
                            point.Y -= 10;
                        }
 
                        adornment.Location = loc;
                        adornment.RotationAngle = link.GetAngle(path);
                        adornment.Remeasure();
                    }

Do you have an idea of what I have to do to have the new Adornment and the new Point at the same location when I change the adornment location ?

Thanks a lot !

I do not understand what it is that you are trying to do.

If you want the shift handle to be a bit farther away from the node, you can increase the fraction that you specify in the two calls to LinkPanel.SetFraction, which the code is currently assuming should be at 0.5.

Yes, it’s exactly what I’m trying to do.
I already spot the LinkPanel.SetFraction and I set it the max value (0.99), but the toolhandle is not enough away from the node (because it hides the arrow head).

That’s why I was trying to do it manually with the code I pasted above in my previous post.

Maybe it will be more clear with a picture (sorry for the quality of my pictures)…

With the LinkPanel.SetFraction(0.99), I got that :

Like i said, the toolhandle is not enough away from the node (because it hides the arrow head).


So I wrote the code above. It does the right comportment, it moves up the toolhandle.



But when I change the location of the toolhandle in my application, it moves the toolhandle and the point of the route. However, it shows that the point of the route has not the same location of the toolhandle :

Is there a way to correct it, or simply, another way to do it ?

Thanks again for your help.

Increase the ToEndSegmentLength and FromEndSegmentLength, as well as LinkPanel.SetFraction value.