HitTest (Stroke)

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

Indicates whether a specified StylusPointCollection intersects with a Stroke object.

retval = object.HitTest(stylusPoints)

Arguments

stylusPoints

StylusPointCollection

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

Return Value

Boolean

true if the specified StylusPointCollection intersects with the Stroke object; otherwise, false.

Managed Equivalent

HitTest

Remarks

You can hit-test with arbitrary stylus point values instead of user-generated strokes, if you first generate a StylusPointCollection with those values.

Example

// Add the new points to the Stroke we're working with or 
// change the color of intersected strokes if the stylus is inverted.
function InkPresenterMouseMove(sender,args)
{
  if (args.GetStylusInfo().IsInverted)
  {
    // Change the color of intersected strokes 
    // to red to indicate they are selected.
    for (var i = 0; i < inkPresenter.Strokes.Count; i++)
    {
      var hitStroke = inkPresenter.Strokes.GetItem(i);
      
      if (hitStroke.HitTest(args.GetStylusPoints(inkPresenter)))
      {
        hitStroke.DrawingAttributes.SetValue("Color", "Red");
      }
    }
  }
  else if (newStroke != null)
  {
    // Add points to the stroke we're currently creating.
    newStroke.StylusPoints.AddStylusPoints(args.GetStylusPoints(inkPresenter));
  }
}

Applies To

Stroke