Rectangle.IsEmpty Proprietà

Definizione

Verifica se tutte le proprietà numeriche della struttura Rectangle hanno valori pari a zero.

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

Valore della proprietà

Questa proprietà restituisce true se le proprietà Width, Height, X e Y di questa struttura Rectangle hanno tutte valori pari a zero; in caso contrario, restituisce false.

Attributi

Esempio

Nell'esempio di codice seguente vengono illustrati i IntersectIsEmpty membri e IntersectsWith . Questo esempio deve essere usato con un Windows Form. Incollare questo codice in un modulo e chiamare questo metodo quando si gestisce l'evento del Paint modulo, passando e come PaintEventArgs.

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

Si applica a