StrokeCollection.HitTest Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a collection of strokes contained within the specified area.
Overloads
HitTest(Rect, Int32) |
Returns a collection of strokes that have at least the specified percentage of length within the specified rectangle. |
HitTest(Point, Double) |
Returns a collection of strokes that intersect the specified area. |
HitTest(IEnumerable<Point>, StylusShape) |
Returns a collection of strokes that intersect with the specified path. |
HitTest(IEnumerable<Point>, Int32) |
Returns a collection of strokes that have at least the specified percentage of length within the specified area. |
HitTest(Point) |
Returns a collection of strokes that intersect the specified point. |
HitTest(Rect, Int32)
Returns a collection of strokes that have at least the specified percentage of length within the specified rectangle.
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
Parameters
- percentageWithinBounds
- Int32
The minimum required length of a Stroke that must exist within bounds for it to be considered hit.
Returns
A StrokeCollection that has strokes with at least the specified percentage within the Rect.
Examples
The following example erases the strokes that are at least 50% within the bounds of the Rect. This example assumes that there is an InkPresenter called 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)
Applies to
HitTest(Point, Double)
Returns a collection of strokes that intersect the specified area.
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
Parameters
Returns
A collection of Stroke objects that intersect the specified point.
Examples
The following example demonstrates how to get the strokes that intersect the specified Point. This example assumes that there is an InkPresenter called 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
Applies to
HitTest(IEnumerable<Point>, StylusShape)
Returns a collection of strokes that intersect with the specified path.
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
Parameters
- path
- IEnumerable<Point>
An array to type Point that represents the path to be hit tested.
- stylusShape
- StylusShape
The StylusShape that specifies the shape of eraserPath
.
Returns
A StrokeCollection of strokes that intersect with path
.
Examples
The following example changes the color of all the strokes that intersect the path that is created by the Point array. This example assumes that there is an InkPresenter called 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
Applies to
HitTest(IEnumerable<Point>, Int32)
Returns a collection of strokes that have at least the specified percentage of length within the specified area.
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
Parameters
- lassoPoints
- IEnumerable<Point>
An array of type Point that represents the bounds of the area to be hit tested.
- percentageWithinLasso
- Int32
The acceptable length of the Stroke, as a percentage, for lassoPoints
to contain.
Returns
A StrokeCollection that has strokes with at least the specified percentage within the Point array.
Exceptions
lassoPoints
contains an empty array.
percentageWithinLasso
is less than 0 or greater than 100.
Examples
The following example demonstrates how to remove all strokes that are at least 80 percent within the specified lasso from a StrokeCollection. This is useful when a custom control enables the user to select ink with a lasso. To create a control that enables a user to select ink with a lasso, see How to: Select Ink from a Custom Control.
// 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
Applies to
HitTest(Point)
Returns a collection of strokes that intersect the specified 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
Parameters
- point
- Point
The point to hit test.
Returns
A collection of Stroke objects that intersect the specified point.
Examples
The following example demonstrates how to get the strokes that intersect the specified Point. This example assumes that there is an InkPresenter called 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
Applies to
Atsauksmes
https://aka.ms/ContentUserFeedback.
Drīzumā: 2024. gada laikā mēs pakāpeniski pārtrauksim izmantot “GitHub problēmas” kā atsauksmju par saturu mehānismu un aizstāsim to ar jaunu atsauksmju sistēmu. Papildinformāciju skatiet:Iesniegt un skatīt atsauksmes par