Preventing Paste of a special node

Hi,
I have few special nodes which could be used only once in a given document. During paste operation, if these nodes exists in the document, paste should exclude these nodes. All other nodes/objects should be pasted which were part of same paste operation.
For example if, A and B are special nodes and paste operation contains A,B,C,D nodes and links connecting them. if document already have B node, paste should paste only A,C,D nodes and links connecting them(links to and from B should be removed from paste selection as B is not pasted).
I tried to override CopyObject of GoNode, but could not differentiate between copy and paste operation. copy/paste both calls CopyObject (function need to return null if it’s called from paste and node exists in the document, otherwise it need to copy the node).
Otherway I was thinking was to override PasteFromClipboard on GoView and remove the GoObject from the GoCopyDictionary if it does not meet the criteria. I have not tried this yet.
Could you please suggest appropriate way to achieve this.

You should define a custom GoCopyDictionary. You’ll want to override the GoCopyDictionary.Copy method to do the following:

  • if the argument is null, return null
  • if the argument is a link to an A or a B, return null
  • if the argument is an A or a B already in the destination document, return them
  • otherwise call the base method for the standard behavior

Install the custom copy-dictionary by overriding GoDocument.CreateCopyDictionary to create an instance of your class, set its GoCopyDictionary.DestinationDocument property to “this” document, and return it.

You can look at the GoCopyDictionary.SourceCollection and .DestinationDocument properties to discriminate between the different kinds of copies. This mechanism is used in all copying situations, not just GoView.PasteFromClipboard, and you’ll want to make sure it works the way you want in all of those situations.

There’s also this note, which has a little more detail on the same subject…

http://www.nwoods.com/forum/forum_posts.asp?TID=2348