다음을 통해 공유


PointF.Addition 연산자

정의

지정된 크기에 따라 지정된 PointF를 변환합니다.

오버로드

Addition(PointF, Size)

지정된 PointFSize를 변환합니다.

Addition(PointF, SizeF)

지정된 PointF에 따라 SizeF를 변환합니다.

Addition(PointF, Size)

Source:
PointF.cs
Source:
PointF.cs
Source:
PointF.cs

지정된 PointFSize를 변환합니다.

public:
 static System::Drawing::PointF operator +(System::Drawing::PointF pt, System::Drawing::Size sz);
public static System.Drawing.PointF operator + (System.Drawing.PointF pt, System.Drawing.Size sz);
static member ( + ) : System.Drawing.PointF * System.Drawing.Size -> System.Drawing.PointF
Public Shared Operator + (pt As PointF, sz As Size) As PointF

매개 변수

pt
PointF

변환할 PointF입니다.

sz
Size

pt의 좌표에 추가할 두 수를 지정하는 Size입니다.

반환

변환된 PointF입니다.

예제

  • 다음 코드 예제에서는 연산자를 사용하여 에 그림자 ListBox 를 추가합니다 Addition . 이 예제는 Windows Form과 함께 사용하도록 설계되었습니다. 이 예제를 실행하려면 폼에 이 코드를 붙여넣고 폼의 Paint 이벤트를 처리할 때 메서드를 호출 AddShadow 합니다. 양식에 라는 가 ListBoxlistBox1포함되어 있는지 확인합니다.
private:
   void AddShadow( PaintEventArgs^ e )
   {
      // Create two SizeF objects.
      SizeF shadowSize = listBox1->Size;
      SizeF addSize = SizeF(10.5F,20.8F);

      // Add them together and save the result in shadowSize.
      shadowSize = shadowSize + addSize;

      // Get the location of the ListBox and convert it to a PointF.
      PointF shadowLocation = listBox1->Location;

      // Add two points to get a new location.
      shadowLocation = shadowLocation + System::Drawing::Size( 5, 5 );

      // Create a rectangleF. 
      RectangleF rectFToFill = RectangleF(shadowLocation,shadowSize);

      // Create a custom brush using a semi-transparent color, and 
      // then fill in the rectangle.
      Color customColor = Color::FromArgb( 50, Color::Gray );
      SolidBrush^ shadowBrush = gcnew SolidBrush( customColor );
      array<RectangleF>^ temp0 = {rectFToFill};
      e->Graphics->FillRectangles( shadowBrush, temp0 );

      // Dispose of the brush.
      delete shadowBrush;
   }
private void AddShadow(PaintEventArgs e)
{

    // Create two SizeF objects.
    SizeF shadowSize = listBox1.Size;
    SizeF addSize = new SizeF(10.5F, 20.8F);

    // Add them together and save the result in shadowSize.
    shadowSize = shadowSize + addSize;

    // Get the location of the ListBox and convert it to a PointF.
    PointF shadowLocation = listBox1.Location;

    // Add two points to get a new location.
    shadowLocation = shadowLocation + new Size(5, 5);

    // Create a rectangleF. 
    RectangleF rectFToFill = 
        new RectangleF(shadowLocation, shadowSize);

    // Create a custom brush using a semi-transparent color, and 
    // then fill in the rectangle.
    Color customColor = Color.FromArgb(50, Color.Gray);
    SolidBrush shadowBrush = new SolidBrush(customColor);
    e.Graphics.FillRectangles(shadowBrush, new RectangleF[]{rectFToFill});

    // Dispose of the brush.
    shadowBrush.Dispose();
}
Private Sub AddShadow(ByVal e As PaintEventArgs)

    ' Create two SizeF objects.
    Dim shadowSize As SizeF = Size.op_Implicit(listBox1.Size)
    Dim addSize As New SizeF(10.5F, 20.8F)

    ' Add them together and save the result in shadowSize.
    shadowSize = SizeF.op_Addition(shadowSize, addSize)

    ' Get the location of the ListBox and convert it to a PointF.
    Dim shadowLocation As PointF = Point.op_Implicit(listBox1.Location)

    ' Add a Size to the Point to get a new location.
    shadowLocation = PointF.op_Addition(shadowLocation, New Size(5, 5))

    ' Create a rectangleF. 
    Dim rectFToFill As New RectangleF(shadowLocation, shadowSize)

    ' Create a custom brush using a semi-transparent color, and 
    ' then fill in the rectangle.
    Dim customColor As Color = Color.FromArgb(50, Color.Gray)
    Dim shadowBrush As SolidBrush = New SolidBrush(customColor)
    e.Graphics.FillRectangles(shadowBrush, _
        New RectangleF() {rectFToFill})

    ' Dispose of the brush.
    shadowBrush.Dispose()
End Sub

적용 대상

Addition(PointF, SizeF)

Source:
PointF.cs
Source:
PointF.cs
Source:
PointF.cs

지정된 PointF에 따라 SizeF를 변환합니다.

public:
 static System::Drawing::PointF operator +(System::Drawing::PointF pt, System::Drawing::SizeF sz);
public static System.Drawing.PointF operator + (System.Drawing.PointF pt, System.Drawing.SizeF sz);
static member ( + ) : System.Drawing.PointF * System.Drawing.SizeF -> System.Drawing.PointF
Public Shared Operator + (pt As PointF, sz As SizeF) As PointF

매개 변수

pt
PointF

변환할 PointF입니다.

sz
SizeF

SizeF의 X 좌표 및 Y 좌표에 추가할 숫자를 지정하는 PointF입니다.

반환

변환된 PointF입니다.

예제

다음 코드 예제에서는 연산자를 사용 하는 방법을 보여 줍니다 Addition . 이 예제를 실행 하려면 Windows 폼에 다음 코드를 붙여 넣습니다. 양식의 Paint 이벤트를 처리하고 를 로 전달 ePaintEventArgs하여 를 호출opAdditionExample합니다.

private void OpAdditionExample(PaintEventArgs e)
{
    PointF point1 = new PointF(120.5F, 120F);
    SizeF size1 = new SizeF(120.5F, 30.5F);
    RectangleF rect1 = new RectangleF(point1, size1);
    if (new PointF(rect1.Right, rect1.Bottom) == point1 + size1)
        e.Graphics.DrawString("They are equal", this.Font, Brushes.Black, rect1);
    else
        e.Graphics.DrawString("They are not equal", this.Font, Brushes.Red, rect1);
}
Private Sub OpAdditionExample(ByVal e As PaintEventArgs) 
    Dim size1 As New SizeF(120.5F, 30.5F)
    Dim point1 As New PointF(20.5F, 20F)
    Dim rect1 As New RectangleF(point1, size1)
    If New PointF(rect1.Right, rect1.Bottom) = point1 + size1 Then
        e.Graphics.DrawString("They are equal", Me.Font, Brushes.Black, rect1)
    Else
        e.Graphics.DrawString("They are not equal", Me.Font, Brushes.Red, rect1)
    End If
 
End Sub

설명

연산자는 Addition 지정된 크기의 를 의 x 좌표 PointF 에 추가하고 의 Height y 좌표에 를 추가 Width 합니다PointF.

이 연산자에 대 한 해당 메서드는 PointF.Add(PointF, SizeF)

적용 대상