Rect.Contains 메서드

정의

사각형에 지정된 점 또는 사각형이 포함되어 있는지 여부를 나타냅니다.

오버로드

Name Description
Contains(Point)

사각형에 지정된 점이 포함되어 있는지 여부를 나타냅니다.

Contains(Rect)

사각형에 지정된 사각형이 포함되어 있는지 여부를 나타냅니다.

Contains(Double, Double)

사각형에 지정된 x 좌표와 y 좌표가 포함되어 있는지 여부를 나타냅니다.

Contains(Point)

사각형에 지정된 점이 포함되어 있는지 여부를 나타냅니다.

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

매개 변수

point
Point

확인할 지점입니다.

반품

사각형에 지정된 점이 포함되어 있으면 이고, 그렇지 않으면 .

예제

다음 예제에서는 메서드를 사용하여 사각형에 Contains(Point) 지정된 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)

사각형에 지정된 사각형이 포함되어 있는지 여부를 나타냅니다.

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

매개 변수

rect
Rect

확인할 사각형입니다.

반품

직사각형에 의해 완전히 포함되면 이고, 그렇지 않으면 .입니다.

예제

다음 예제에서는 메서드를 사용 하 여 Contains(Rect) 한 사각형이 다른 사각형에 포함 되어 있는지 확인 하는 방법을 보여 집니다.

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)

사각형에 지정된 x 좌표와 y 좌표가 포함되어 있는지 여부를 나타냅니다.

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

매개 변수

x
Double

확인할 점의 x 좌표입니다.

y
Double

확인할 점의 y 좌표입니다.

반품

true (x, y)가 사각형에 포함되어 있으면 이고, false그렇지 않으면 .

예제

다음 예제에서는 메서드를 사용하여 Contains(Double, Double) 사각형에 지정된 x 좌표 및 y 좌표로 지정된 점이 포함되어 있는지 확인하는 방법을 보여 줍니다.

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

적용 대상