StrokeCollection.HitTest Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Returnerar en samling linjer som finns inom det angivna området.
Överlagringar
| Name | Description |
|---|---|
| HitTest(Rect, Int32) |
Returnerar en samling linjer som har minst den angivna procentandelen längd inom den angivna rektangeln. |
| HitTest(Point, Double) |
Returnerar en samling linjer som korsar det angivna området. |
| HitTest(IEnumerable<Point>, StylusShape) |
Returnerar en samling linjer som korsar den angivna sökvägen. |
| HitTest(IEnumerable<Point>, Int32) |
Returnerar en samling linjer som har minst den angivna procentandelen längd inom det angivna området. |
| HitTest(Point) |
Returnerar en samling linjer som korsar den angivna punkten. |
HitTest(Rect, Int32)
Returnerar en samling linjer som har minst den angivna procentandelen längd inom den angivna rektangeln.
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
Parametrar
- percentageWithinBounds
- Int32
Den minsta längd som krävs för ett slag som måste finnas inom gränserna för att den ska anses träffad.
Returer
En StrokeCollection som har linjer med minst den angivna procentandelen Recti .
Exempel
I följande exempel raderas de linjer som är minst 50% inom gränserna för Rect. Det här exemplet förutsätter att det finns en InkPresenter som heter 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)
Gäller för
HitTest(Point, Double)
Returnerar en samling linjer som korsar det angivna området.
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
Parametrar
Returer
En samling Stroke objekt som korsar den angivna punkten.
Exempel
I följande exempel visas hur du hämtar de linjer som korsar den angivna Point. Det här exemplet förutsätter att det finns en InkPresenter som heter 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
Gäller för
HitTest(IEnumerable<Point>, StylusShape)
Returnerar en samling linjer som korsar den angivna sökvägen.
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
Parametrar
- path
- IEnumerable<Point>
En matris som ska skrivas Point som representerar sökvägen som ska tryckas på testad.
- stylusShape
- StylusShape
Som StylusShape anger formen på eraserPath.
Returer
En StrokeCollection av slag som korsar med path.
Exempel
I följande exempel ändras färgen på alla linjer som korsar sökvägen som skapas av matrisen Point . Det här exemplet förutsätter att det finns en InkPresenter som heter 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
Gäller för
HitTest(IEnumerable<Point>, Int32)
Returnerar en samling linjer som har minst den angivna procentandelen längd inom det angivna området.
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
Parametrar
- lassoPoints
- IEnumerable<Point>
En matris av typen Point som representerar gränserna för det område som ska träffas testas.
- percentageWithinLasso
- Int32
Den acceptabla längden för Stroke, som en procentandel, för lassoPoints att innehålla.
Returer
En StrokeCollection som har linjer med minst den angivna procentandelen i matrisen Point .
Undantag
lassoPoints innehåller en tom matris.
percentageWithinLasso är mindre än 0 eller större än 100.
Exempel
I följande exempel visas hur du tar bort alla linjer som är minst 80 procent inom den angivna lasso från en StrokeCollection. Detta är användbart när en anpassad kontroll gör det möjligt för användaren att välja pennanteckning med en lasso. Om du vill skapa en kontroll som gör det möjligt för en användare att välja pennanteckning med en lasso läser du Så här: Välj pennanteckning från en anpassad kontroll.
// 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
Gäller för
HitTest(Point)
Returnerar en samling linjer som korsar den angivna punkten.
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
Parametrar
- point
- Point
Poängen att träffa testet.
Returer
En samling Stroke objekt som korsar den angivna punkten.
Exempel
I följande exempel visas hur du hämtar de linjer som korsar den angivna Point. Det här exemplet förutsätter att det finns en InkPresenter som heter 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