Point.Offset 方法

定义

将此 Point 平移指定的量。Translates the Point by the specified amount.

重载

Offset(Int32, Int32)

按指定量平移此 PointTranslates this Point by the specified amount.

Offset(Point)

将此 Point 平移指定的 PointTranslates this Point by the specified Point.

Offset(Int32, Int32)

按指定量平移此 PointTranslates this Point by the specified amount.

public:
 void Offset(int dx, int dy);
public void Offset (int dx, int dy);
member this.Offset : int * int -> unit
Public Sub Offset (dx As Integer, dy As Integer)

参数

dx
Int32

x 坐标的偏移量。The amount to offset the x-coordinate.

dy
Int32

y 坐标的偏移量。The amount to offset the y-coordinate.

适用于

Offset(Point)

将此 Point 平移指定的 PointTranslates this Point by the specified Point.

public:
 void Offset(System::Drawing::Point p);
public void Offset (System.Drawing.Point p);
member this.Offset : System.Drawing.Point -> unit
Public Sub Offset (p As Point)

参数

p
Point

用于使此 Point 发生偏移的 PointThe Point used offset this Point.

示例

下面的示例显示如何使用 Offset 方法。The following example shows how to use the Offset method. 若要运行此示例,请将其粘贴到 Windows 窗体中。To run this example, paste it into a Windows Form. 处理窗体的 Paint 事件,并 OffsetPointPaint 事件处理方法调用方法,并将 e 作为传递 PaintEventArgsHandle the form's Paint event and call the OffsetPoint method from the Paint event-handling method, passing e as PaintEventArgs.

private void OffsetPoint(PaintEventArgs e)
{
    Point point1 = new Point(10, 10);
    point1.Offset(50, 0);
    Point point2 = new Point(250, 10);
    e.Graphics.DrawLine(Pens.Red, point1, point2);
}
Private Sub OffsetPoint(ByVal e As PaintEventArgs) 
    Dim point1 As New Point(10, 10)
    point1.Offset(50, 0)
    Dim point2 As New Point(250, 10)
    e.Graphics.DrawLine(Pens.Red, point1, point2)
End Sub

注解

此方法将 X 此的和 Y 值调整 Point 为此和的和 X 值之和 Y Point pThis method adjusts the X and Y values of this Point to the sum of the X and Y values of this Point and p.

适用于