Share via


Rect.Contains Yöntem

Tanım

Dikdörtgenin belirtilen noktayı mı yoksa dikdörtgeni mi içerdiğini gösterir.

Aşırı Yüklemeler

Contains(Point)

Dikdörtgenin belirtilen noktayı içerip içermediğini gösterir.

Contains(Rect)

Dikdörtgenin belirtilen dikdörtgeni içerip içermediğini gösterir.

Contains(Double, Double)

Dikdörtgenin belirtilen x koordinatını ve y koordinatını içerip içermediğini gösterir.

Contains(Point)

Dikdörtgenin belirtilen noktayı içerip içermediğini gösterir.

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

Parametreler

point
Point

Denetlenecek nokta.

Döndürülenler

true dikdörtgen belirtilen noktayı içeriyorsa; aksi takdirde , false.

Örnekler

Aşağıdaki örnek, dikdörtgenin Contains(Point) belirtilen Pointöğesini içerip içermediğini belirlemek için yönteminin nasıl kullanılacağını gösterir.

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;
}

Şunlara uygulanır

Contains(Rect)

Dikdörtgenin belirtilen dikdörtgeni içerip içermediğini gösterir.

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

Parametreler

rect
Rect

Denetlenecek dikdörtgen.

Döndürülenler

truerect tamamen dikdörtgen tarafından kapsanırsa; değilse, false.

Örnekler

Aşağıdaki örnekte, bir dikdörtgenin Contains(Rect) başka bir dikdörtgen tarafından kapsandığını belirlemek için yönteminin nasıl kullanılacağı gösterilmektedir.

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;
}

Şunlara uygulanır

Contains(Double, Double)

Dikdörtgenin belirtilen x koordinatını ve y koordinatını içerip içermediğini gösterir.

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

Parametreler

x
Double

Denetlenecek noktanın x koordinatı.

y
Double

Denetlenecek noktanın y koordinatı.

Döndürülenler

true if (x, y) dikdörtgen tarafından kapsanırsa; değilse , false.

Örnekler

Aşağıdaki örnek, dikdörtgenin verilen x koordinatı Contains(Double, Double) ve y koordinatı tarafından belirtilen noktayı içerip içermediğini belirlemek için yönteminin nasıl kullanılacağını gösterir.

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;
}

Şunlara uygulanır