Поделиться через


HitTest (StrokeCollection)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

retval = object.HitTest(stylusPoints)

Arguments

stylusPoints

StylusPointCollection

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

Return Value

Type: StrokeCollection

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

Managed Equivalent

HitTest

Remarks

For a StrokeCollectionsc that contains strokes S0 - S2, and a StylusPointCollectionspc that contains points P0 - P3, the following HitTest call:

sc.HitTest(spc)

returns a StrokeCollection that containing S1 and S2.

Hit-test results

Hit-Test for StrokeCollection

Example

// 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