HitTest (Stroke)


[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Indicates whether a specified StylusPointCollection intersects with a Stroke object.

retval = object.HitTest(stylusPoints)



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


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

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

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

Aggiunte alla community