IncrementalHitTester Klasa

Definicja

Dynamicznie wykonuje testy trafienia na obiekcie Stroke.

public ref class IncrementalHitTester abstract
public abstract class IncrementalHitTester
type IncrementalHitTester = class
Public MustInherit Class IncrementalHitTester
Dziedziczenie
IncrementalHitTester
Pochodne

Przykłady

W poniższym przykładzie pokazano, jak dodawać punkty do IncrementalHitTester danych wejściowych przez użytkownika za pomocą stylu. W tym przykładzie przedstawiono procedurę StrokeHit obsługi zdarzeń, która usuwa część Stroke , którą przecina użytkownik. Aby utworzyć kontrolkę umożliwiającą użytkownikowi wymazywanie pisma odręcznego, zobacz Instrukcje: wymazywanie pisma odręcznego w kontrolce niestandardowej.


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

Uwagi

Dynamicznie IncrementalHitTester określa, czy użytkownik "osiąga" wartość Stroke. Ta klasa umożliwia natychmiastowe przesyłanie opinii do użytkownika w sytuacjach, takich jak wybieranie i wymazywanie pisma odk.

Istnieją dwie klasy dziedziczone po IncrementalHitTester:

W poniższej tabeli przedstawiono, gdzie dowiedzieć się, jak zarządzać cyfrowym atramentem w kontrolce niestandardowej.

Aby to zrobić... Zobacz ten artykuł
Tworzenie kontrolki, która zbiera cyfrowy atrament Tworzenie formantu danych wejściowych atramentu
Tworzenie kontrolki, która umożliwia użytkownikowi wybieranie pisma odwłocznego Porady: wybrać atrament w niestandardowej kontrolce
Tworzenie kontrolki, która umożliwia użytkownikowi wymazywanie pisma odręcznego Jak usunąć atrament na niestandardowej kontrolce

Użycie tekstu w języku XAML

Ta klasa nie jest zwykle używana w języku XAML.

Właściwości

IsValid

Pobiera, czy IncrementalHitTester test trafienia.

Metody

AddPoint(Point)

Dodaje element do Point elementu IncrementalHitTester.

AddPoints(IEnumerable<Point>)

Dodaje punkty do elementu IncrementalHitTester.

AddPoints(StylusPointCollection)

Dodaje określone StylusPoint obiekty do obiektu IncrementalHitTester.

AddPointsCore(IEnumerable<Point>)

Dodaje punkty do elementu IncrementalHitTester.

EndHitTesting()

Zwalnia zasoby używane przez usługę IncrementalHitTester.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy