IncrementalHitTester Třída

Definice

Dynamicky provádí testování hitů na .Stroke

public ref class IncrementalHitTester abstract
public abstract class IncrementalHitTester
type IncrementalHitTester = class
Public MustInherit Class IncrementalHitTester
Dědičnost
IncrementalHitTester
Odvozené

Příklady

Následující příklad ukazuje, jak přidat body do IncrementalHitTester , když uživatel zadá data pomocí pera. Příklad obsahuje obslužnou rutinu StrokeHit události, která vymaže část Stroke , kterou uživatel protíná. Pokud chcete vytvořit ovládací prvek, který uživateli umožňuje vymazat rukopis, přečtěte si článek Postupy: Vymazání rukopisu u vlastního ovládacího prvku.


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

Poznámky

Dynamicky IncrementalHitTester určuje, zda uživatel "hits" a Stroke. Tato třída umožňuje uživateli poskytnout okamžitou zpětnou vazbu v situacích, jako je výběr a vymazání rukopisu.

Existují dvě třídy, které dědí z IncrementalHitTester:

Následující tabulka uvádí, kde se dozvíte, jak spravovat digitální rukopis na vlastním ovládacím prvku.

K tomu… Podívejte se na tento článek
Vytvoření ovládacího prvku, který shromažďuje digitální rukopis Vytvoření vstupního ovládacího prvku rukopisu
Vytvoření ovládacího prvku, který uživateli umožňuje vybrat rukopis Postupy: Výběr rukopisu z vlastního ovládacího prvku
Vytvoření ovládacího prvku, který uživateli umožňuje vymazat rukopis Postupy: Vymazání rukopisu ve vlastním ovládacím prvku

Použití textu XAML

Tato třída se obvykle nepoužívá v jazyce XAML.

Vlastnosti

Name Description
IsValid

Získá, zda je IncrementalHitTester dosaženo testování.

Metody

Name Description
AddPoint(Point)

Přidá Point do IncrementalHitTester.

AddPoints(IEnumerable<Point>)

Přidá body do .IncrementalHitTester

AddPoints(StylusPointCollection)

Přidá zadané StylusPoint objekty do objektu IncrementalHitTester.

AddPointsCore(IEnumerable<Point>)

Přidá body do .IncrementalHitTester

EndHitTesting()

Uvolní prostředky používané nástrojem IncrementalHitTester.

Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro