Rectangle.IsEmptyRectangle.IsEmptyRectangle.IsEmptyRectangle.IsEmpty Property

Definição

Testa se todas as propriedades numéricas deste Rectangle têm valores de zero.Tests whether all numeric properties of this Rectangle have values of zero.

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

Essa propriedade retorna `true` Widthse as X Height PropriedadesY ,, e `false`de Rectangle tudo tiverem valores de zero; caso contrário,.This property returns `true` if the Width, Height, X, and Y properties of this Rectangle all have values of zero; otherwise, `false`.

Exemplos

O exemplo de código a seguir Intersectdemonstra IsEmpty o e IntersectsWith os membros.The following code example demonstrates the Intersect, IsEmpty and the IntersectsWith members. Este exemplo deve ser usado com um Windows Form.This example should be used with a Windows Form. Cole este código em um formulário e chame esse método ao manipular o evento do Paint formulário, passando `e` como PaintEventArgs.Paste this code into a form and call this method when handling the form's Paint event, passing `e` as 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
``````