Language

StrokeCollection.HitTest メソッド

定義

指定した領域内に含まれるストロークのコレクションを返します。

オーバーロード

Name 説明
HitTest(Rect, Int32)

指定した四角形内の長さの指定された割合以上のストロークのコレクションを返します。

HitTest(Point, Double)

指定した領域と交差するストロークのコレクションを返します。

HitTest(IEnumerable<Point>, StylusShape)

指定したパスと交差するストロークのコレクションを返します。

HitTest(IEnumerable<Point>, Int32)

指定した領域内の長さの指定された割合以上のストロークのコレクションを返します。

HitTest(Point)

指定した点と交差するストロークのコレクションを返します。

HitTest(Rect, Int32)

指定した四角形内の長さの指定された割合以上のストロークのコレクションを返します。

public:
 System::Windows::Ink::StrokeCollection ^ HitTest(System::Windows::Rect bounds, int percentageWithinBounds);
public System.Windows.Ink.StrokeCollection HitTest(System.Windows.Rect bounds, int percentageWithinBounds);
member this.HitTest : System.Windows.Rect * int -> System.Windows.Ink.StrokeCollection
Public Function HitTest (bounds As Rect, percentageWithinBounds As Integer) As StrokeCollection

パラメーター

bounds
Rect

ヒット テストする境界を指定する Rect 。

percentageWithinBounds
Int32

ヒットと見なされるために境界内に存在する必要があるストロークの最小必要長。

戻り値

StrokeCollection内で少なくとも指定されたパーセンテージを持つストロークを持つRect。

例

次の例では、 Rectの境界内で少なくとも 50% のストロークを消去します。 この例では、InkPresenterと呼ばれるpresenterがあることを前提としています。

Rect rect = new Rect(100, 100, 200, 200);
StrokeCollection strokes = presenter.Strokes.HitTest(rect, 50);

presenter.Strokes.Remove(strokes);
Dim rect As Rect = New Rect(100, 100, 200, 200)
Dim strokes As StrokeCollection = presenter.Strokes.HitTest(rect, 50)

presenter.Strokes.Remove(strokes)

適用対象

HitTest(Point, Double)

指定した領域と交差するストロークのコレクションを返します。

public:
 System::Windows::Ink::StrokeCollection ^ HitTest(System::Windows::Point point, double diameter);
public System.Windows.Ink.StrokeCollection HitTest(System.Windows.Point point, double diameter);
member this.HitTest : System.Windows.Point * double -> System.Windows.Ink.StrokeCollection
Public Function HitTest (point As Point, diameter As Double) As StrokeCollection

パラメーター

point
Point

ヒット テストの Point 。

diameter
Double

ヒット テストを実行する Point の周囲の領域のサイズ。

戻り値

指定した点と交差する Stroke オブジェクトのコレクション。

例

次の例では、指定した Pointと交差するストロークを取得する方法を示します。 この例では、InkPresenterと呼ばれるpresenterがあることを前提としています。

// Change the color of all the strokes at the specified position.
public void SelectStrokes(Point position)
{
    StrokeCollection selected = presenter.Strokes.HitTest(position, 5);

    foreach (Stroke s in selected)
    {
        s.DrawingAttributes.Color = Colors.Purple;
    }
}
' Change the color of all the strokes at the specified position.
Public Sub SelectStrokes(ByVal position As Point)

    Dim selected As StrokeCollection = presenter.Strokes.HitTest(position, 5)

    Dim s As Stroke
    For Each s In selected
        s.DrawingAttributes.Color = Colors.Purple
    Next s

End Sub

適用対象

HitTest(IEnumerable<Point>, StylusShape)

指定したパスと交差するストロークのコレクションを返します。

public:
 System::Windows::Ink::StrokeCollection ^ HitTest(System::Collections::Generic::IEnumerable<System::Windows::Point> ^ path, System::Windows::Ink::StylusShape ^ stylusShape);
public System.Windows.Ink.StrokeCollection HitTest(System.Collections.Generic.IEnumerable<System.Windows.Point> path, System.Windows.Ink.StylusShape stylusShape);
member this.HitTest : seq<System.Windows.Point> * System.Windows.Ink.StylusShape -> System.Windows.Ink.StrokeCollection
Public Function HitTest (path As IEnumerable(Of Point), stylusShape As StylusShape) As StrokeCollection

パラメーター

path
IEnumerable<Point>

ヒット テストするパスを表す Point 型の配列。

stylusShape
StylusShape

StylusShapeの形状を指定するeraserPath。

戻り値

StrokeCollectionと交差するストロークのpath。

例

次の使用例は、 Point 配列によって作成されたパスと交差するすべてのストロークの色を変更します。 この例では、InkPresenterと呼ばれるpresenterがあることを前提としています。

private void HitTestWithEraser(Point[] points)
{
    RectangleStylusShape eraser = new RectangleStylusShape(3, 3, 0);

    StrokeCollection strokes = presenter.Strokes.HitTest(points, eraser);

    foreach (Stroke s in strokes)
    {
        s.DrawingAttributes.Color = Colors.Purple;
    }
}
Private Sub HitTestWithEraser(ByVal points() As Point)
    Dim eraser As RectangleStylusShape = New RectangleStylusShape(3, 3, 0)

    Dim strokes As StrokeCollection = presenter.Strokes.HitTest(points, eraser)

    Dim s As Stroke
    For Each s In strokes
        s.DrawingAttributes.Color = Colors.Purple
    Next
End Sub

適用対象

HitTest(IEnumerable<Point>, Int32)

指定した領域内の長さの指定された割合以上のストロークのコレクションを返します。

public:
 System::Windows::Ink::StrokeCollection ^ HitTest(System::Collections::Generic::IEnumerable<System::Windows::Point> ^ lassoPoints, int percentageWithinLasso);
public System.Windows.Ink.StrokeCollection HitTest(System.Collections.Generic.IEnumerable<System.Windows.Point> lassoPoints, int percentageWithinLasso);
member this.HitTest : seq<System.Windows.Point> * int -> System.Windows.Ink.StrokeCollection
Public Function HitTest (lassoPoints As IEnumerable(Of Point), percentageWithinLasso As Integer) As StrokeCollection

パラメーター

lassoPoints
IEnumerable<Point>

ヒット テストする領域の境界を表す Point 型の配列。

percentageWithinLasso
Int32

Strokeに含めるlassoPointsの許容される長さをパーセンテージで指定します。

戻り値

StrokeCollection配列内で指定された割合以上のストロークを持つPoint。

例外

lassoPoints は nullです。

-又は-

percentageWithinLasso は nullです。

lassoPoints には空の配列が含まれています。

percentageWithinLasso が 0 未満または 100 より大きい。

例

次の例では、指定したなげなわ内の少なくとも 80% のストロークをすべて StrokeCollectionから削除する方法を示します。 これは、ユーザーがなげなわでインクを選択できるカスタム コントロールの場合に便利です。 ユーザーがなげなわでインクを選択できるようにするコントロールを作成するには、「 方法: カスタム コントロールからインクを選択する」を参照してください。

// Remove the strokes within the lasso from the InkPresenter
public void RemoveStrokes(Point[] lasso)
{
    StrokeCollection strokes = presenter.Strokes.HitTest(lasso, 80);

    presenter.Strokes.Remove(strokes);
}
' Remove the strokes within the lasso from the InkPresenter
Public Sub RemoveStrokes(ByVal lasso As Point())

    If lasso Is Nothing Then
        Return
    End If

    Dim strokes As StrokeCollection = _
        presenter.Strokes.HitTest(lasso, 80)

    presenter.Strokes.Remove(strokes)

End Sub

適用対象

HitTest(Point)

指定した点と交差するストロークのコレクションを返します。

public:
 System::Windows::Ink::StrokeCollection ^ HitTest(System::Windows::Point point);
public System.Windows.Ink.StrokeCollection HitTest(System.Windows.Point point);
member this.HitTest : System.Windows.Point -> System.Windows.Ink.StrokeCollection
Public Function HitTest (point As Point) As StrokeCollection

パラメーター

point
Point

ヒット テストのポイント。

戻り値

指定した点と交差する Stroke オブジェクトのコレクション。

例

次の例では、指定した Pointと交差するストロークを取得する方法を示します。 この例では、InkPresenterと呼ばれるpresenterがあることを前提としています。

// Change the color of all the strokes at the specified position.
public void SelectStrokes(Point position)
{
    StrokeCollection selected = presenter.Strokes.HitTest(position, 5);

    foreach (Stroke s in selected)
    {
        s.DrawingAttributes.Color = Colors.Purple;
    }
}
' Change the color of all the strokes at the specified position.
Public Sub SelectStrokes(ByVal position As Point)

    Dim selected As StrokeCollection = presenter.Strokes.HitTest(position, 5)

    Dim s As Stroke
    For Each s In selected
        s.DrawingAttributes.Color = Colors.Purple
    Next s

End Sub

適用対象