IncrementalHitTester.AddPoints Méthode

Définition

Ajoute des points à IncrementalHitTester.

Surcharges

AddPoints(IEnumerable<Point>)

Ajoute des points à IncrementalHitTester.

AddPoints(StylusPointCollection)

Ajoute les objets StylusPoint spécifiés au IncrementalHitTester.

AddPoints(IEnumerable<Point>)

Ajoute des points à IncrementalHitTester.

public:
 void AddPoints(System::Collections::Generic::IEnumerable<System::Windows::Point> ^ points);
public void AddPoints (System.Collections.Generic.IEnumerable<System.Windows.Point> points);
member this.AddPoints : seq<System.Windows.Point> -> unit
Public Sub AddPoints (points As IEnumerable(Of Point))

Paramètres

points
IEnumerable<Point>

Tableau de type Point à ajouter au IncrementalHitTester.

Exemples

L’exemple suivant montre comment ajouter des points au IncrementalHitTester lorsque l’utilisateur entre des données avec le stylet. L’exemple inclut un gestionnaire d’événements StrokeHit qui efface la partie du Stroke que l’utilisateur croise. Pour créer un contrôle qui permet à un utilisateur d’effacer l’entrée manuscrite, consultez Guide pratique pour effacer l’encre sur un contrôle personnalisé.


// Prepare to collect stylus packets. Get the 
// IncrementalHitTester from the InkPresenter's 
// StrokeCollection and subscribe to its StrokeHitChanged event.
protected override void OnStylusDown(StylusDownEventArgs e)
{
    base.OnStylusDown(e);

    EllipseStylusShape eraserTip = new EllipseStylusShape(3, 3, 0);
    eraseTester = 
        presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip);
    eraseTester.StrokeHit += new StrokeHitEventHandler(eraseTester_StrokeHit);
    eraseTester.AddPoints(e.GetStylusPoints(this));
}

// Collect the StylusPackets as the stylus moves.
protected override void OnStylusMove(StylusEventArgs e)
{
    if (eraseTester.IsValid)
    {
        eraseTester.AddPoints(e.GetStylusPoints(this));
    }
}

// Unsubscribe from the StrokeHitChanged event when the
// user lifts the stylus.
protected override void OnStylusUp(StylusEventArgs e)
{

    eraseTester.AddPoints(e.GetStylusPoints(this));
    eraseTester.StrokeHit -= new
        StrokeHitEventHandler(eraseTester_StrokeHit);
    eraseTester.EndHitTesting();
}

// When the stylus intersects a stroke, erase that part of
// the stroke.  When the stylus dissects a stoke, the 
// Stroke.Erase method returns a StrokeCollection that contains
// the two new strokes.
void eraseTester_StrokeHit(object sender,
    StrokeHitEventArgs args)
{
    StrokeCollection eraseResult =
        args.GetPointEraseResults();
    StrokeCollection strokesToReplace = new StrokeCollection();
    strokesToReplace.Add(args.HitStroke);
   
    // Replace the old stroke with the new one.
    if (eraseResult.Count > 0)
    {
        presenter.Strokes.Replace(strokesToReplace, eraseResult);
    }
    else
    {
        presenter.Strokes.Remove(strokesToReplace);
    }
}

     ' Prepare to collect stylus packets. Get the 
     ' IncrementalHitTester from the InkPresenter's 
     ' StrokeCollection and subscribe to its StrokeHitChanged event.
     Protected Overrides Sub OnStylusDown(ByVal e As StylusDownEventArgs)

         MyBase.OnStylusDown(e)

         Dim eraserTip As New EllipseStylusShape(3, 3, 0)
         eraseTester = presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip)
         AddHandler eraseTester.StrokeHit, _
             AddressOf eraseTester_StrokeHit
         eraseTester.AddPoints(e.GetStylusPoints(Me))

     End Sub

     ' Collect the StylusPackets as the stylus moves.
     Protected Overrides Sub OnStylusMove(ByVal e As StylusEventArgs)

         If eraseTester.IsValid Then
             eraseTester.AddPoints(e.GetStylusPoints(Me))
         End If

     End Sub

     ' Unsubscribe from the StrokeHitChanged event when the
     ' user lifts the stylus.
     Protected Overrides Sub OnStylusUp(ByVal e As StylusEventArgs)

         eraseTester.AddPoints(e.GetStylusPoints(Me))

         RemoveHandler eraseTester.StrokeHit, _
             AddressOf eraseTester_StrokeHit
         eraseTester.EndHitTesting()

     End Sub


     ' When the stylus intersects a stroke, erase that part of
     ' the stroke.  When the stylus dissects a stoke, the 
     ' Stroke.Erase method returns a StrokeCollection that contains
     ' the two new strokes.
     Private Sub eraseTester_StrokeHit(ByVal sender As Object, _
             ByVal args As StrokeHitEventArgs)

         Dim eraseResult As StrokeCollection = _
             args.GetPointEraseResults()
         Dim strokesToReplace As New StrokeCollection()
         strokesToReplace.Add(args.HitStroke)

         ' Replace the old stroke with the new one.
         If eraseResult.Count > 0 Then
             presenter.Strokes.Replace(strokesToReplace, eraseResult)
         Else
             presenter.Strokes.Remove(strokesToReplace)
         End If

     End Sub

S’applique à

AddPoints(StylusPointCollection)

Ajoute les objets StylusPoint spécifiés au IncrementalHitTester.

public:
 void AddPoints(System::Windows::Input::StylusPointCollection ^ stylusPoints);
public void AddPoints (System.Windows.Input.StylusPointCollection stylusPoints);
member this.AddPoints : System.Windows.Input.StylusPointCollection -> unit
Public Sub AddPoints (stylusPoints As StylusPointCollection)

Paramètres

stylusPoints
StylusPointCollection

Collection d'objets StylusPoint à ajouter au IncrementalHitTester.

Exemples

L’exemple suivant montre comment ajouter des points au IncrementalStrokeHitTester lorsque l’utilisateur entre des données avec le stylet. L’exemple inclut un gestionnaire d’événements StrokeHit qui efface la partie du Stroke que l’utilisateur croise. Pour créer un contrôle qui permet à un utilisateur d’effacer l’entrée manuscrite, consultez Guide pratique pour effacer l’encre sur un contrôle personnalisé.


// Prepare to collect stylus packets. Get the 
// IncrementalHitTester from the InkPresenter's 
// StrokeCollection and subscribe to its StrokeHitChanged event.
protected override void OnStylusDown(StylusDownEventArgs e)
{
    base.OnStylusDown(e);

    EllipseStylusShape eraserTip = new EllipseStylusShape(3, 3, 0);
    eraseTester = 
        presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip);
    eraseTester.StrokeHit += new StrokeHitEventHandler(eraseTester_StrokeHit);
    eraseTester.AddPoints(e.GetStylusPoints(this));
}

// Collect the StylusPackets as the stylus moves.
protected override void OnStylusMove(StylusEventArgs e)
{
    if (eraseTester.IsValid)
    {
        eraseTester.AddPoints(e.GetStylusPoints(this));
    }
}

// Unsubscribe from the StrokeHitChanged event when the
// user lifts the stylus.
protected override void OnStylusUp(StylusEventArgs e)
{

    eraseTester.AddPoints(e.GetStylusPoints(this));
    eraseTester.StrokeHit -= new
        StrokeHitEventHandler(eraseTester_StrokeHit);
    eraseTester.EndHitTesting();
}

// When the stylus intersects a stroke, erase that part of
// the stroke.  When the stylus dissects a stoke, the 
// Stroke.Erase method returns a StrokeCollection that contains
// the two new strokes.
void eraseTester_StrokeHit(object sender,
    StrokeHitEventArgs args)
{
    StrokeCollection eraseResult =
        args.GetPointEraseResults();
    StrokeCollection strokesToReplace = new StrokeCollection();
    strokesToReplace.Add(args.HitStroke);
   
    // Replace the old stroke with the new one.
    if (eraseResult.Count > 0)
    {
        presenter.Strokes.Replace(strokesToReplace, eraseResult);
    }
    else
    {
        presenter.Strokes.Remove(strokesToReplace);
    }
}

     ' Prepare to collect stylus packets. Get the 
     ' IncrementalHitTester from the InkPresenter's 
     ' StrokeCollection and subscribe to its StrokeHitChanged event.
     Protected Overrides Sub OnStylusDown(ByVal e As StylusDownEventArgs)

         MyBase.OnStylusDown(e)

         Dim eraserTip As New EllipseStylusShape(3, 3, 0)
         eraseTester = presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip)
         AddHandler eraseTester.StrokeHit, _
             AddressOf eraseTester_StrokeHit
         eraseTester.AddPoints(e.GetStylusPoints(Me))

     End Sub

     ' Collect the StylusPackets as the stylus moves.
     Protected Overrides Sub OnStylusMove(ByVal e As StylusEventArgs)

         If eraseTester.IsValid Then
             eraseTester.AddPoints(e.GetStylusPoints(Me))
         End If

     End Sub

     ' Unsubscribe from the StrokeHitChanged event when the
     ' user lifts the stylus.
     Protected Overrides Sub OnStylusUp(ByVal e As StylusEventArgs)

         eraseTester.AddPoints(e.GetStylusPoints(Me))

         RemoveHandler eraseTester.StrokeHit, _
             AddressOf eraseTester_StrokeHit
         eraseTester.EndHitTesting()

     End Sub


     ' When the stylus intersects a stroke, erase that part of
     ' the stroke.  When the stylus dissects a stoke, the 
     ' Stroke.Erase method returns a StrokeCollection that contains
     ' the two new strokes.
     Private Sub eraseTester_StrokeHit(ByVal sender As Object, _
             ByVal args As StrokeHitEventArgs)

         Dim eraseResult As StrokeCollection = _
             args.GetPointEraseResults()
         Dim strokesToReplace As New StrokeCollection()
         strokesToReplace.Add(args.HitStroke)

         ' Replace the old stroke with the new one.
         If eraseResult.Count > 0 Then
             presenter.Strokes.Replace(strokesToReplace, eraseResult)
         Else
             presenter.Strokes.Remove(strokesToReplace)
         End If

     End Sub

S’applique à