StrokeCollection.HitTest Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Devuelve una colección de trazos contenidos en el área especificada.
Sobrecargas
| Nombre | Description |
|---|---|
| HitTest(Rect, Int32) |
Devuelve una colección de trazos que tienen al menos el porcentaje de longitud especificado dentro del rectángulo especificado. |
| HitTest(Point, Double) |
Devuelve una colección de trazos que intersecan el área especificada. |
| HitTest(IEnumerable<Point>, StylusShape) |
Devuelve una colección de trazos que se intersecan con la ruta de acceso especificada. |
| HitTest(IEnumerable<Point>, Int32) |
Devuelve una colección de trazos que tienen al menos el porcentaje de longitud especificado dentro del área especificada. |
| HitTest(Point) |
Devuelve una colección de trazos que intersecan el punto especificado. |
HitTest(Rect, Int32)
Devuelve una colección de trazos que tienen al menos el porcentaje de longitud especificado dentro del rectángulo especificado.
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
Parámetros
- percentageWithinBounds
- Int32
Longitud mínima necesaria de un trazo que debe existir dentro de los límites para que se considere acierto.
Devoluciones
que StrokeCollection tiene trazos con al menos el porcentaje especificado dentro de .Rect
Ejemplos
En el ejemplo siguiente se borran los trazos que son al menos 50% dentro de los límites de Rect. En este ejemplo se supone que hay un InkPresenter denominado 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)
Se aplica a
HitTest(Point, Double)
Devuelve una colección de trazos que intersecan el área especificada.
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
Parámetros
Devoluciones
Colección de Stroke objetos que intersecan el punto especificado.
Ejemplos
En el ejemplo siguiente se muestra cómo obtener los trazos que intersecan el especificado Point. En este ejemplo se supone que hay un InkPresenter denominado 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
Se aplica a
HitTest(IEnumerable<Point>, StylusShape)
Devuelve una colección de trazos que se intersecan con la ruta de acceso especificada.
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
Parámetros
- path
- IEnumerable<Point>
Matriz que se va a escribir Point que representa la ruta de acceso que se va a probar.
- stylusShape
- StylusShape
StylusShape que especifica la forma de eraserPath.
Devoluciones
de StrokeCollection trazos que se intersecan con path.
Ejemplos
En el ejemplo siguiente se cambia el color de todos los trazos que intersecan la ruta de acceso creada por la Point matriz. En este ejemplo se supone que hay un InkPresenter denominado 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
Se aplica a
HitTest(IEnumerable<Point>, Int32)
Devuelve una colección de trazos que tienen al menos el porcentaje de longitud especificado dentro del área especificada.
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
Parámetros
- lassoPoints
- IEnumerable<Point>
Matriz de tipo Point que representa los límites del área que se van a probar.
- percentageWithinLasso
- Int32
Longitud aceptable de Stroke, como porcentaje, para lassoPoints que contenga.
Devoluciones
que StrokeCollection tiene trazos con al menos el porcentaje especificado dentro de la Point matriz.
Excepciones
lassoPoints contiene una matriz vacía.
percentageWithinLasso es menor que 0 o mayor que 100.
Ejemplos
En el ejemplo siguiente se muestra cómo quitar todos los trazos que son al menos el 80 % dentro del lazo especificado de un StrokeCollection. Esto resulta útil cuando un control personalizado permite al usuario seleccionar la entrada de lápiz con una lazo. Para crear un control que permita a un usuario seleccionar la entrada de lápiz con una lazo, vea Cómo: Seleccionar entrada de lápiz desde un control personalizado.
// 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
Se aplica a
HitTest(Point)
Devuelve una colección de trazos que intersecan el punto especificado.
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
Parámetros
- point
- Point
Punto a la prueba de posicionamiento.
Devoluciones
Colección de Stroke objetos que intersecan el punto especificado.
Ejemplos
En el ejemplo siguiente se muestra cómo obtener los trazos que intersecan el especificado Point. En este ejemplo se supone que hay un InkPresenter denominado 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