1/ If you have replaced the GoTextNode.Background with a GoImage (instead of the normal GoRectangle), you shouldn’t have to override any copy method. The normal definition of CopyChildren should do the right thing.
2/ If you have a fixed number of properties, just add them as .NET properties on your class inheriting from GoTextNode. You’ll only need to override CopyObject if you want to avoid sharing references to property values in copies of the node.
If you have a variable number of properties, say in a Dictionary, you’ll need to override CopyObject to make sure you make a copy of the Dictionary with the right values in it. (This is just another case of avoiding unwanted shared references in a copied GoObject.)
All of your properties need to be serializable.
In OnKindChanged I replaced:
Images and ImageLists aren’t copied. This allows for images, which can be large, to be shared by multiple GoImages in memory.
However, the references to the images (file name or resource name or ImageList index) that are in GoImage are copied.
The problem is that you are directly assigning the GoImage.Image property. I suggest that you set the GoImage’s Index = 0 and that you set the shared property GoImage.DefaultImageList in your application constructor.
Here’s the relevant text from the FAQ (GoDiagramFAQ.chm):
· If an image is
not appearing when the object is pasted from the clipboard, but is visible when
created and when drag-drop-copied, then the cause is a lack of knowledge about
where to retrieve the Image. You need to set GoImage.ImageList or
GoImage.ResourceManager on the newly copied objects, because those image
sources are not serialized. More convenient, when you only have a single source
of images, is to set the static/shared property GoImage.DefaultImageList
Thanks Walter, that was exactly the information I needed.