StrokeCollection.HitTest Metoda

Definicja

Zwraca kolekcję pociągnięć zawartych w określonym obszarze.

Przeciążenia

HitTest(Rect, Int32)

Zwraca kolekcję pociągnięć, które mają co najmniej określoną wartość procentową długości w określonym prostokącie.

HitTest(Point, Double)

Zwraca kolekcję pociągnięć przecinających określony obszar.

HitTest(IEnumerable<Point>, StylusShape)

Zwraca kolekcję pociągnięć przecinających się z określoną ścieżką.

HitTest(IEnumerable<Point>, Int32)

Zwraca kolekcję pociągnięć, które mają co najmniej określoną wartość procentową długości w określonym obszarze.

HitTest(Point)

Zwraca kolekcję pociągnięć przecinających określony punkt.

HitTest(Rect, Int32)

Zwraca kolekcję pociągnięć, które mają co najmniej określoną wartość procentową długości w określonym prostokącie.

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

Parametry

bounds
Rect

Element Rect określający granice, które mają zostać przetestowane.

percentageWithinBounds
Int32

Minimalna wymagana długość pociągnięcia, który musi istnieć w granicach, aby można było go uznać za trafienie.

Zwraca

StrokeCollection

Obiekt StrokeCollection , który ma pociągnięcia z co najmniej określoną wartością procentową w obiekcie Rect.

Przykłady

Poniższy przykład usuwa pociągnięcia, które są co najmniej 50% w granicach Rect. W tym przykładzie założono, że istnieje InkPresenter nazwa .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)

Dotyczy

HitTest(Point, Double)

Zwraca kolekcję pociągnięć przecinających określony obszar.

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

Parametry

point
Point

Test Point trafienia.

diameter
Double

Rozmiar obszaru wokół testu trafienia Point .

Zwraca

StrokeCollection

Kolekcja Stroke obiektów przecinających określony punkt.

Przykłady

W poniższym przykładzie pokazano, jak uzyskać pociągnięcia przecinające określony Pointelement . W tym przykładzie założono, że istnieje InkPresenter nazwa .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

Dotyczy

HitTest(IEnumerable<Point>, StylusShape)

Zwraca kolekcję pociągnięć przecinających się z określoną ścieżką.

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

Parametry

path
IEnumerable<Point>

Tablica do typu Point reprezentująca ścieżkę do trafienia przetestowana.

stylusShape
StylusShape

Element StylusShape określający kształt eraserPath.

Zwraca

StrokeCollection

A StrokeCollection pociągnięć przecinających się z path.

Przykłady

Poniższy przykład zmienia kolor wszystkich pociągnięć przecinających ścieżkę utworzoną przez tablicę Point . W tym przykładzie założono, że istnieje InkPresenter nazwa .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

Dotyczy

HitTest(IEnumerable<Point>, Int32)

Zwraca kolekcję pociągnięć, które mają co najmniej określoną wartość procentową długości w określonym obszarze.

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

Parametry

lassoPoints
IEnumerable<Point>

Tablica typu Point reprezentująca granice obszaru do trafienia.

percentageWithinLasso
Int32

Dopuszczalna długość Strokeelementu , jako wartość procentowa, która lassoPoints ma być zawarta.

Zwraca

StrokeCollection

Obiekt StrokeCollection , który ma pociągnięcia z co najmniej określoną wartością procentową w tablicy Point .

Wyjątki

lassoPoints to null.

-lub- percentageWithinLasso to null.

lassoPoints zawiera pustą tablicę.

percentageWithinLasso wartość jest mniejsza niż 0 lub większa niż 100.

Przykłady

W poniższym przykładzie pokazano, jak usunąć wszystkie pociągnięcia, które są co najmniej 80 procent w określonym lasso z obiektu StrokeCollection. Jest to przydatne, gdy kontrolka niestandardowa umożliwia użytkownikowi wybranie pisma odwrotowego z lasso. Aby utworzyć kontrolkę, która umożliwia użytkownikowi wybieranie pisma odwrotowego za pomocą lasso, zobacz Instrukcje: wybieranie pisma odwrotowego z kontrolki niestandardowej.

// 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

Dotyczy

HitTest(Point)

Zwraca kolekcję pociągnięć przecinających określony punkt.

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

Parametry

point
Point

Punkt trafienia testu.

Zwraca

StrokeCollection

Kolekcja Stroke obiektów przecinających określony punkt.

Przykłady

W poniższym przykładzie pokazano, jak uzyskać pociągnięcia przecinające określony Pointelement . W tym przykładzie założono, że istnieje InkPresenter nazwa .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

Dotyczy