Rect.Contains Rect.Contains Rect.Contains Rect.Contains Method

Definizione

Indica se il rettangolo contiene il punto o il rettangolo specificato.Indicates whether the rectangle contains the specified point or rectangle.

Overload

Contains(Point) Contains(Point) Contains(Point)

Indica se il rettangolo contiene il punto specificato.Indicates whether the rectangle contains the specified point.

Contains(Rect) Contains(Rect) Contains(Rect)

Indica se il rettangolo contiene il rettangolo specificato.Indicates whether the rectangle contains the specified rectangle.

Contains(Double, Double) Contains(Double, Double) Contains(Double, Double) Contains(Double, Double)

Indica se il rettangolo contiene le coordinate specificate x e y.Indicates whether the rectangle contains the specified x-coordinate and y-coordinate.

Contains(Point) Contains(Point) Contains(Point)

Indica se il rettangolo contiene il punto specificato.Indicates whether the rectangle contains the specified point.

public:
 bool Contains(System::Windows::Point point);
public bool Contains (System.Windows.Point point);
member this.Contains : System.Windows.Point -> bool

Parametri

point
Point Point Point Point

Punto da controllare.The point to check.

Restituisce

true se il rettangolo contiene il punto specificato; in caso contrario, false.true if the rectangle contains the specified point; otherwise, false.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Contains(Point) metodo per determinare se il rettangolo contiene l'oggetto specificato Point.The following example shows how to use the Contains(Point) method to determine if the rectangle contains the specified 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;

}

Contains(Rect) Contains(Rect) Contains(Rect)

Indica se il rettangolo contiene il rettangolo specificato.Indicates whether the rectangle contains the specified rectangle.

public:
 bool Contains(System::Windows::Rect rect);
public bool Contains (System.Windows.Rect rect);
member this.Contains : System.Windows.Rect -> bool

Parametri

rect
Rect Rect Rect Rect

Rettangolo da controllare.The rectangle to check.

Restituisce

true se rect è completamente contenuto dal rettangolo; in caso contrario, false.true if rect is entirely contained by the rectangle; otherwise, false.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Contains(Rect) metodo per determinare se un rettangolo è contenuto da un altro rettangolo.The following example shows how to use the Contains(Rect) method to determine if one rectangle is contained by another rectangle.

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;

}

Contains(Double, Double) Contains(Double, Double) Contains(Double, Double) Contains(Double, Double)

Indica se il rettangolo contiene le coordinate specificate x e y.Indicates whether the rectangle contains the specified x-coordinate and y-coordinate.

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

Parametri

x
Double Double Double Double

Coordinata x del punto da controllare.The x-coordinate of the point to check.

y
Double Double Double Double

Coordinata y del punto da controllare.The y-coordinate of the point to check.

Restituisce

true se (x, y) è contenuto dal rettangolo; in caso contrario, false.true if (x, y) is contained by the rectangle; otherwise, false.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Contains(Double, Double) metodo per determinare se il rettangolo contiene il punto specificato dalle coordinate specificate x e coordinata y.The following example shows how to use the Contains(Double, Double) method to determine if the rectangle contains the point specified by the given x-coordinate and y-coordinate.

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;

}

Si applica a