I implemented the rotation behaviour on nodes based on Piping example (GoWpf Demo). My links can move along the side(left,top,right,bottom). If i move a link, it changes his position to 45 degrees when I tried to rotate my node, even if I didn’t complete the rotation and the node didn’t rotate (see picture below).
I made a sample based on our code in sequantialFunction (here).We modified the DoReshape method.
private void DoReshape(Point newPoint)
{
Link link = AdornedLink;
var id = LinkPanel.GetIndex(this.Handle);
Rect portb = (id == 0) ? link.FromNode.GetElementBounds(link.FromPort) : link.ToNode.GetElementBounds(link.ToPort);
if (portb.Width < 1 || portb.Height < 1)
{
return;
}
var ctr = Spot.Center.PointInRect(portb);
var x = (newPoint.X - portb.Left) / portb.Width;
var y = (newPoint.Y - portb.Top) / portb.Height;
x = Math.Max(0, Math.Min(x, 1));
y = Math.Max(0, Math.Min(y, 1));[details=Summary][details=Summary]This text will be hidden[/details][/details]
switch (GetReshapeBehavior(Handle))
{
case ReshapeBehavior.Horizontal:
y = newPoint.Y < ctr.Y ? 0 : 1;
break;
case ReshapeBehavior.Vertical:
x = newPoint.X < ctr.X ? 0 : 1;
break;
}
var route = link.Route;
if (id == 0)
{
route.FromSpot = new Spot(x, y);
}
else
{
route.ToSpot = new Spot(x, y);
}
}
I’m sorry but I don’t have the time to investigate this thoroughly. Perhaps you need to remove these properties on the Link.Route:
FromEndSegmentDirection=“RotatedNodeOrthogonal”
ToEndSegmentDirection=“RotatedNodeOrthogonal”
First, I’d like to point out that your node template refers to the “Icon” element, but no such element has that x:Name. If you set x:Name=“Icon” on the NodePanel, resizing will work better. But that’s not the topic.
I think what’s happening is that the normally computed link end points do not match up with those that you compute in your overridden DoReshape method. So as soon as the user starts shifting the end of the link, it goes to the point that DoReshape specifies.
Part of the issue is that the LinkShiftingTool wasn’t designed to work with rotated nodes. That isn’t something that the Sequential Function sample anticipated.