Copy paste

Hello, i’m probing the code&paste.

I need copy a node and paste, but when i do copy, need to change internal variables, so:

How could i detect the copy and the paste event?

Thanks

If it's a paste from the clipboard, you could implement a Diagram.ClipboardPasted event handler.

If it's a control-drag-and-drop within the diagram, implement a Diagram.SelectionCopied event handler. If it's a drag-and-drop from another diagram, implement a Diagram.ExternalObjectsDropped event handler.

Thanks for all.

Hello.

I have a question about this.

If i copy select several elements (ctrl+c) and paste, how could i get the colection?

        // Event
        private void exampleDiagram_ClipboardPasted(object sender, DiagramEventArgs e)
        {
            int a = 1;
        }
Sender is the diagram.

I don’t know how i could get the elements in the clipboard.

Diagram.SelectedParts

Thank you for the reply

I have:

 public class GraphModel : GraphLinksModel<GraphBaseElement, String, String, GraphBaseLink>
And i have overrited:
protected override GraphBaseElement CopyNode1(GraphBaseElement nodedata, GraphLinksModel<GraphBaseElement, string, string, GraphBaseLink>.CopyDictionary env)
It is possible detect here, if i drop a new element from palette or i paste a element?

I would like know if a node is pasted before add it on diagram.

Well, it depends on what you want to do, and when. Why do you want to know if a node is pasted before adding it to a diagram? Do you want to prevent it from being added? Do you want to modify it? Do you want to add other parts as well?

Without knowing what you really want to do, the most general answer is to implement Diagram.ClipboardPasted and Diagram.ExternalObjectsDropped event handlers to make the changes that you want to the Diagram.SelectedParts collection. That includes deleting some of those parts, or modifying the bound data, or adding other parts.