Stroke.HitTest メソッド

定義

Stroke が交差しているか、または特定の領域内にあるかを返します。

オーバーロード

HitTest(Point)

現在の Stroke が指定したポイントと交差するかどうかを示す値を返します。

HitTest(IEnumerable<Point>, Int32)

現在の Stroke が指定した境界内にあるかどうかを示す値を返します。

HitTest(IEnumerable<Point>, StylusShape)

指定した Stroke を使用して、指定したパスが StylusShape と交差するかどうかを返します。

HitTest(Point, Double)

現在の Stroke が指定した領域と交差するかどうかを示す値を返します。

HitTest(Rect, Int32)

Stroke が指定した四角形の境界内にあるかどうかを示す値を返します。

注釈

メソッドを HitTest 使用して、特定のポイントと交差しているか、指定された境界内にあるかを Stroke 判断できます。

次のメソッドは、交差しているかどうかを Stroke 確認します。

次のメソッドは、囲まれているかどうかを Stroke 確認します。

HitTest(Point)

現在の Stroke が指定したポイントと交差するかどうかを示す値を返します。

public:
 bool HitTest(System::Windows::Point point);
public bool HitTest (System.Windows.Point point);
member this.HitTest : System.Windows.Point -> bool
Public Function HitTest (point As Point) As Boolean

パラメーター

point
Point

ヒット テストを行う対象の Point

戻り値

Boolean

point が現在のストロークと交差している場合は true。それ以外の場合は false

次の例では、特定の領域と交差する場合に a Stroke の色を変更します。

Point myPoint = new Point(100, 100);

if (myStroke.HitTest(myPoint, 10))
{
    myStroke.DrawingAttributes.Color = Colors.Red;
}
Dim myPoint As New System.Windows.Point(100, 100)

If myStroke.HitTest(myPoint, 10) Then
    myStroke.DrawingAttributes.Color = Colors.Red
End If

注釈

このメソッドは、オーバーロードされた HitTest(Point, Double) メソッドが 1 の場合 diameter と同じように動作します。

適用対象

HitTest(IEnumerable<Point>, Int32)

現在の Stroke が指定した境界内にあるかどうかを示す値を返します。

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

パラメーター

lassoPoints
IEnumerable<Point>

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

percentageWithinLasso
Int32

Stroke がヒットしたと見なされるために、lassoPoints 内に含まれている必要がある Stroke の長さの割合。

戻り値

Boolean

現在のストロークが指定した境界内にある場合は true。それ以外の場合は false

次の例では、ストロークの少なくとも 80% が境界内にある場合に、ストロークを紫色にレンダリングします myPoints

Point[] myPoints = new Point[] {
    new Point(100, 100),
    new Point(200, 100),
    new Point(200, 200),
    new Point(100, 200)};

if (aStroke.HitTest(myPoints, 80))
{
    aStroke.DrawingAttributes.Color = Colors.Purple;
}
Dim myPoints() As System.Windows.Point = _
                      {New System.Windows.Point(100, 100), _
                       New System.Windows.Point(200, 100), _
                       New System.Windows.Point(200, 200), _
                       New System.Windows.Point(100, 200)}

If aStroke.HitTest(myPoints, 80) Then
    aStroke.DrawingAttributes.Color = Colors.Purple
End If

注釈

メソッドは HitTest 、最初と最後のポイント lassoPoints を接続してなわを作成します。

適用対象

HitTest(IEnumerable<Point>, StylusShape)

指定した Stroke を使用して、指定したパスが StylusShape と交差するかどうかを返します。

public:
 bool HitTest(System::Collections::Generic::IEnumerable<System::Windows::Point> ^ path, System::Windows::Ink::StylusShape ^ stylusShape);
public bool 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 -> bool
Public Function HitTest (path As IEnumerable(Of Point), stylusShape As StylusShape) As Boolean

パラメーター

path
IEnumerable<Point>

ヒット テストに続くパス stylusShape

stylusShape
StylusShape

ヒット テストに使用する path の形状。

戻り値

Boolean

stylusShape が現在のストロークと交差している場合は true。それ以外の場合は false

次のコードは、ストロークがパスと交差する場合に、ストロークを紫色に myPointsレンダリングします。

Point[] myPoints = new Point[] {
    new Point(100, 100),
    new	Point(200, 100),
    new	Point(200, 200),
    new	Point(100, 200)};

EllipseStylusShape myStylus = new EllipseStylusShape(5.0, 5.0, 0.0);

if (aStroke.HitTest(myPoints, myStylus))
{
    aStroke.DrawingAttributes.Color = Colors.Purple;
}
Dim myPoints() As System.Windows.Point = _
                      {New System.Windows.Point(100, 100), _
                       New System.Windows.Point(200, 100), _
                       New System.Windows.Point(200, 200), _
                       New System.Windows.Point(100, 200)}

Dim myStylus As New EllipseStylusShape(5.0, 5.0, 0.0)

If aStroke.HitTest(myPoints, myStylus) Then
    aStroke.DrawingAttributes.Color = Colors.Purple
End If

注釈

このメソッドは HitTest 、ストロークをヒット テストに使用 stylusShape します eraserPath

適用対象

HitTest(Point, Double)

現在の Stroke が指定した領域と交差するかどうかを示す値を返します。

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

パラメーター

point
Point

ヒット テストを行う領域の中心を定義する Point

diameter
Double

ヒット テストを行う領域の直径。

戻り値

Boolean

指定した領域が現在のストロークと交差する場合は true。それ以外の場合は false

次の例では、特定の領域と交差する場合に a Stroke の色を変更します。

Point myPoint = new Point(100, 100);

if (myStroke.HitTest(myPoint, 10))
{
    myStroke.DrawingAttributes.Color = Colors.Red;
}
Dim myPoint As New System.Windows.Point(100, 100)

If myStroke.HitTest(myPoint, 10) Then
    myStroke.DrawingAttributes.Color = Colors.Red
End If

適用対象

HitTest(Rect, Int32)

Stroke が指定した四角形の境界内にあるかどうかを示す値を返します。

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

パラメーター

bounds
Rect

ヒット テスト領域の境界を表す Rect

percentageWithinBounds
Int32

Stroke がヒットしたと見なされるために、percentageWithinBounds 内に含まれている必要がある Stroke の長さの割合。

戻り値

Boolean

現在のストロークが bounds の境界内にある場合は true。それ以外の場合は false です。

次の例では、ストロークの少なくとも 80% が Rect.

Rect rect1 = new Rect(100, 100, 100, 100);

if (aStroke.HitTest(rect1, 80))
{
    aStroke.DrawingAttributes.Color = Colors.Purple;
}
Dim rect1 As New Rect(100, 100, 100, 100)

If aStroke.HitTest(rect1, 80) Then
    aStroke.DrawingAttributes.Color = Colors.Purple
End If

適用対象