다음을 통해 공유


RectangleF.Equality(RectangleF, RectangleF) 연산자

정의

RectangleF 구조체가 동일한 위치와 크기를 갖는지 여부를 테스트합니다.

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 구조체입니다.

right
RectangleF

같음 연산자의 오른쪽에 있는 RectangleF 구조체입니다.

반환

두 개의 지정된 RectangleF 구조체에 동일한 X, Y, WidthHeight 속성이 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제를 사용 Implicit하는 방법에 설명 합니다 , RectangleFEquality 멤버입니다. 이 예제는 Windows Form에서 사용하도록 설계되었습니다. 이 코드를 양식에 붙여넣고 양식의 ConvertRectangleToRectangleFPaint 이벤트를 처리할 때 메서드를 호출하여 으로 PaintEventArgs전달합니다e.

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

적용 대상