Point 結構

定義

表示整數 X 和 Y 座標之已排序的配對,此配對會定義二維平面中的點。

public value class Point : IEquatable<System::Drawing::Point>
public value class Point
[System.ComponentModel.TypeConverter("System.Drawing.PointConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public struct Point : IEquatable<System.Drawing.Point>
public struct Point
public struct Point : IEquatable<System.Drawing.Point>
[System.ComponentModel.TypeConverter(typeof(System.Drawing.PointConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct Point
[<System.ComponentModel.TypeConverter("System.Drawing.PointConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type Point = struct
type Point = struct
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.PointConverter))>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type Point = struct
Public Structure Point
Implements IEquatable(Of Point)
Public Structure Point
繼承
屬性
實作

範例

下列程式碼範例會使用針對這些類型定義的數個多載運算子來建立點和大小。 它也會示範如何使用 SystemPens 類別。

此範例的設計目的是要與Windows Forms搭配使用。 建立包含具名 subtractButtonButton 表單。 將程式碼貼到表單中,並從表單 Paint 的事件處理方法呼叫 CreatePointsAndSizes 方法,並 e 傳遞為 PaintEventArgs

void CreatePointsAndSizes( PaintEventArgs^ e )
{
   // Create the starting point.
   Point startPoint = Point(subtractButton->Size);
   
   // Use the addition operator to get the end point.
   Point endPoint = startPoint + System::Drawing::Size( 140, 150 );
   
   // Draw a line between the points.
   e->Graphics->DrawLine( SystemPens::Highlight, startPoint, endPoint );
   
   // Convert the starting point to a size and compare it to the
   // subtractButton size.  
   System::Drawing::Size buttonSize = (System::Drawing::Size)startPoint;
   if ( buttonSize == subtractButton->Size )
   {
      e->Graphics->DrawString( "The sizes are equal.", gcnew System::Drawing::Font( this->Font,FontStyle::Italic ), Brushes::Indigo, 10.0F, 65.0F );
   }
}
private void CreatePointsAndSizes(PaintEventArgs e)
{

    // Create the starting point.
    Point startPoint = new Point(subtractButton.Size);

    // Use the addition operator to get the end point.
    Point endPoint = startPoint + new Size(140, 150);

    // Draw a line between the points.
    e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint);

    // Convert the starting point to a size and compare it to the
    // subtractButton size.  
    Size buttonSize = (Size)startPoint;
    if (buttonSize == subtractButton.Size)

        // If the sizes are equal, tell the user.
    {
        e.Graphics.DrawString("The sizes are equal.", 
            new Font(this.Font, FontStyle.Italic), 
            Brushes.Indigo, 10.0F, 65.0F);
    }
}
Private Sub CreatePointsAndSizes(ByVal e As PaintEventArgs)

    ' Create the starting point.
    Dim startPoint As New Point(subtractButton.Size)

    ' Use the addition operator to get the end point.
    Dim endPoint As Point = Point.op_Addition(startPoint, _
        New Size(140, 150))

    ' Draw a line between the points.
    e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint)

    ' Convert the starting point to a size and compare it to the
    ' subtractButton size.  
    Dim buttonSize As Size = Point.op_Explicit(startPoint)
    If (Size.op_Equality(buttonSize, subtractButton.Size)) Then

        ' If the sizes are equal, tell the user.
        e.Graphics.DrawString("The sizes are equal.", _
            New Font(Me.Font, FontStyle.Italic), _
            Brushes.Indigo, 10.0F, 65.0F)
    End If

End Sub

備註

若要將 轉換為 PointPointF ,請使用 Implicit

建構函式

Point(Int32)

使用整數值所指定的座標, Point 初始化 結構的新實例。

Point(Int32, Int32)

使用指定的座標, Point 初始化 結構的新實例。

Point(Size)

Size 初始化 結構的新實例 Point

欄位

Empty

表示 Point,其 X 值與 Y 值設為零。

屬性

IsEmpty

取得值,指出這個 Point 是否為空的。

X

取得或設定這個 Point 的 X 座標。

Y

取得或設定這個 Point 的 Y 座標。

方法

Add(Point, Size)

將指定的 Size 加上指定的 Point

Ceiling(PointF)

藉由將 PointF 的值捨入為下一個較大的整數值,來將指定的 Point 轉換成 PointF

Equals(Object)

指定這個點執行個體是否包含與指定物件相同的座標。

Equals(Point)

指定這個點執行個體是否包含與其他點相同的座標。

GetHashCode()

傳回這個 Point 的雜湊碼。

Offset(Int32, Int32)

根據指定的數量來平移這個 Point

Offset(Point)

根據指定的 Point 來轉換這個 Point

Round(PointF)

藉由將 PointF 值捨入為最接近的整數值,來將指定的 Point 轉換為 PointF 物件。

Subtract(Point, Size)

傳回值,該值為從指定的 Size 減去指定的 Point 得到的結果。

ToString()

將這個 Point 轉換為人們可讀取的字串。

Truncate(PointF)

藉由截斷 PointF 的值,來將指定的 Point 轉換為 PointF

運算子

Addition(Point, Size)

根據指定的 Point 來轉換 Size

Equality(Point, Point)

比較兩個 Point 物件。 結果會指定兩個 X 物件的 YPoint 屬性值是否相等。

Explicit(Point to Size)

將指定的 Point 結構轉換成 Size 結構。

Implicit(Point to PointF)

將指定的 Point 結構轉換成 PointF 結構。

Inequality(Point, Point)

比較兩個 Point 物件。 結果會指定兩個 X 物件的 YPoint 屬性值是否不相等。

Subtraction(Point, Size)

根據指定 Point 的負數來轉換 Size

適用於