IncrementalHitTester Classe

Definizione

Esegue dinamicamente l'hit testing sull'oggetto Stroke.

public ref class IncrementalHitTester abstract
public abstract class IncrementalHitTester
type IncrementalHitTester = class
Public MustInherit Class IncrementalHitTester
Ereditarietà
IncrementalHitTester
Derivato

Esempio

Nell'esempio seguente viene illustrato come aggiungere punti a IncrementalHitTester quando l'utente inserisce i dati con lo stilo. L'esempio include un StrokeHit gestore eventi che cancella la parte dell'oggetto Stroke intersecato dall'utente. Per creare un controllo che consente a un utente di cancellare l'input penna, vedere Procedura: Cancellare l'input penna in un controllo personalizzato.


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

Commenti

Determina IncrementalHitTester in modo dinamico se l'utente "raggiunge" un oggetto Stroke. Questa classe consente di fornire feedback immediato all'utente in situazioni come la selezione e la cancellazione dell'input penna.

Esistono due classi che ereditano da IncrementalHitTester:

La tabella seguente elenca dove imparare a gestire l'input penna digitale in un controllo personalizzato.

Per eseguire questa operazione… Vedere questo articolo
Creare un controllo che raccoglie l'input penna digitale Creazione di un controllo di input penna
Creare un controllo che consenta all'utente di selezionare l'input penna Procedura: selezionare l'input penna da un controllo personalizzato
Creare un controllo che consenta all'utente di cancellare l'input penna Procedura: cancellare l'input penna da un controllo personalizzato

Utilizzo del testo XAML

Questa classe non viene in genere usata in XAML.

Proprietà

IsValid

Indica se l'oggetto IncrementalHitTester sta effettuando l'hit testing.

Metodi

AddPoint(Point)

Aggiunge un oggetto Point a IncrementalHitTester.

AddPoints(IEnumerable<Point>)

Aggiunge punti a IncrementalHitTester.

AddPoints(StylusPointCollection)

Aggiunge gli oggetti StylusPoint specificati all'oggetto IncrementalHitTester.

AddPointsCore(IEnumerable<Point>)

Aggiunge punti a IncrementalHitTester.

EndHitTesting()

Rilascia le risorse utilizzate da IncrementalHitTester.

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Si applica a