Stroke.HitTest メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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
パラメーター
返品
true
pointが現在のストロークと交差する場合は。それ以外の場合はfalse。
例
次の例では、特定の領域と交差する 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 型の配列。
返品
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 の形状。
返品
true
stylusShapeが現在のストロークと交差する場合は。それ以外の場合は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
パラメーター
- diameter
- Double
ヒット テストする領域の直径。
返品
true 指定した領域が現在のストロークと交差する場合。それ以外の場合は false。
例
次の例では、特定の領域と交差する 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
パラメーター
返品
true 現在のストロークが boundsの範囲内にある場合は。それ以外の場合は 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