Idioma

Stroke.HitTest Método

Definição

Retorna quer o Stroke intersecte ou esteja dentro de uma determinada área.

Sobrecargas

Nome Descrição
HitTest(Point)

Devolve um valor que indica se a corrente Stroke intersecta o ponto especificado.

HitTest(IEnumerable<Point>, Int32)

Devolve um valor que indica se a corrente Stroke está dentro dos limites especificados.

HitTest(IEnumerable<Point>, StylusShape)

Devolve se o caminho especificado intersecta o Stroke usando o especificado StylusShape.

HitTest(Point, Double)

Devolve um valor que indica se a corrente Stroke intersecta a área especificada.

HitTest(Rect, Int32)

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

Observações

Pode usar os HitTest métodos para determinar se um Stroke intersecta um determinado ponto ou se está dentro de limites especificados.

Os métodos seguintes verificam se o Stroke está intersectado.

Os métodos seguintes verificam se o Stroke está rodeado.

HitTest(Point)

Devolve um valor que indica se a corrente Stroke intersecta 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 teste para acertar.

Devoluções

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

Exemplos

O exemplo seguinte altera a cor de um Stroke se este intersectar 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

Observações

Este método comporta-se da mesma forma que o método sobrecarregado HitTest(Point, Double) quando diameter é 1.

Aplica-se a

HitTest(IEnumerable<Point>, Int32)

Devolve um valor que indica se a corrente Stroke 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>

Um array de tipos Point que representa os limites da área a testar.

percentageWithinLasso
Int32

A percentagem do comprimento do Stroke, que deve estar em lassoPoints para que o Stroke seja considerado atingido.

Devoluções

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

Exemplos

O exemplo seguinte torna 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

Observações

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

Aplica-se a

HitTest(IEnumerable<Point>, StylusShape)

Devolve se o caminho especificado intersecta o Stroke usando o especificado 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

Parâmetros

path
IEnumerable<Point>

O caminho que stylusShape se segue para testes de acerto.

stylusShape
StylusShape

A forma com path que fazer o teste de acerto.

Devoluções

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

Exemplos

O código seguinte torna um traço roxo se o traço intersectar 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

Observações

O HitTest método é usado stylusShape para testar o golpe ao longo eraserPathde .

Aplica-se a

HitTest(Point, Double)

Devolve um valor que indica se a corrente Stroke intersecta 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 a fazer o teste de acerto.

diameter
Double

O diâmetro da área a testar.

Devoluções

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

Exemplos

O exemplo seguinte altera a cor de um Stroke se este intersectar 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)

Devolve 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

A Rect que representa os limites da área a testar.

percentageWithinBounds
Int32

A percentagem do comprimento do Stroke, que deve estar em percentageWithinBounds para que o Stroke seja considerado atingido.

Devoluções

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

Exemplos

O exemplo seguinte torna um traço roxo se pelo menos 80% do traço estiverem 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