PointF.Addition 演算子

定義

指定の PointF を指定のサイズだけ移動します。Translates the given PointF by a specified size.

オーバーロード

Addition(PointF, SizeF)

PointF を指定の SizeF だけ移動します。Translates the PointF by the specified SizeF.

Addition(PointF, Size)

PointF を指定の Size だけ移動します。Translates a PointF by a given Size.

Addition(PointF, SizeF)

PointF を指定の SizeF だけ移動します。Translates the PointF by the specified 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

移動する PointFThe PointF to translate.

sz
SizeF

SizeF の x 座標と y 座標に追加する数を指定する PointFThe SizeF that specifies the numbers to add to the x- and y-coordinates of the PointF.

戻り値

移動された PointF 構造体。The translated PointF.

Addition演算子を使用する方法を次のコード例に示します。The following code example demonstrates how to use the Addition operator. この例を実行するには、Windows フォームに次のコードを貼り付けます。To run this example, paste the following code into a Windows Form. フォームのPaintイベントopAdditionExampleを処理し、をとePaintEventArgsて渡します。Handle the form's Paint event and call opAdditionExample, passing e as PaintEventArgs.

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は、指定WidthされたサイズのをのPointF x Height座標に、をの y 座標PointFに加算します。The Addition operator adds the Width of the specified size to the x-coordinate of the PointF and the Height to the y-coordinate of the PointF.

この演算子の同等の方法は次のようになります。PointF.Add(PointF, SizeF)The equivalent method for this operator is PointF.Add(PointF, SizeF)

Addition(PointF, Size)

PointF を指定の Size だけ移動します。Translates a PointF by a given Size.

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

移動する PointFThe PointF to translate.

sz
Size

pt の座標に追加する数の組み合わせを指定する SizeA Size that specifies the pair of numbers to add to the coordinates of pt.

戻り値

移動された PointF 構造体。The translated PointF.

  • 次のコード例では、 ListBox Addition演算子を使用してに影を追加します。The following code example adds a shadow to a ListBox using the Addition operator. この例は、Windows フォームと共に使用するように設計されています。This example is designed to be used with a Windows Form. この例を実行するには、フォームにこのコードを貼りAddShadow付け、フォームのPaintイベントを処理するときにメソッドを呼び出します。To run this example, paste this code into a form and call the AddShadow method when handling the form's Paint event. フォームにという名前ListBox listBox1のが含まれていることを確認します。Make sure the form contains a ListBox named listBox1.
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

適用対象