StrokeCollection.HitTest Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает коллекцию штрихов, содержащихся в указанной области.
Перегрузки
| Имя | Описание |
|---|---|
| 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 В этом примере предполагается, что вызывается InkPresenterpresenter.
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. В этом примере предполагается, что вызывается InkPresenterpresenter.
// 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 . В этом примере предполагается, что вызывается InkPresenterpresenter.
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 Это полезно, если пользовательский элемент управления позволяет пользователю выбрать рукописный ввод с помощью лассо. Чтобы создать элемент управления, позволяющий пользователю выбрать рукописный ввод с помощью lasso, см. статью "Практическое руководство. Выбор рукописного ввода из пользовательского элемента управления".
// 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. В этом примере предполагается, что вызывается InkPresenterpresenter.
// 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