Share via


Stroke.HitTest Método

Definição

Retorna se o Stroke intercepta ou está dentro de uma determinada área.

Sobrecargas

HitTest(Point)

Retorna um valor que indica se o Stroke atual intersecciona o ponto especificado.

HitTest(IEnumerable<Point>, Int32)

Retorna um valor que indica se o Stroke atual está dentro dos limites especificados.

HitTest(IEnumerable<Point>, StylusShape)

Retorna se o caminho especificado intersecciona o Stroke usando o StylusShape especificado.

HitTest(Point, Double)

Retorna um valor que indica se o Stroke atual intersecciona a área especificada.

HitTest(Rect, Int32)

Retorna um valor que indica se o Stroke está dentro dos limites do retângulo especificado.

Comentários

Você pode usar os HitTest métodos para determinar se um Stroke ponto se cruza ou se está dentro dos limites especificados.

Os métodos a seguir verificam se a interseção Stroke foi intersecionada.

Os métodos a seguir verificam se o Stroke objeto está cercado.

HitTest(Point)

Retorna um valor que indica se o Stroke atual intersecciona o ponto especificado.

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

Parâmetros

point
Point

O Point ao qual será aplicado o teste de clique.

Retornos

Boolean

true se point intersecciona o traço atual, caso contrário, false.

Exemplos

O exemplo a seguir altera a cor de um Stroke se ele cruza uma determinada área.

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

Comentários

Esse método se comporta da mesma maneira que o método sobrecarregado HitTest(Point, Double) faz quando diameter é 1.

Aplica-se a

HitTest(IEnumerable<Point>, Int32)

Retorna um valor que indica se o Stroke atual está dentro dos limites especificados.

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

Parâmetros

lassoPoints
IEnumerable<Point>

Uma matriz do tipo Point que representa os limites da área que passará por teste de clique.

percentageWithinLasso
Int32

O percentual do tamanho do Stroke, que deve estar em lassoPoints para o Stroke ser considerado um clique.

Retornos

Boolean

true se o traço atual estiver dentro dos limites especificados, caso contrário, false.

Exemplos

O exemplo a seguir renderiza um traço roxo se pelo menos 80% do traço estiver dentro dos limites de 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

Comentários

O HitTest método conecta o primeiro e o último pontos lassoPoints para criar o laço.

Aplica-se a

HitTest(IEnumerable<Point>, StylusShape)

Retorna se o caminho especificado intersecciona o Stroke usando o StylusShape especificado.

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

Parâmetros

path
IEnumerable<Point>

O caminho a stylusShape seguir para teste de ocorrência.

stylusShape
StylusShape

A forma do path com a qual realizar o teste de clique.

Retornos

Boolean

true se stylusShape intersecciona o traço atual, caso contrário, false.

Exemplos

O código a seguir renderizará um traço roxo se o traço cruzar o caminho de 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

Comentários

O HitTest método usa stylusShape para testar o traço ao longo eraserPath.

Aplica-se a

HitTest(Point, Double)

Retorna um valor que indica se o Stroke atual intersecciona a área especificada.

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

Parâmetros

point
Point

O Point que define o centro da área que passará pelo teste de clique.

diameter
Double

O diâmetro da área que passará pelo teste de clique.

Retornos

Boolean

true se a área especificada intersecciona o traço atual, caso contrário, false.

Exemplos

O exemplo a seguir altera a cor de um Stroke se ele cruza uma determinada área.

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

Aplica-se a

HitTest(Rect, Int32)

Retorna um valor que indica se o Stroke está dentro dos limites do retângulo especificado.

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

Parâmetros

bounds
Rect

Um Rect que representa os limites da área que passará por teste de clique.

percentageWithinBounds
Int32

O percentual do tamanho do Stroke, que deve estar em percentageWithinBounds para o Stroke ser considerado um clique.

Retornos

Boolean

true se o traço atual estiver dentro dos limites de bounds, caso contrário, false.

Exemplos

O exemplo a seguir renderiza um traço roxo se pelo menos 80% do traço estiver dentro do 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

Aplica-se a