Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HitTest (Stroke)

Silverlight

Indicates whether a specified StylusPointCollection intersects with a Stroke object.

retval = object.HitTest(stylusPoints)

stylusPoints

StylusPointCollection

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

Boolean

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.
    newStroke.StylusPoints.AddStylusPoints(args.GetStylusPoints(inkPresenter));
  }
}

Community Additions

ADD
Show:
© 2015 Microsoft