IncrementalHitTester クラス

定義

Stroke でヒット テストを動的に実行します。

public ref class IncrementalHitTester abstract
public abstract class IncrementalHitTester
type IncrementalHitTester = class
Public MustInherit Class IncrementalHitTester
継承
IncrementalHitTester
派生

次の例では、ユーザーがスタイラスを使用してデータを入力するときに、 に IncrementalHitTester ポイントを追加する方法を示します。 この例には、 StrokeHit ユーザーが交差する の Stroke 一部を消去するイベント ハンドラーが含まれています。 ユーザーがインクを消去できるようにするコントロールを作成するには、「 方法: カスタム コントロールでインクを消去する」を参照してください。


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

注釈

IncrementalHitTester 、ユーザーが を "ヒット" するかどうかを動的に Stroke決定します。 このクラスを使用すると、インクの選択や消去などの状況で、ユーザーに即座にフィードバックを提供できます。

から IncrementalHitTester継承する 2 つのクラスがあります。

  • ヒット テストでは IncrementalLassoHitTester 、なげなわパスで囲まれているかどうかを判断することでストロークがテストされます。

  • ヒット テストでは IncrementalStrokeHitTester 、消しゴム パスが交差する場所を決定することでストロークがテストされます。

次の表は、カスタム コントロールでデジタル インクを管理する方法を学習する場所を示しています。

目的 参照する記事
デジタル インクを収集するコントロールを作成する インク入力コントロールの作成
ユーザーがインクを選択できるようにするコントロールを作成する 方法: カスタム コントロールからインクを選択する
ユーザーがインクをポイント消去できるようにするコントロールを作成する 方法 : カスタム コントロールでインクを消去する

XAML テキストの使用法

このクラスは通常、XAML では使用されません。

プロパティ

IsValid

IncrementalHitTester がヒット テストを行っているかどうかを取得します。

メソッド

AddPoint(Point)

PointIncrementalHitTester に追加します。

AddPoints(IEnumerable<Point>)

IncrementalHitTester にポイントを追加します。

AddPoints(StylusPointCollection)

指定した StylusPoint オブジェクトを IncrementalHitTester に追加します。

AddPointsCore(IEnumerable<Point>)

IncrementalHitTester にポイントを追加します。

EndHitTesting()

IncrementalHitTester によって使用されているリソースを解放します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象