Rect.Contains Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Indica se o retângulo contém o ponto ou retângulo especificado.
Sobrecargas
| Name | Descrição |
|---|---|
| Contains(Point) |
Indica se o retângulo contém o ponto especificado. |
| Contains(Rect) |
Indica se o retângulo contém o retângulo especificado. |
| Contains(Double, Double) |
Indica se o retângulo contém as coordenadas x e y especificadas. |
Contains(Point)
Indica se o retângulo contém o ponto especificado.
public:
bool Contains(System::Windows::Point point);
public bool Contains(System.Windows.Point point);
member this.Contains : System.Windows.Point -> bool
Public Function Contains (point As Point) As Boolean
Parâmetros
- point
- Point
O ponto a verificar.
Devoluções
true se o retângulo contiver o ponto especificado; caso contrário, false.
Exemplos
O exemplo seguinte mostra como usar o Contains(Point) método para determinar se o retângulo contém o especificado Point.
private bool rectContainsExample1()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Using the Contains method, see if the rectangle contains the specified
// point. doesContain is true because the point is inside of myRectangle.
bool doesContain = myRectangle.Contains(new Point(13, 30));
return doesContain;
}
Aplica-se a
Contains(Rect)
Indica se o retângulo contém o retângulo especificado.
public:
bool Contains(System::Windows::Rect rect);
public bool Contains(System.Windows.Rect rect);
member this.Contains : System.Windows.Rect -> bool
Public Function Contains (rect As Rect) As Boolean
Parâmetros
- rect
- Rect
O retângulo para verificar.
Devoluções
true se rect estiver inteiramente contido pelo retângulo; caso contrário, false.
Exemplos
O exemplo seguinte mostra como usar o Contains(Rect) método para determinar se um retângulo está contido por outro retângulo.
private bool rectContainsExample2()
{
// Create a rectangle.
Rect myRectangle1 = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle1.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle1.Size = new Size(200, 50);
// Create second rectangle.
Rect myRectangle2 = new Rect();
myRectangle2.Location = new Point(12, 12);
myRectangle2.Size = new Size(10, 60);
// Using the Contains method, see if the second rectangle is
// contained within the first rectangle. doesContain is false
// because only part of myRectangle2 is contained in myRectangle1
// (myRectangle2 is too wide).
bool doesContain = myRectangle1.Contains(myRectangle2);
return doesContain;
}
Aplica-se a
Contains(Double, Double)
Indica se o retângulo contém as coordenadas x e y especificadas.
public:
bool Contains(double x, double y);
public bool Contains(double x, double y);
member this.Contains : double * double -> bool
Public Function Contains (x As Double, y As Double) As Boolean
Parâmetros
- x
- Double
A coordenada x do ponto a verificar.
- y
- Double
A coordenada y do ponto a verificar.
Devoluções
true se (x, y) está contido pelo retângulo; caso contrário, false.
Exemplos
O exemplo seguinte mostra como usar o Contains(Double, Double) método para determinar se o retângulo contém o ponto especificado pelas coordenadas x e y dadas.
private bool rectContainsExample3()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Using the Contains method, see if the rectangle contains the specified
// point specified by the given X and Y coordinates. doesContain is false
// because the X and Y coordinates specify a point outside of myRectangle.
bool doesContain = myRectangle.Contains(4, 13);
return doesContain;
}