NtApplication.NtGetBitmap Method

Whenever a data object shall be displayed as a bitmap of flexible size, the NtTimeChartControl needs to get the Bitmap for this object. So it will call this interface method to call your code. You will retreive the NtDataObject as a parameter. Your data is contained in the NtDataObject.dataItem member, so you can return the correct Bitmap.
 
This technology makes sense because in many cases the application does not store the bitmap within the data object itself. It rather stores a key (like the file path or URL) that allows the application to retrieve the bitmap efficiently. But of course this retrieval can not be done by the Time Chart, it must be done by the application's code. So whenever the NtTimeChartControl wants to draw an object as a bitmap, it calls this member function. Then your code returns the Bitmap.

Overload List:

Modifier / Return Value Name and Parameters Description

Bitmap

NtGetBitmap ( NtDataObject ntDo )

For the data object given as parameter you will return the correct Bitmap.

Return value:

Bitmap
The Bitmap that represents the object.

Parameters:

NtDataObject ntDo
The data object that the Time Chart wants to draw.

Remarks:

The Time Chart guarantees to only call this interface mamber for those objects that are defined to be represented as Bitmaps. For others that are to be drawn as strings, double values or icons this method will never be called. This is important because you do not need to check the data type for these types. In other words, if all data objects that shall be drawn as Bitmaps are of the same type (e.g. strings that represent file paths) you can omit the casting completely.

Example:

One simple implementation looks like this:
 

public string NtGetBitmap(NtDataObject ntDo)
{
Bitmap bitmap = null;
try { bitmap = new Bitmap(bitmapDirectory + (string)ntDo.dataItem); }
catch(Exception) { }
return bitmap;
}


 
This implementation is perfectly fine if the Bitmaps are not being reused among data objects. Once the NtTimeChartControl called this method to get a Bitmap for a certain data object, it will keep the Bitmap in memory for this data object until this data object is being moved out of the scroll range. It will not call this method on every Paint event that takes place, so you do not need to be afraid of permanently reloading the same bitmap when using this implementation.
 
Still you can improve efficiency if several data objects share the same bitmap for display. Assume you create an application for a car rental company and in the Time Chart there is a row that shows car return events. When a car is being returned, an image of that car is placed at the time stamp of the return. The data objects of type 'car return' do not hold the bitmap itself, of course. They hold the identifier of the car. And as you may have many returns of the same car over time, the same bitmap is being used for many data objects. In this situation it now makes sense to implement a dictionary in your application that on startup is filled with all car images linked to their identifiers. And in the method NtGetBitmap() you then query the dictionary:
 

public string NtGetBitmap(NtDataObject ntDo)
{
Bitmap bitmap = null;
carBitmapDictionary.TryGetValue(((CarReturn)ntDo.dataItem).carIdentifier, out bitmap);
return bitmap;
}


 
For more details please see the Concept Bitmaps and Icons and the Tutorial Bitmaps and Icons.

See also:

NtGetDouble()
NtGetIcon()
NtGetText()