Issue with cut and paste of group of elements into new tab

Scenario 1:
If we do select all using Ctrl+A and do cut/paste,functionality works fine.
com-video-to-gif

Scenario 2:
If we select the model using dragging tool and do cut/paste, One connection is not selected.

If we do not override ComputeEffectiveCollection(),cut/paste works fine with dragging tool selection as well.
This method implementation was provided by Walter to achieve dragging tool selection and paste in the location where the mouse is pointed.

com-video-to-gif%20(1)

Could you please suggest how can we resolve the moved connection issue?

Are you saying that the problem only occurs when you have overridden the ComputeEffectiveCollection method? Have you debugged that method to see what is included in the dictionary for that particular Link?

Yes. I have debugged, I see that the link is not added as part of node.LinksConnected.

No, I meant in the Dictionary that is returned by your override of ComputeEffectiveCollection. Both the presence of the Link to be copied as well as the its DraggingTool.Info values.

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

            if (parts == null)
            {
                return map;
            }

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

Above is the code implemented.

Refer the below screenshots:
1

2 is the connection which is not getting selected or pasted.

LinksConnected is zero for the nodes ID3 and ID2.

That Link is not supposed to be selected, but it is supposed to be copied, and I thought your video shows that it is copied and selected but that it is copied at the wrong location. Or did I misunderstand your video?

Is your debugging showing that that Link is not connected to either the ID3 or the ID2 node in the original Diagram? If so, that would explain why it isn’t being copied, because your override of ComputeEffectiveCollection is ignoring selected Links that are not connected with selected Nodes. Why aren’t selected Links being included in the resulting Dictionary?

Can you please elaborate?
The link should be both selected and copied.Yes,debugging is showing that the link not connected to either the ID3 or the ID2
node in the original diagram.Why that link is not connected?
Link is not included in original diagram.SelectedParts itself.

I was pointing out the bug in your code:

…that would explain why it isn’t being copied, because your override of ComputeEffectiveCollection is ignoring selected Links that are not connected with selected Nodes. Why aren’t selected Links being included in the resulting Dictionary?

We have observed a scenario, the above mentioned issue occurs only when we set the same Key to the Node (as it was before cutting). If a new Key is set during the paste operation the issue is not occurring.

Could you please suggest how we can come over it ?

Could you please explain what you are doing with keys?

We are assingning set of ID’s for nodes(ID1,ID2…). When we do cut and paste,we are clearing the IDs and trying to reuse the same set IDs(need not be in the same order).When we are trying to resuse the same set of IDs,we are getting the issue.
Cant we resuse the IDs?

Modifying node keys can cause confusion!

Could you modify some other property instead?
Or, could you modify keys at a separate time, so that any other ongoing operation is not impacted?