PointF.Add 方法

定义

按指定的大小平移给定的 PointFTranslates a given PointF by the specified size.

重载

Add(PointF, Size)

按指定的 PointF 平移给定的 SizeTranslates a given PointF by the specified Size.

Add(PointF, SizeF)

按指定的 PointF 平移给定的 SizeFTranslates a given PointF by a specified SizeF.

Add(PointF, Size)

按指定的 PointF 平移给定的 SizeTranslates a given PointF by the specified Size.

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

参数

pt
PointF

要平移的 PointFThe PointF to translate.

sz
Size

Size,它指定要增加到 pt 的坐标的数。The Size that specifies the numbers to add to the coordinates of pt.

返回

转换的 PointFThe translated PointF.

注解

Add 方法将指定大小的 Width 添加到 PointF 的 x 坐标,将 Height 添加到 PointF的 y 坐标。The Add method adds the Width of the specified size to the x-coordinate of the PointF and the Height to the y-coordinate of the PointF.

另请参阅

Add(PointF, SizeF)

按指定的 PointF 平移给定的 SizeFTranslates a given PointF by a specified SizeF.

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

参数

pt
PointF

要平移的 PointFThe PointF to translate.

sz
SizeF

SizeF,它指定要增加到 pt 的坐标的数。The SizeF that specifies the numbers to add to the coordinates of pt.

返回

转换的 PointFThe translated PointF.

示例

下面的代码示例演示如何使用 Add 方法。The following code example demonstrates how to use the Add method. 若要运行此示例,请将以下代码粘贴到 Windows 窗体中。To run this example, paste the following code into a Windows Form. 处理窗体的 Paint 事件并调用 AddExample,将 e 作为 PaintEventArgs传递。Handle the form's Paint event and call AddExample, passing e as PaintEventArgs.

private void AddExample(PaintEventArgs e)
{
    PointF point1 = new PointF(120.5F, 120F);
    SizeF size1 = new SizeF(20.5F, 20.5F);
    RectangleF rect1 = new RectangleF(point1, size1);
    PointF point2 = new PointF(rect1.Right, rect1.Bottom);
    if (point2 != PointF.Add(point1, size1))
        e.Graphics.DrawString("They are not equal", this.Font, Brushes.Red, rect1);
    else
        e.Graphics.DrawString("They are equal", this.Font, Brushes.Black, rect1);
}
Private Sub AddExample(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)
    Dim point2 As New PointF(rect1.Right, rect1.Bottom)
    If point2 <> PointF.Add(point1, size1) Then
        e.Graphics.DrawString("They are not equal", Me.Font, Brushes.Red, rect1)
    Else
        e.Graphics.DrawString("They are equal", Me.Font, Brushes.Black, rect1)
    End If

End Sub

注解

Add 方法将指定大小的 Width 添加到 PointF 的 x 坐标,将 Height 添加到 PointF的 y 坐标。The Add method adds the Width of the specified size to the x-coordinate of the PointF and the Height to the y-coordinate of the PointF.

另请参阅

适用于