Rectangle.IsEmpty 속성

정의

Rectangle의 숫자 속성이 모두 0 값을 갖는지 여부를 테스트합니다.

public:
 property bool IsEmpty { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool IsEmpty { get; }
public bool IsEmpty { get; }
[<System.ComponentModel.Browsable(false)>]
member this.IsEmpty : bool
member this.IsEmpty : bool
Public ReadOnly Property IsEmpty As Boolean

속성 값

WidthHeight, X, YRectangle 속성이 모두 0 값을 가지면 이 속성이 true를 반환하고 그렇지 않으면 false를 반환합니다.

특성

예제

다음 코드 예제에서는 Intersect, IsEmpty 및 멤버입니다 IntersectsWith . 이 예제는 Windows Form과 함께 사용해야 합니다. 이 코드를 양식에 붙여넣고 양식의 Paint 이벤트를 처리할 때 이 메서드를 호출하여 로 PaintEventArgs전달합니다e.

private:
   void InstanceRectangleIntersection( PaintEventArgs^ e )
   {
      Rectangle rectangle1 = Rectangle(50,50,200,100);
      Rectangle rectangle2 = Rectangle(70,20,100,200);
      e->Graphics->DrawRectangle( Pens::Black, rectangle1 );
      e->Graphics->DrawRectangle( Pens::Red, rectangle2 );
      if ( rectangle1.IntersectsWith( rectangle2 ) )
      {
         rectangle1.Intersect( rectangle2 );
         if (  !rectangle1.IsEmpty )
         {
            e->Graphics->FillRectangle( Brushes::Green, rectangle1 );
         }
      }
   }
private void InstanceRectangleIntersection(PaintEventArgs e)
{

    Rectangle rectangle1 = new Rectangle(50, 50, 200, 100);
    Rectangle rectangle2 = new Rectangle(70, 20, 100, 200);

    e.Graphics.DrawRectangle(Pens.Black, rectangle1);
    e.Graphics.DrawRectangle(Pens.Red, rectangle2);

    if (rectangle1.IntersectsWith(rectangle2))
    {
        rectangle1.Intersect(rectangle2);
        if (!rectangle1.IsEmpty)
        {
            e.Graphics.FillRectangle(Brushes.Green, rectangle1);
        }
    }
}
  Private Sub InstanceRectangleIntersection( _
      ByVal e As PaintEventArgs)

      Dim rectangle1 As New Rectangle(50, 50, 200, 100)
      Dim rectangle2 As New Rectangle(70, 20, 100, 200)

      e.Graphics.DrawRectangle(Pens.Black, rectangle1)
      e.Graphics.DrawRectangle(Pens.Red, rectangle2)

      If (rectangle1.IntersectsWith(rectangle2)) Then
          rectangle1.Intersect(rectangle2)
          If Not (rectangle1.IsEmpty) Then
              e.Graphics.FillRectangle(Brushes.Green, rectangle1)
          End If
      End If
  End Sub

적용 대상