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

Параметры

bounds
Rect

Объект Rect, определяющий границы для проверки касания.

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

Параметры

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

Применяется к