語言

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 表單。 建立一個包含 Button 名稱 subtractButton的表單。 將程式碼貼入表單,並從表單的CreatePointsAndSizes事件處理方法呼叫該Paint方法,傳遞ePaintEventArgs

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

備註

若要將 a Point 轉換為 PointF,請使用 Implicit

建構函式

名稱 Description
Point(Int32, Int32)

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

Point(Int32)

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

Point(Size)

初始化來自 Point的結構體新實例Size

欄位

名稱 Description
Empty

表示Point一個 ,XY且 的值設為零。

屬性

名稱 Description
IsEmpty

會得到一個值,表示這個值 Point 是否為空。

X

取得或設定此座標 Point的 x座標。

Y

取得或設定此座標 Point的 。

方法

名稱 Description
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)

將指定的PointFPoint值四捨五入PointF至最接近的整數,轉換為物件。

Subtract(Point, Size)

回傳從指定Size值中減去指定Point結果。

ToString()

將此 Point 轉換成人類可讀的字串。

Truncate(PointF)

透過截PointF斷 的 值,將指定的 Point 轉換為 。PointF

運算子

名稱 Description
Addition(Point, Size)

將 a 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)

將 a Point 換成給定 Size的負值。

適用於