Scenario 1:
If we do select all using Ctrl+A and do cut/paste,functionality works fine.
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.
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?
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:
is the connection which is not getting selected or pasted.
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.
…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 ?
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?