Rotate link issue if the link is movable

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).

Thanks,

I cannot reproduce the problem in the Piping sample, using its Link and a Valve node. Could you tell me how to reproduce the problem?

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);
        }
    }

xaml code:
<DataTemplate x:Key=“Step”> <go:SpotPanel go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}" go:Node.LocationSpot=“Center” go:Part.SelectionAdorned=“True” go:Part.SelectionAdornmentTemplate="{StaticResource NodeSelectionAdornmentTemplate}" go:Part.Resizable=“True” go:Part.ResizeElementName=“Icon” go:Part.ResizeAdornmentTemplate="{StaticResource NodeResizeAdornmentTemplate}" go:Node.RotationAngle="{Binding Path=Data.Angle, Mode=TwoWay}" go:Part.Rotatable=“True” go:Part.RotateAdornmentTemplate="{StaticResource NodeRotateAdornmentTemplate}"> <go:NodePanel Sizing=“Fixed” Height=“60” Width=“160” > <go:NodeShape go:NodePanel.Figure=“Rectangle” Stroke=“Black” StrokeThickness=“1” Fill=“Pink” go:Node.PortId="" go:Node.FromSpot=“MiddleBottom” go:Node.ToSpot=“MiddleTop” /> <TextBlock HorizontalAlignment=“Center” VerticalAlignment=“Center” Text="{Binding Path=Data.Text, Mode=TwoWay}" TextWrapping=“Wrap” go:Part.TextEditable=“True” /> </go:NodePanel> </go:SpotPanel> </DataTemplate>

In this sample, the issue appears when:

  1. Shift the link (from bar to step 3).
  2. Rotate the node (step3)
  3. Click on shifting point (on link from bar to step 3)
    Automatically the link will rotate.

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”

I already tried to remove FromEndSegmentDirection, ToEndSegmentDirection or used others opitions avalaible but the issue is still there.

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.