StrokeCollection.HitTest 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳一組包含在指定區域內的筆劃。
多載
| 名稱 | Description |
|---|---|
| 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
參數
- percentageWithinBounds
- Int32
一個劃線必須在一定範圍內,且必須達到被視為命中所需的最小長度。
傳回
StrokeCollection其中筆劃的筆劃百分比至少在 內Rect。
範例
以下範例抹除至少在 範圍內 50% Rect的筆劃。 此範例假設存在一個 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
參數
傳回
一組 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 A 筆劃與 相交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 列。
傳回
StrokeCollection一個在陣列中筆劃至少達到指定百分比Point的。
例外狀況
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