RectangleF.Equality(RectangleF, RectangleF) RectangleF.Equality(RectangleF, RectangleF) RectangleF.Equality(RectangleF, RectangleF) RectangleF.Equality(RectangleF, RectangleF) Operator

Определение

Проверяет, имеют ли две структуры RectangleF одинаковое положение и размер.Tests whether two RectangleF structures have equal location and size.

public:
 static bool operator ==(System::Drawing::RectangleF left, System::Drawing::RectangleF right);
public static bool operator == (System.Drawing.RectangleF left, System.Drawing.RectangleF right);
static member ( = ) : System.Drawing.RectangleF * System.Drawing.RectangleF -> bool
Public Shared Operator == (left As RectangleF, right As RectangleF) As Boolean

Параметры

left
RectangleF RectangleF RectangleF RectangleF

Структура RectangleF, которая находится слева от оператора равенства.The RectangleF structure that is to the left of the equality operator.

right
RectangleF RectangleF RectangleF RectangleF

Структура RectangleF, которая находится справа от оператора равенства.The RectangleF structure that is to the right of the equality operator.

Возвраты

Значение true, если у двух заданных структур RectangleF равны свойства X, Y, Width и Height; в противном случае — значение false.true if the two specified RectangleF structures have equal X, Y, Width, and Height properties; otherwise, false.

Примеры

В следующем примере кода показано Implicit, RectangleF как использовать элементы и Equality .The following code example demonstrates how to use the Implicit, RectangleF and Equality members. Этот пример предназначен для использования с Windows Form.This example is designed for use with a Windows Form. Вставьте этот код в форму и вызовите ConvertRectangleToRectangleF метод при обработке Paint события формы, передав e его как PaintEventArgs.Paste this code into a form and call the ConvertRectangleToRectangleF method when handling the form's Paint event, passing e as PaintEventArgs.

private:
   void ConvertRectangleToRectangleF( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rectangle1 = Rectangle(30,40,50,100);

      // Convert it to a RectangleF.
      RectangleF convertedRectangle = rectangle1;

      // Create a new RectangleF.
      RectangleF rectangle2 = RectangleF(PointF(30.0F,40.0F),SizeF(50.0F,100.0F));

      // Create a custom, partially transparent brush.
      SolidBrush^ redBrush = gcnew SolidBrush( Color::FromArgb( 40, Color::Red ) );

      // Compare the converted rectangle with the new one.  If they 
      // are equal draw and fill the rectangles on the form.
      if ( convertedRectangle == rectangle2 )
      {
         e->Graphics->FillRectangle( redBrush, rectangle2 );
      }

      // Dispose of the custom brush.
      delete redBrush;
   }
};
private void ConvertRectangleToRectangleF(PaintEventArgs e)
{

    // Create a rectangle.
    Rectangle rectangle1 = new Rectangle(30, 40, 50, 100);

    // Convert it to a RectangleF.
    RectangleF convertedRectangle = rectangle1;

    // Create a new RectangleF.
    RectangleF rectangle2 = new RectangleF(new PointF(30.0F, 40.0F),
        new SizeF(50.0F, 100.0F));

    // Create a custom, partially transparent brush.
    SolidBrush redBrush = new SolidBrush(Color.FromArgb(40, Color.Red));

    // Compare the converted rectangle with the new one.  If they 
    // are equal draw and fill the rectangles on the form.
    if (convertedRectangle == rectangle2)
    {
        e.Graphics.FillRectangle(redBrush, rectangle2);
    }

    // Dispose of the custom brush.
    redBrush.Dispose();
}

Private Sub ConvertRectangleToRectangleF( _
    ByVal e As PaintEventArgs)

    ' Create a rectangle.
    Dim rectangle1 As New Rectangle(30, 40, 50, 100)

    ' Convert it to a RectangleF.
    Dim convertedRectangle As RectangleF = _
        RectangleF.op_Implicit(rectangle1)

    ' Create a new RectangleF.
    Dim rectangle2 As New RectangleF(New PointF(30.0F, 40.0F), _
        New SizeF(50.0F, 100.0F))

    ' Create a custom, partially transparent brush.
    Dim redBrush As New SolidBrush(Color.FromArgb(40, Color.Red))

    ' Compare the converted rectangle with the new one.  If they 
    ' are equal, draw and fill the rectangles on the form.
    If (RectangleF.op_Equality(convertedRectangle, rectangle2)) Then
        e.Graphics.FillRectangle(redBrush, rectangle2)
    End If

    ' Dispose of the custom brush.
    redBrush.Dispose()
End Sub

Применяется к