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 中,的 XYPoint 之間的分隔符號可以是逗號或空格。

某些文化特性可能會使用逗號字元做為小數分隔符號,而不是句號字元。 非變異文化特性的 XAML 處理預設為大部分 XAML 處理器實作中的 en-US,而且預期期間為小數分隔符號。 如果在 XAML 中指定 Point ,您應該避免使用逗號字元做為十進位分隔符號,因為這會與將屬性值轉換成 XY 元件的字串類型發生 Point 衝突。

XAML Attribute Usage

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

XAML 值

x
這個 Point 的 X 座標。

y
這個 Point 的 Y 座標。

建構函式

Point(Double, Double)

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

屬性

X

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

Y

取得或設定這個 YPoint 座標值。

方法

Add(Point, Vector)

Vector 加入至 Point,並傳回結果做為 Point 結構。

Equals(Object)

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

Equals(Point)

比較兩個 Point 結構是否相等。

Equals(Point, Point)

比較兩個 Point 結構是否相等。

GetHashCode()

傳回這個 Point 的雜湊程式碼。

Multiply(Point, Matrix)

使用指定的 Point 結構轉換指定的 Matrix 結構。

Offset(Double, Double)

將點的 XY 座標位移指定的數量。

Parse(String)

從指定的 Point 建構 String

Subtract(Point, Point)

從指定的 Point 減去另一個指定的 Point 並以 Vector 傳回差數。

Subtract(Point, Vector)

從指定的 Vector 減去指定的 Point 並傳回產生的 Point

ToString()

建立這個 StringPoint 表示。

ToString(IFormatProvider)

建立這個 StringPoint 表示。

運算子

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)

從指定的 Point 減去另一個指定的 Point 並以 Vector 傳回差數。

Subtraction(Point, Vector)

從指定的 Vector 減去指定的 Point 並傳回產生的 Point

明確介面實作

IFormattable.ToString(String, IFormatProvider)

此成員支援Windows Presentation Foundation (WPF) 基礎結構,而且不適合直接從您的程式碼使用。 如需這個成員的說明,請參閱 ToString(String, IFormatProvider)

適用於