Idioma

Stroke.HitTest Método

Definição

Retorna se os Stroke intersecções ou se estão dentro de uma determinada área.

Sobrecargas

Nome Descrição
HitTest(Point)

Retorna um valor que indica se a corrente Stroke cruza o ponto especificado.

HitTest(IEnumerable<Point>, Int32)

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

HitTest(IEnumerable<Point>, StylusShape)

Retorna se o caminho especificado interseciona o Stroke uso do .StylusShape

HitTest(Point, Double)

Retorna um valor que indica se a atual Stroke cruza 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 está dentro dos limites especificados.

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

Os métodos a seguir verificam se eles Stroke estão cercados.

HitTest(Point)

Retorna um valor que indica se a corrente Stroke cruza 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 de ocorrência.

Retornos

true se point cruza 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 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>

Uma matriz de tipo Point que representa os limites da área a ser atingida no teste.

percentageWithinLasso
Int32

O percentual do comprimento do Stroke, que deve estar dentro lassoPoints para que o Stroke acerto seja considerado.

Retornos

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 interseciona o Stroke uso do .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 a stylusShape seguir para o teste de ocorrência.

stylusShape
StylusShape

A forma da path qual o teste será atingido.

Retornos

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

Exemplos

O código a seguir renderiza um traço roxo se o traço cruza 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 atingir o teste de traço ao longo eraserPath.

Aplica-se a

HitTest(Point, Double)

Retorna um valor que indica se a atual Stroke cruza 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 ser atingida no teste.

diameter
Double

O diâmetro da área a ser atingida pelo teste.

Retornos

true se a área especificada cruza 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 a ser atingida no teste.

percentageWithinBounds
Int32

O percentual do comprimento do Stroke, que deve estar dentro percentageWithinBounds para que o Stroke acerto seja considerado.

Retornos

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