Compartir a través de


Ink.NearestPoint Method

Ink.NearestPoint Method

Returns the Stroke object nearest a specified point, and returns the point on the Stroke object that is closest to the specified point.

Definition

Visual Basic .NET Public Function NearestPoint( _
ByVal point As Point, _
ByRef pointOnStroke As Single _
) As Stroke
C# public Stroke NearestPoint(
Point point,
out float pointOnStroke
);
Managed C++ public: Stroke* NearestPoint(
Point *point,
float **pointOnStroke
);

Parameters

point System.Drawing.Point. The specified point within the Ink object, given in ink space coordinates.
pointOnStroke System.Single. The point on the Stroke object that is closest to the specified point within the Ink object.

Return Value

Microsoft.Ink.Stroke. Returns the Stroke that contains a Point Leave Site that is closest to the specified point in the Ink object. If more than one stroke contains a Point Leave Site that is the same distance from the known Point Leave Site, the value of this result is arbitrary.

Exceptions

ObjectDisposedException Leave Site: The Ink object is disposed.

Remarks

The pointOnStroke parameter is defined as a floating-point number because the point on the Stroke object can fall between two physical coordinate points. For example, a value of 1.5 indicates that the point falls halfway between the first and second packets of the stroke. Use this value to split the Stroke object by calling the Stroke.Split method, or round the value up or down to index a packet in the Stroke object.

Examples

[C#]

This C# example returns the nearest Stroke object to a specified Point Leave Site, ptInk, which is given in ink space coordinates. In addition, the example returns the location of the point in the Stroke, thePointInStroke, that is nearest to the specified point.

float thePointInStroke;
Stroke theNearestStroke = theInkCollector.Ink.NearestPoint(ptInk,
    out thePointInStroke);

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example returns the nearest Stroke object to a specified Point Leave Site, ptInk, which is given in ink space coordinates. In addition, the example returns the location of the point in the Stroke, thePointInStroke, that is nearest to the specified point.

Dim thePointInStroke, theDistance As Single
Dim theNearestStroke As Stroke = theInkCollector.Ink.NearestPoint(ptInk, _
    thePointInStroke)

See Also