Moving a unconnected link along with the node

Consider there is a node and a link which is not connected to any node on the other side. Now if we move the node the link re-routes keeping the open end of the node at the same location.

I want to have a feature like if I move any node which has a unconnected link the whole link should move along with the node without rerouting.

Any suggestions ?

You’ll note that if you select such Links, they will be moved along with the Node. So I think you just need to override DraggingTool.ComputeEffectiveCollection to include connected Links that are not connected to other Nodes.

Thanks for the suggestion. I tried using it but the location of the link and node are going in random location.
Could you provide some examples regarding the same ?

This is how it happens right now:
This is my node with unlinked connection
image

when I tried to select the node and drag the node and the links gets seperated:
image

How did you override DraggingTool.ComputeEffectiveCollection? Here’s an example override that includes a lot more than what you want, because it includes related Nodes:

    public override Dictionary<Part, DraggingTool.Info> ComputeEffectiveCollection(IEnumerable<Part> parts) {
      if (this.IsShiftKeyDown()) {
        return base.ComputeEffectiveCollection(parts);
      } else {
        var map = new Dictionary<Part, DraggingTool.Info>();
        if (parts == null) return map;
        foreach (var n in parts) {
          GatherConnecteds(map, n);
        }
        return map;
      }
    }

    private void GatherConnecteds(Dictionary<Part, DraggingTool.Info> map, Part part) {
      var node = part as Node;
      if (node == null) return;
      if (map.ContainsKey(node)) return;
      // record the original Node location, for relative positioning and for cancellation
      map[node] = new DraggingTool.Info() { Point = node.Location };
      // now recursively collect all connected Nodes and the Links to them
      foreach (var link in node.LinksConnected) {
        map[link] = new DraggingTool.Info();
        GatherConnecteds(map, link.GetOtherNode(node));
      }
    }

Well my implementation was

public override Dictionary<Part, Info> ComputeEffectiveCollection(IEnumerable parts)
{
var connectedLinks = (parts.ToList().First() as Node).LinksConnected;
var openConnections = connectedLinks.Where(l => l.FromNode == null || l.ToNode == null).First();
Dictionary<Part,Info> toBeSelectedParts = new Dictionary<Part, Info>();
toBeSelectedParts.Add(parts.ToList().First(), new Info());
toBeSelectedParts.Add(openConnections as Part, new Info());
return toBeSelectedParts;
}

Note that for the Nodes that you want to include in the effective collection, which should include all selected Nodes, that the corresponding Dragging.Info needs to have their original Location.

Yeah. Noted that. The following code worked for me:

public override Dictionary<Part, Info> ComputeEffectiveCollection(IEnumerable parts)
{
var map = new Dictionary<Part, Info>();

        if (parts.OfType<Link>().Any())
        {
            return base.ComputeEffectiveCollection(parts);
        }
        if (parts == null)
        {
            return map;
        }

        foreach (var part in parts.OfType<Node>())
        {
            Node node = part as Node;
            map[node] = new Info() { Point = node.Location };
            var connectedLinks = node.LinksConnected;
            if (connectedLinks.Any())
            {
                connectedLinks.Where(link => link.FromNode == null || link.ToNode == null).ToList().ForEach(openLink => map[openLink] = new Info());
            }
        }
        return map;
    }