HitTest Method (StrokeCollection)

Returns a collection of strokes that are intersected by the points in the StylusPointCollection passed.

XAML
Cannot use methods in XAML.
Scripting
retval = object.HitTest(stylusPoints)

Parameters

stylusPoints

StylusPointCollection

The collection of stylus points used to check for intersection with the StrokeCollection.

Return Value

StrokeCollection

A collection of strokes that are intersected by the points in the StylusPointCollection passed.

Remarks

For a StrokeCollection sc, containing strokes S0 - S2, and a StylusPointCollection spc, containing points P0 - P3, calling:

sc.HitTest(spc)

returns a StrokeCollection containing S1 and S2.

Hit test results

Hit test results

Examples

JavaScript
// Add the new points to the Stroke we're working with
// or delete strokes if we are in erase mode
function inkPresenterMouseMove(sender, args)
{
    var stylusPoints = args.getStylusPoints(sender);
    
    // Erase Mode?
    if (lastErasePoint != null)
    {
        // connect the point from previous mouse event
        // to the current collection of stylus points
        stylusPoints.insert(0, lastErasePoint);
        var hitStrokes = sender.strokes.hitTest(stylusPoints);
        // Remove the strokes that were intersected above
        for (var i = 0; i < hitStrokes.Count; i++)
        {
          sender.strokes.remove(hitStrokes.getItem(i));
        }
        
        // update the cached last erase point
        lastErasePoint = stylusPoints.getItem(stylusPoints.count-1);
    }
    // Ink Mode?
    if (newStroke != null)
    {
        newStroke.stylusPoints.addStylusPoints(stylusPoints);
    }
}

Applies To

StrokeCollection

See Also

Ink Support In Microsoft Silverlight