API Documentation -> NtCustomObjectPaint -> NtCalculateTopAndBottomInRow

# NtCustomObjectPaint.NtCalculateTopAndBottomInRow Method

This interface method allows the NtTimeChartControl to get information about top and bottom of a custom NtDisplayObject. When scaling the vertical position (Y-coordinate) and height (or top and bottom resp.) you should not base your calculations on the current row height (which you can get from the NtTimeChartControl by calling its GetRowHeight() method). Instead you should take the NtDisplayDef's member preferredRowHeight into account. The reason is that the actual row height can change dynamically due to changes of the currently active perspective or due to open and closed categories. For example if data types of different preferredRowHeight are combined in one row you can not tell which row heigh finally is the one that is being used. Still you want your data to look the same independently of that.

Example:
Suppose from NtDisplayObject you derivated your own class CircleDisplayObject that shall be used to draw objects as circles with an individual radius each. In order to align the centers of all the circles on half the height of the row (defined by displayObject.DisplayDef.preferredRowHeight/2), you need to calculate top and bottom accordingly:

public void NtCalculateTopAndBottomInRow(NtTimeChartControl ntTimeChartControl, NtDisplayObject displayObject, out int top, out int bottom)
{
top = displayObject.DisplayDef.preferredRowHeight/2 - ((CircleDisplayObject)displayObject).radius;
bottom = top + 2 * ((CircleDisplayObject)displayObject).radius;
}

Both top and bottom values might as well be negative or greater than the current or preferred row height.

Overload List:

Modifier / Return Value | Name and Parameters | Description
--- | --- | ---
NtDisplayObject | NtCalculateTopAndBottomInRow ( NtTimeChartControl ntTimeChartControl, NtDataObject dataObject, 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.

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 -> NtCalculateTopAndBottomInRow © 2016 Bassaly