Drag like feature in Copy paste


Consider there are 2 connected nodes with a link. I select all and drag by holding Ctrl key. Now the copy of selected nodes and links will be visible. At this point, the new set of nodes and links will not have adornments and will get the adornments only after I leave the mouse.

For copy paste in our application is like when I paste the nodes and links will be moving along with the mouse location. In this scenario my new nodes which move along with my mouse have got adornments already.

What I want to achieve is when I select the nodes and links and do Ctrl+C and Ctrl V the pasted nodes that actually stick to my mouse but they should not be selected but rather when I click they should get the adornments until this the copied nodes should be selected and should have adornments. How can I do that ?

OK, I assume this is related to Moving the copy frame with mouse location. Thanks for finally starting a new topic.

I’m confused what the current behavior is for you, and what you want different. The pasted Parts definitely should be selected. Do you want Adornments to be shown during the drag?

Sorry for dragging the previous topic. The random offset was really annoying. But anyways, now the requirement is that copied node should be selected until the mouse click is made.

I want to have the selection exactly how Ctrl Drag works for copy paste.

Your statements are still very ambiguous. Those Parts will definitely be selected. The question is whether or not you want their Adornments to be visible.

Unfortunately the easy way to control that is not public – there’s an internal property Part.WithoutAdornments that you could set to true on each of those Parts, which would prevent such Parts from getting Adornments in Part.UpdateAdornments.

But you could remove any Adornments the same way that another internal bit of code does on the Part class:

    // remove all adornments from this part
    internal void ClearAdornments() {
        foreach (String n in this.Adornments.Keys.ToList()) {
          SetAdornment(n, null);  // remove Adornment from Layer and remove dictionary entry

Sorry for the confusion. I didn’t distinguish between selected nodes and the adornments.

I have 2 nodes connected. I select them and I drag holding the ctrl key. When I move the mouse and click the nodes are pasted. Here the adornments are over the pasted nodes once they are placed in some part of diagram. Until then the adornments were over the source nodes( to be copied nodes). This is the expected behavior.com-video-to-gif%20(6)

Now consider when I am doing the copy paste for the same initial nodes and I do Ctrl+C and Ctrl+V. The new nodes get adornments. What I want to achieve is, until I place the new nodes on diagram the source nodes should be selected and once I place by mouse click, the new nodes should get the adornments.

OK, when the Parts are copied you will need to remove any Adornments on each selected Part, as my suggested ClearAdornments does.

Then at the end, you will need to call Part.UpdateAdornments on each selected Part.

Hmmm, that probably won’t work, due to the continual calls to UpdateAdornments because you are moving the parts. So maybe you can set Part.WithoutAdornments via reflection? I don’t know if the property name has been minified.