API Documentation -> NtCustomObjectPaint -> NtCalculateLeftAndRightEdgesTicks

# NtCustomObjectPaint.NtCalculateLeftAndRightEdgesTicks Method

Display Objects have a certain width. Suppose you create a hotline software and want to symbolize customer calls by an icon. The icon's left edge indicates the time of the call while the right edge is placed more to the right. Please see the sceenshot below: A customer has called for PC support exactly at 12:00. So the left edge of the icon is located at 12:00. Meanwhile the right edge of the icon is located at another time which depends not only on the width of the icon but also on the current time scale factor of the NtTimeChartControl. In this example this is roundabout 12:45.

The second screenshot (below) shows the same data, but the time scaling factor (ticksPerPixel) is different: And while the left edge of the icon still is on the same time stamp 12:00 the right edge is about 12:07. If calling this interface method now, the parameter ticksPerPixel is different (smaller in this case).

The NtTimeChartControl needs to know about the time stamps of the left and right edges at any time and thereby calls this member function. The implementation is fairly easy. In the example above (with an icon width of 30 pixels) it simply looks like this:

public void NtCalculateLeftAndRightEdgesTicks(NtTimeChartControl ntTimeChartControl, NtDataObject dataObject, double ticksPerPixel, out long leftTicks, out long rightTicks)
{
leftTicks = dataObject.dt.Ticks;
rigthTicks = dataObject.dt.Ticks + 30 * ticksPerPixel;
}

Overload List:

Modifier / Return Value | Name and Parameters | Description
--- | --- | ---
NtDisplayObject | NtCalculateLeftAndRightEdgesTicks ( NtTimeChartControl ntTimeChartControl, NtDataObject dataObject, NtDisplayDef displayDef, double ticksPerPixel, out long leftTicks, out long rightTicks ) | Implement this interface method to create a display object for the data object given.

Return value:

NtDisplayObject

Parameters:

NtTimeChartControl ntTimeChartControl
The NtTimeChartControl that does the call. Normally not used if you have only one NtTimeChartControl in your Form or application. But if you have more than one NtTimeChartControl and implement this interface only onece, this parameter might be helpful.

NtDataObject dataObject
The data object to do the calculation for.

NtDisplayDef displayDef
The NtDisplayDef instance for the data type of the object to be drawn. This conatins useful information like font and size information that you might need to do the calculation.

double ticksPerPixel
The time scaling factor the NtTimeChartControl currently works with. It describes the time difference of two neighboring pixels in ticks. One tick is 100 nano seconds.

out long leftTicks
The left edge of the NtDisplayObject in ticks. It is the first output parameter of this method.

out long rightTicks
The right edge of the NtDisplayObject in ticks. It is the second output parameter of this method.

Remarks:

None.

Top API Documentation -> NtTimeChartControl -> NtCalculateLeftAndRightEdgesTicks © 2016 Bassaly