Stroke.HitTest Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un valore che indica se l'oggetto Stroke si interseca o si trova all'interno di una determinata area.
Overload
| Nome | Descrizione |
|---|---|
| HitTest(Point) |
Restituisce un valore che indica se l'oggetto corrente Stroke interseca il punto specificato. |
| HitTest(IEnumerable<Point>, Int32) |
Restituisce un valore che indica se l'oggetto corrente Stroke si trova all'interno dei limiti specificati. |
| HitTest(IEnumerable<Point>, StylusShape) |
Restituisce un valore che indica se il percorso specificato interseca l'oggetto Stroke utilizzando l'oggetto specificato StylusShape. |
| HitTest(Point, Double) |
Restituisce un valore che indica se l'oggetto corrente Stroke interseca l'area specificata. |
| HitTest(Rect, Int32) |
Restituisce un valore che indica se l'oggetto Stroke si trova all'interno dei limiti del rettangolo specificato. |
Commenti
È possibile utilizzare i HitTest metodi per determinare se un Stroke oggetto interseca un determinato punto o si trova all'interno di limiti specificati.
I metodi seguenti controllano se l'oggetto Stroke è intersecato.
I metodi seguenti controllano se l'oggetto Stroke è racchiuso.
HitTest(Point)
Restituisce un valore che indica se l'oggetto corrente Stroke interseca il punto specificato.
public:
bool HitTest(System::Windows::Point point);
public bool HitTest(System.Windows.Point point);
member this.HitTest : System.Windows.Point -> bool
Public Function HitTest (point As Point) As Boolean
Parametri
Valori restituiti
true se point interseca il tratto corrente; in caso contrario, false.
Esempio
Nell'esempio seguente viene modificato il colore di un oggetto Stroke se interseca una determinata area.
Point myPoint = new Point(100, 100);
if (myStroke.HitTest(myPoint, 10))
{
myStroke.DrawingAttributes.Color = Colors.Red;
}
Dim myPoint As New System.Windows.Point(100, 100)
If myStroke.HitTest(myPoint, 10) Then
myStroke.DrawingAttributes.Color = Colors.Red
End If
Commenti
Questo metodo si comporta allo stesso modo del metodo di overload HitTest(Point, Double) quando diameter è 1.
Si applica a
HitTest(IEnumerable<Point>, Int32)
Restituisce un valore che indica se l'oggetto corrente Stroke si trova all'interno dei limiti specificati.
public:
bool HitTest(System::Collections::Generic::IEnumerable<System::Windows::Point> ^ lassoPoints, int percentageWithinLasso);
public bool HitTest(System.Collections.Generic.IEnumerable<System.Windows.Point> lassoPoints, int percentageWithinLasso);
member this.HitTest : seq<System.Windows.Point> * int -> bool
Public Function HitTest (lassoPoints As IEnumerable(Of Point), percentageWithinLasso As Integer) As Boolean
Parametri
- lassoPoints
- IEnumerable<Point>
Matrice di tipo Point che rappresenta i limiti dell'area da eseguire per l'hit test.
- percentageWithinLasso
- Int32
Percentuale della lunghezza di Stroke, che deve essere in lassoPoints per Stroke essere considerata hit.
Valori restituiti
true se il tratto corrente si trova all'interno dei limiti specificati; in caso contrario false, .
Esempio
Nell'esempio seguente viene eseguito il rendering di un tratto viola se almeno 80% del tratto si trova all'interno dei limiti di myPoints.
Point[] myPoints = new Point[] {
new Point(100, 100),
new Point(200, 100),
new Point(200, 200),
new Point(100, 200)};
if (aStroke.HitTest(myPoints, 80))
{
aStroke.DrawingAttributes.Color = Colors.Purple;
}
Dim myPoints() As System.Windows.Point = _
{New System.Windows.Point(100, 100), _
New System.Windows.Point(200, 100), _
New System.Windows.Point(200, 200), _
New System.Windows.Point(100, 200)}
If aStroke.HitTest(myPoints, 80) Then
aStroke.DrawingAttributes.Color = Colors.Purple
End If
Commenti
Il HitTest metodo connette il primo e l'ultimo punto in lassoPoints per creare il lasso.
Si applica a
HitTest(IEnumerable<Point>, StylusShape)
Restituisce un valore che indica se il percorso specificato interseca l'oggetto Stroke utilizzando l'oggetto specificato StylusShape.
public:
bool HitTest(System::Collections::Generic::IEnumerable<System::Windows::Point> ^ path, System::Windows::Ink::StylusShape ^ stylusShape);
public bool 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 -> bool
Public Function HitTest (path As IEnumerable(Of Point), stylusShape As StylusShape) As Boolean
Parametri
- path
- IEnumerable<Point>
Percorso che stylusShape segue per l'hit testing.
- stylusShape
- StylusShape
Forma di path con cui eseguire l'hit test.
Valori restituiti
true se stylusShape interseca il tratto corrente; in caso contrario, false.
Esempio
Il codice seguente esegue il rendering di un tratto viola se il tratto interseca il percorso di myPoints.
Point[] myPoints = new Point[] {
new Point(100, 100),
new Point(200, 100),
new Point(200, 200),
new Point(100, 200)};
EllipseStylusShape myStylus = new EllipseStylusShape(5.0, 5.0, 0.0);
if (aStroke.HitTest(myPoints, myStylus))
{
aStroke.DrawingAttributes.Color = Colors.Purple;
}
Dim myPoints() As System.Windows.Point = _
{New System.Windows.Point(100, 100), _
New System.Windows.Point(200, 100), _
New System.Windows.Point(200, 200), _
New System.Windows.Point(100, 200)}
Dim myStylus As New EllipseStylusShape(5.0, 5.0, 0.0)
If aStroke.HitTest(myPoints, myStylus) Then
aStroke.DrawingAttributes.Color = Colors.Purple
End If
Commenti
Il HitTest metodo usa stylusShape per eseguire il hit test del tratto lungo eraserPath.
Si applica a
HitTest(Point, Double)
Restituisce un valore che indica se l'oggetto corrente Stroke interseca l'area specificata.
public:
bool HitTest(System::Windows::Point point, double diameter);
public bool HitTest(System.Windows.Point point, double diameter);
member this.HitTest : System.Windows.Point * double -> bool
Public Function HitTest (point As Point, diameter As Double) As Boolean
Parametri
- diameter
- Double
Diametro dell'area da testare.
Valori restituiti
true se l'area specificata interseca il tratto corrente; in caso contrario, false.
Esempio
Nell'esempio seguente viene modificato il colore di un oggetto Stroke se interseca una determinata area.
Point myPoint = new Point(100, 100);
if (myStroke.HitTest(myPoint, 10))
{
myStroke.DrawingAttributes.Color = Colors.Red;
}
Dim myPoint As New System.Windows.Point(100, 100)
If myStroke.HitTest(myPoint, 10) Then
myStroke.DrawingAttributes.Color = Colors.Red
End If
Si applica a
HitTest(Rect, Int32)
Restituisce un valore che indica se l'oggetto Stroke si trova all'interno dei limiti del rettangolo specificato.
public:
bool HitTest(System::Windows::Rect bounds, int percentageWithinBounds);
public bool HitTest(System.Windows.Rect bounds, int percentageWithinBounds);
member this.HitTest : System.Windows.Rect * int -> bool
Public Function HitTest (bounds As Rect, percentageWithinBounds As Integer) As Boolean
Parametri
- percentageWithinBounds
- Int32
Percentuale della lunghezza di Stroke, che deve essere in percentageWithinBounds per Stroke essere considerata hit.
Valori restituiti
true se il tratto corrente si trova all'interno dei limiti di bounds; in caso contrario, false.
Esempio
Nell'esempio seguente viene eseguito il rendering di un tratto viola se almeno 80% del tratto si trova all'interno di Rect.
Rect rect1 = new Rect(100, 100, 100, 100);
if (aStroke.HitTest(rect1, 80))
{
aStroke.DrawingAttributes.Color = Colors.Purple;
}
Dim rect1 As New Rect(100, 100, 100, 100)
If aStroke.HitTest(rect1, 80) Then
aStroke.DrawingAttributes.Color = Colors.Purple
End If