Paste on mouseposition

Hi,
I got an issue from our service.
They want to multiselect some nodes and paste them on the actual mouse position.
I havn’t found this option in the code or the documentation.

Then I tried to override the paste command in a customcommandhandler, but I discovered that sequence of the selection isn’t predictable. So I found it difficult to calculate the new positions.

Do you have a solution for that?

I found something!

    protected override IDataCollection PasteFromClipboard()
    {
        var dataCollection = base.PasteFromClipboard();

        var allElementsInCollection = dataCollection.Nodes.Cast<Element>().ToList();

        var minX = allElementsInCollection.Min(e => e.X);
        var minY = allElementsInCollection.Min(e => e.Y);

        var diff = new Point(minX, minY) - Diagram.LastMousePointInModel;

        foreach (var element in allElementsInCollection)
        {
            element.X = (int) (element.X - diff.X);
            element.Y = (int) (element.Y - diff.Y);
        }

        return dataCollection;
    }

This is working. Now I only must detect the difference if the paste was invoked from contextmenu or from pressing ctrl-v.

Well, that was easy and quick for me. I’m glad you figured it out.