Rectangle.Contains 메서드

정의

지정된 점이 이 Rectangle에 의해 정의된 사각형 영역 안에 들어 있는지 여부를 확인합니다.

오버로드

Contains(Point)

지정된 점이 이 Rectangle 구조체에 들어 있는지 여부를 확인합니다.

Contains(Rectangle)

rect에 의해 표시된 사각형 영역이 이 Rectangle 구조체에 완전히 들어 있는지 여부를 확인합니다.

Contains(Int32, Int32)

지정된 점이 이 Rectangle 구조체에 들어 있는지 여부를 확인합니다.

Contains(Point)

Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs

지정된 점이 이 Rectangle 구조체에 들어 있는지 여부를 확인합니다.

public:
 bool Contains(System::Drawing::Point pt);
public readonly bool Contains (System.Drawing.Point pt);
public bool Contains (System.Drawing.Point pt);
member this.Contains : System.Drawing.Point -> bool
Public Function Contains (pt As Point) As Boolean

매개 변수

pt
Point

테스트할 Point입니다.

반환

pt에 의해 표시된 점이 이 Rectangle 구조체 안에 들어 있으면 이 메서드는 true를 반환하고 그러지 않으면 false를 반환합니다.

설명

이 메서드가 정확한 결과를 반환하려면 포함하는 사각형을 정규화해야 합니다.

적용 대상

Contains(Rectangle)

Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs

rect에 의해 표시된 사각형 영역이 이 Rectangle 구조체에 완전히 들어 있는지 여부를 확인합니다.

public:
 bool Contains(System::Drawing::Rectangle rect);
public readonly bool Contains (System.Drawing.Rectangle rect);
public bool Contains (System.Drawing.Rectangle rect);
member this.Contains : System.Drawing.Rectangle -> bool
Public Function Contains (rect As Rectangle) As Boolean

매개 변수

rect
Rectangle

테스트할 Rectangle입니다.

반환

rect에 의해 표시된 사각형 영역이 이 Rectangle 구조체 안에 완전히 들어 있으면 이 메서드는 true를 반환하고 그러지 않으면 false를 반환합니다.

예제

다음 코드 예제에서는 Contains 메서드 및 클래스를 보여 줍니다 SystemPens . 이 예제는 Windows Form에서 사용하도록 설계되었습니다. 이 코드를 라는 단추Button1가 포함된 폼에 붙여넣고, 폼의 생성자 또는 Load 메서드에서 를 호출 DrawFirstRectangle 하고, 메서드를 Button1_Click 단추의 Click 이벤트와 연결합니다.

private:
   [UIPermission(SecurityAction::Demand, Window=UIPermissionWindow::AllWindows)]
   void DrawFirstRectangle()
   {
      Rectangle rectangle1 = Rectangle(70,70,100,150);
      ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
   }

   void Button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      Rectangle rectangle1 = Rectangle(70,70,100,150);

      // Get the bounds of the screen.
      Rectangle screenRectangle = Screen::PrimaryScreen->Bounds;

      // Check to see if the rectangle is within the bounds of the screen.
      if ( screenRectangle.Contains( rectangle1 ) )
      {
         ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );

         // Call the Offset method to move the rectangle.
         rectangle1.Offset( 20, 20 );

         // Draw the new, offset rectangle.
         ControlPaint::DrawReversibleFrame( rectangle1, SystemColors::Highlight, FrameStyle::Thick );
      }
   }
Rectangle rectangle1 = new Rectangle(70, 70, 100, 150);

private void DrawFirstRectangle()
{
    ControlPaint.DrawReversibleFrame(rectangle1, 
        SystemColors.Highlight, FrameStyle.Thick);
}

private void Button1_Click(object sender, EventArgs e)
{

    // Get the bounds of the screen.
    Rectangle screenRectangle = Screen.PrimaryScreen.Bounds;

    // Check to see if the rectangle is within the bounds of the screen.
    if (screenRectangle.Contains(rectangle1))

        // If so, erase the previous rectangle.
    {
        ControlPaint.DrawReversibleFrame(rectangle1, 
            SystemColors.Highlight, FrameStyle.Thick);

        // Call the Offset method to move the rectangle.
        rectangle1.Offset(20, 20);

        // Draw the new, offset rectangle.
        ControlPaint.DrawReversibleFrame(rectangle1, 
            SystemColors.Highlight, FrameStyle.Thick);
    }
}
Dim rectangle1 As New Rectangle(70, 70, 100, 150)

Private Sub DrawFirstRectangle()
    ControlPaint.DrawReversibleFrame(rectangle1, _
        SystemColors.Highlight, FrameStyle.Thick)
End Sub

Private Sub Button1_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Button1.Click

    ' Get the bounds of the screen.
    Dim screenRectangle As Rectangle = Screen.PrimaryScreen.Bounds

    ' Check to see if the rectangle is within the bounds of the screen.
    If (screenRectangle.Contains(rectangle1)) Then

        ' If so, erase the previous rectangle.
        ControlPaint.DrawReversibleFrame(rectangle1, _
            SystemColors.Highlight, FrameStyle.Thick)

        ' Call the Offset method to move the rectangle.
        rectangle1.Offset(20, 20)

        ' Draw the new, offset rectangle.
        ControlPaint.DrawReversibleFrame(rectangle1, _
            SystemColors.Highlight, FrameStyle.Thick)
    End If
End Sub

설명

이 메서드가 정확한 결과를 반환하려면 포함하는 사각형을 정규화해야 합니다.

적용 대상

Contains(Int32, Int32)

Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs

지정된 점이 이 Rectangle 구조체에 들어 있는지 여부를 확인합니다.

public:
 bool Contains(int x, int y);
public readonly bool Contains (int x, int y);
public bool Contains (int x, int y);
member this.Contains : int * int -> bool
Public Function Contains (x As Integer, y As Integer) As Boolean

매개 변수

x
Int32

테스트할 점의 x좌표입니다.

y
Int32

테스트할 점의 y좌표입니다.

반환

xy에 의해 정의된 점이 이 Rectangle 구조체 안에 들어 있으면 이 메서드는 true를 반환하고, 그러지 않으면 false를 반환합니다.

설명

이 메서드가 정확한 결과를 반환하려면 포함하는 사각형을 정규화해야 합니다.

적용 대상