GoDigram for .NET Framework and .NET Core
Northwoods.Go Namespace / GoImage Class
Members
In This Topic
    GoImage Class
    In This Topic
    An object that displays a image such as a bitmap or JPEG file.
    Syntax
    [Serializable()]
    public class GoImage : GoObject 
    Remarks

    This GoObject is responsible for painting an Image. The ResourceManager, Name, ImageList, and Index properties are used by LoadImage in order to procure the actual Image that is painted. If you change any of these properties, LoadImage will be called again to find a new image.

    When you set any of those properties, if AutoResizes is true (which is the default value), LoadImage will be called immediately to determine whether the new Image has a new Size, in order to resize this GoImage object to the Image's natural size. However, when AutoResizes is false, LoadImage will only get called when the Image property is needed by a call to Paint. Hence if you have a large diagram with many different Images to be shown, it is advantageous to have GoDiagram only load images on demand due to painting. You can achieve this effect by setting AutoResizes to false and by setting the GoObject.Size explicitly to the size that you want, before setting the Name or Index properties.

    If Index is non-negative, this tries to display the corresponding Image in the ImageList. If ImageList is null, this uses the value of DefaultImageList instead.

    If Name is non-null and non-empty, this tries to display the correspondingly named Image in the ResourceManager. If ResourceManager is null, this uses the value of DefaultResourceManager instead. If no Image is found in any ResourceManager for the given name, the Name is treated as a URI to be gotten via a WebClient if NameIsUri is true, or as a file pathname for an image file stored on disk if NameIsUri is false.

    Finally, even if Image is null, this object will still be able to paint an image if Index is non-negative and if it can find an image in the GoView's ImageList.

    Images loaded by LoadImage from a ResourceManager or ImageList or from a file on disk or from the web are cached in a static/shared hash table. Future calls to LoadImage with the same source and name/index will just share the same Image. You can clear the whole cache by calling ClearCachedImages, or you can clear individual cache entries by calling one of the ClearCachedImage overloaded methods. Call UnloadImage to cause an individual GoImage to call LoadImage again the next time it needs to show an Image.

    A newly constructed GoImage will get its initial value for ImageList from DefaultImageList and for ResourceManager from DefaultResourceManager. These properties are not serialized and deserialized, although Name and Index are. To make sure copy-and-paste works successfully, you should either set DefaultImageList or DefaultResourceManager, or fix up the value of ImageList or ResourceManager in a GoView.ClipboardPasted event handler or GoObject.CopyObject override.

    See Also