Point.Offset 方法

定義

根據指定的數量來轉換 PointTranslates 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 使用此 Point 的位移。The Point used offset this Point.

範例

下列範例會示範如何使用 Offset 方法。The following example shows how to use the Offset method. 若要執行此範例,請將它貼到 Windows Form 中。To run this example, paste it into a Windows Form. 處理表單的 Paint 事件,並從 Paint 事件處理方法呼叫 OffsetPoint 方法,並將 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

備註

這個方法會將這個 PointXY 值,調整為這個 YPointXp值的總和。This method adjusts the X and Y values of this Point to the sum of the X and Y values of this Point and p.

適用於