StrokeCollection.HitTest Metodo

Definizione

Restituisce un insieme di tratti contenuti nell'area specificata.

Overload

HitTest(Rect, Int32)

Restituisce un insieme di tratti che hanno almeno la percentuale di lunghezza specificata all'interno del rettangolo specificato.

HitTest(Point, Double)

Restituisce un insieme di tratti che intersecano l'area specificata.

HitTest(IEnumerable<Point>, StylusShape)

Restituisce un insieme di tratti che intersecano con il tracciato specificato.

HitTest(IEnumerable<Point>, Int32)

Restituisce un insieme di tratti che hanno almeno la percentuale di lunghezza specificata nell'area specificata.

HitTest(Point)

Restituisce un insieme di tratti che intersecano il punto specificato.

HitTest(Rect, Int32)

Restituisce un insieme di tratti che hanno almeno la percentuale di lunghezza specificata all'interno del rettangolo specificato.

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

Parametri

bounds
Rect

Oggetto Rect che specifica i limiti da sottoporre a hit testing.

percentageWithinBounds
Int32

Lunghezza minima richiesta per un tratto, che deve esserci all'interno dei limiti, affinché possa essere considerato riscontrato.

Restituisce

Oggetto StrokeCollection che ha i tratti con almeno la percentuale specificata all'interno dell'oggetto Rect.

Esempio

Nell'esempio seguente vengono cancellati i tratti che sono almeno il 50% entro i limiti dell'oggetto Rect. In questo esempio si presuppone che sia presente un InkPresenter oggetto denominato 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)

Si applica a

HitTest(Point, Double)

Restituisce un insieme di tratti che intersecano l'area specificata.

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

Parametri

point
Point

Point per l'hit test.

diameter
Double

La dimensione dell'area intorno all'oggetto Point da sottoporre a hit testing.

Restituisce

L'insieme degli oggetti Stroke che intersecano il punto specificato.

Esempio

Nell'esempio seguente viene illustrato come ottenere i tratti che intersecano l'oggetto specificato Point. In questo esempio si presuppone che sia presente un InkPresenter oggetto denominato 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

Si applica a

HitTest(IEnumerable<Point>, StylusShape)

Restituisce un insieme di tratti che intersecano con il tracciato specificato.

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

Parametri

path
IEnumerable<Point>

Matrice per il tipo Point che rappresenta il tracciato da sottoporre a hit testing.

stylusShape
StylusShape

StylusShape, che specifica la forma di eraserPath.

Restituisce

Insieme StrokeCollection di tratti che si intersecano con path.

Esempio

Nell'esempio Point seguente viene modificato il colore di tutti i tratti che intersecano il percorso creato dalla matrice. In questo esempio si presuppone che sia presente un InkPresenter oggetto denominato 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

Si applica a

HitTest(IEnumerable<Point>, Int32)

Restituisce un insieme di tratti che hanno almeno la percentuale di lunghezza specificata nell'area specificata.

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

Parametri

lassoPoints
IEnumerable<Point>

Matrice di tipo Point che rappresenta i limiti dell'area da sottoporre a hit testing.

percentageWithinLasso
Int32

Lunghezza accettabile dell'oggetto Stroke, in percentuale, che lassoPoints può contenere.

Restituisce

Oggetto StrokeCollection che ha i tratti con almeno la percentuale specificata nella matrice Point.

Eccezioni

lassoPoints è null.

-oppure-

percentageWithinLasso è null.

lassoPoints contiene una matrice vuota.

percentageWithinLasso è minore di 0 o maggiore di 100.

Esempio

Nell'esempio seguente viene illustrato come rimuovere tutti i tratti che sono almeno il 80% all'interno del lasso specificato da un StrokeCollectionoggetto . Questo è utile quando un controllo personalizzato consente all'utente di selezionare l'input penna con un lasso. Per creare un controllo che consente a un utente di selezionare input penna con un lasso, vedere Procedura: Selezionare input penna da un controllo personalizzato.

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

Si applica a

HitTest(Point)

Restituisce un insieme di tratti che intersecano il punto specificato.

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

Parametri

point
Point

Il punto da sottoporre a hit testing.

Restituisce

L'insieme degli oggetti Stroke che intersecano il punto specificato.

Esempio

Nell'esempio seguente viene illustrato come ottenere i tratti che intersecano l'oggetto specificato Point. In questo esempio si presuppone che sia presente un InkPresenter oggetto denominato 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

Si applica a