다음을 통해 공유


RectangleF 생성자

정의

지정된 위치와 크기를 사용하여 RectangleF 클래스의 새 인스턴스를 초기화합니다.

오버로드

RectangleF(Vector4)

지정된 Vector4에서 구조체의 RectangleF 새 instance 초기화합니다.

RectangleF(PointF, SizeF)

지정된 위치와 크기를 사용하여 RectangleF 클래스의 새 인스턴스를 초기화합니다.

RectangleF(Single, Single, Single, Single)

지정된 위치와 크기를 사용하여 RectangleF 클래스의 새 인스턴스를 초기화합니다.

RectangleF(Vector4)

Source:
RectangleF.cs
Source:
RectangleF.cs
Source:
RectangleF.cs

지정된 Vector4에서 구조체의 RectangleF 새 instance 초기화합니다.

public:
 RectangleF(System::Numerics::Vector4 vector);
public RectangleF (System.Numerics.Vector4 vector);
new System.Drawing.RectangleF : System.Numerics.Vector4 -> System.Drawing.RectangleF
Public Sub New (vector As Vector4)

매개 변수

vector
Vector4

원본 벡터입니다.

적용 대상

RectangleF(PointF, SizeF)

Source:
RectangleF.cs
Source:
RectangleF.cs
Source:
RectangleF.cs

지정된 위치와 크기를 사용하여 RectangleF 클래스의 새 인스턴스를 초기화합니다.

public:
 RectangleF(System::Drawing::PointF location, System::Drawing::SizeF size);
public RectangleF (System.Drawing.PointF location, System.Drawing.SizeF size);
new System.Drawing.RectangleF : System.Drawing.PointF * System.Drawing.SizeF -> System.Drawing.RectangleF
Public Sub New (location As PointF, size As SizeF)

매개 변수

location
PointF

사각형 영역의 왼쪽 위 모퉁이를 나타내는 PointF입니다.

size
SizeF

사각형 영역의 너비 및 높이를 나타내는 SizeF입니다.

예제

다음 코드 예제를 사용 Implicit하는 방법에 설명 합니다 , RectangleF, 및 Equality 멤버입니다. 이 예제는 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

적용 대상

RectangleF(Single, Single, Single, Single)

Source:
RectangleF.cs
Source:
RectangleF.cs
Source:
RectangleF.cs

지정된 위치와 크기를 사용하여 RectangleF 클래스의 새 인스턴스를 초기화합니다.

public:
 RectangleF(float x, float y, float width, float height);
public RectangleF (float x, float y, float width, float height);
new System.Drawing.RectangleF : single * single * single * single -> System.Drawing.RectangleF
Public Sub New (x As Single, y As Single, width As Single, height As Single)

매개 변수

x
Single

사각형의 왼쪽 위 모퉁이의 x좌표입니다.

y
Single

사각형의 왼쪽 위 모퉁이의 y좌표입니다.

width
Single

사각형의 너비입니다.

height
Single

사각형의 높이입니다.

예제

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

private:
   void RoundingAndTruncatingRectangles( PaintEventArgs^ e )
   {
      // Construct a new RectangleF.
      RectangleF myRectangleF = RectangleF(30.6F,30.7F,40.8F,100.9F);

      // Call the Round method.
      Rectangle roundedRectangle = Rectangle::Round( myRectangleF );

      // Draw the rounded rectangle in red.
      Pen^ redPen = gcnew Pen( Color::Red,4.0f );
      e->Graphics->DrawRectangle( redPen, roundedRectangle );

      // Call the Truncate method.
      Rectangle truncatedRectangle = Rectangle::Truncate( myRectangleF );

      // Draw the truncated rectangle in white.
      Pen^ whitePen = gcnew Pen( Color::White,4.0f );
      e->Graphics->DrawRectangle( whitePen, truncatedRectangle );

      // Dispose of the custom pens.
      delete redPen;
      delete whitePen;
   }
private void RoundingAndTruncatingRectangles(PaintEventArgs e)
{

    // Construct a new RectangleF.
    RectangleF myRectangleF = 
        new RectangleF(30.6F, 30.7F, 40.8F, 100.9F);

    // Call the Round method.
    Rectangle roundedRectangle = Rectangle.Round(myRectangleF);

    // Draw the rounded rectangle in red.
    Pen redPen = new Pen(Color.Red, 4);
    e.Graphics.DrawRectangle(redPen, roundedRectangle);

    // Call the Truncate method.
    Rectangle truncatedRectangle = Rectangle.Truncate(myRectangleF);

    // Draw the truncated rectangle in white.
    Pen whitePen = new Pen(Color.White, 4);
    e.Graphics.DrawRectangle(whitePen, truncatedRectangle);

    // Dispose of the custom pens.
    redPen.Dispose();
    whitePen.Dispose();
}
Private Sub RoundingAndTruncatingRectangles( _
    ByVal e As PaintEventArgs)

    ' Construct a new RectangleF.
    Dim myRectangleF As New RectangleF(30.6F, 30.7F, 40.8F, 100.9F)

    ' Call the Round method.
    Dim roundedRectangle As Rectangle = Rectangle.Round(myRectangleF)

    ' Draw the rounded rectangle in red.
    Dim redPen As New Pen(Color.Red, 4)
    e.Graphics.DrawRectangle(redPen, roundedRectangle)

    ' Call the Truncate method.
    Dim truncatedRectangle As Rectangle = _
        Rectangle.Truncate(myRectangleF)

    ' Draw the truncated rectangle in white.
    Dim whitePen As New Pen(Color.White, 4)
    e.Graphics.DrawRectangle(whitePen, truncatedRectangle)

    ' Dispose of the custom pens.
    redPen.Dispose()
    whitePen.Dispose()
End Sub

적용 대상