Point 結構

定義

表示二維空間中的 x 和 Y 座標組。

public value class Point : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.PointConverter))]
[System.Serializable]
public struct Point : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.PointConverter))]
public struct Point : IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.PointConverter))>]
[<System.Serializable>]
type Point = struct
    interface IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.PointConverter))>]
type Point = struct
    interface IFormattable
Public Structure Point
Implements IFormattable
繼承
屬性
實作

範例

以下範例說明如何檢查兩個 Point 結構是否不相等。 同時說明在結構宣告時及宣告後,如何為結構指派值 Point

// Checks if two Points are equal using the overloaded inequality operator.
private Boolean pointInequalityExample()
{
    // Checks if two Points are not equal using the overloaded inequality operator.

    // Declaring point1 and initializing x,y values
    Point point1 = new Point(10, 5);

    // Declaring point2 without initializing x,y values
    Point point2 = new Point();

    // Boolean to hold the result of the comparison
    Boolean areNotEqual;

    // assigning values to point2
    point2.X = 15;
    point2.Y = 40;

    // Compare Point structures for equality.
    // areNotEqual is True
    areNotEqual = (point1 != point2);

    return areNotEqual;
}
' Checks if two Points are equal using the overloaded inequality operator.
Private Function pointInequalityExample() As Boolean
    ' Checks if two Points are not equal using the overloaded inequality operator.

    ' Declaring point1 and initializing x,y values
    Dim point1 As New Point(10, 5)

    ' Declaring point2 without initializing x,y values
    Dim point2 As New Point()

    ' Boolean to hold the result of the comparison
    Dim areNotEqual As Boolean

    ' assigning values to point2
    point2.X = 15
    point2.Y = 40

    ' Compare Point structures for equality.
    ' areNotEqual is True
    areNotEqual = (point1 <> point2)

    Return areNotEqual

End Function

備註

在 XAML 中,a X 與 值之間的YPoint分隔符可以是逗號或空格。

有些文化可能會用逗號作為小數分隔符,而不是時代字元。 大多數 XAML 處理器實作中,不變文化的 XAML 處理預設為 en-US,且預期週期為十進位分隔符。 如果在 XAML 中指定 a Point ,應該避免用逗號作為十進位分隔符,因為這會和屬性 Point 值轉換成 X and Y components 的字串類型產生衝突。

XAML 屬性使用方式

<object property="x,y"/>
-or-
<object property="x y"/>

XAML 值

x 這個 的 x 座標 Point

y 這個的 y 座標 Point

建構函式

名稱 Description
Point(Double, Double)

建立 Point 包含指定座標的新結構。

屬性

名稱 Description
X

取得或設定 XPoint 結構的 -座標值。

Y

取得或設定 Y此值 Point的 -座標值。

方法

名稱 Description
Add(Point, Vector)

將 a Vector 加到 a Point 上,並以結構形式回傳結果 Point

Equals(Object)

判斷指定的 Object 是否為 a Point ,以及是否包含與此 Point相同的座標。

Equals(Point, Point)

比較兩種 Point 平等結構。

Equals(Point)

比較兩種 Point 平等結構。

GetHashCode()

回傳此 Point的雜湊碼。

Multiply(Point, Matrix)

將指定的 Point 結構轉換為指定的 Matrix 結構。

Offset(Double, Double)

將點 XY 座標偏移至指定數量。

Parse(String)

從指定的 Point構造 a String

Subtract(Point, Point)

從另一個指定PointPoint中減去,並返回差值為 Vector

Subtract(Point, Vector)

從指定Vector值減去指定Point值,並返回結果 Point

ToString()

會產生 StringPoint的表示。

ToString(IFormatProvider)

會產生 StringPoint的表示。

操作員

名稱 Description
Addition(Point, Vector)

將指定 Point 值轉換為指定 Vector 值,並回傳結果。

Equality(Point, Point)

比較兩種 Point 平等結構。

Explicit(Point to Size)

建立Size一個結構,其Width值等於此點,X且等Height於該點值。Y

Explicit(Point to Vector)

建立 Vector 一個結構,其 X 值等於該點的 X 值與 Y 一個等於該點 Y 的值。

Inequality(Point, Point)

比較兩種 Point 不平等結構。

Multiply(Point, Matrix)

將指定 Point 變換為指定的 Matrix

Subtraction(Point, Point)

從另一個指定PointPoint中減去,並返回差值為 Vector

Subtraction(Point, Vector)

從指定Vector值減去指定Point值,並返回結果 Point

明確介面實作

名稱 Description
IFormattable.ToString(String, IFormatProvider)

此成員支援 Windows Presentation Foundation(WPF)基礎架構,並非直接從您的程式碼中使用。 關於此成員的描述,請參見 ToString(String, IFormatProvider)

適用於