Point Point Point Point Struct

定义

表示二维空间中的 x 坐标和 y 坐标对。Represents an x- and y-coordinate pair in two-dimensional space.

public value class Point : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.PointConverter))]
[System.Serializable]
public struct Point : IFormattable
type Point = struct
    interface IFormattable
Public Structure Point
Implements IFormattable
继承
属性
实现

示例

下面的示例演示如何检查两个Point结构是否不相等。The following example shows how to check if two Point structures are not equal. 它还说明了在声明结构时以及Point在声明结构后如何向结构分配值。It also illustrates how to assign values to a Point structure when the structure is being declared and after the structure has been declared.

// 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之间的分隔符可以是逗号或空格。In XAML, the delimiter between the X and Y values of a Point can be either a comma or a space.

某些区域性可能使用逗号字符作为小数分隔符, 而不是句点字符。Some cultures might use the comma character as the decimal delimiter instead of the period character. 在大多数 XAML 处理器实现中, 用于固定区域性的 XAML 处理默认为 en-us, 并期望句点是小数分隔符。XAML processing for invariant culture defaults to en-US in most XAML processor implementations, and expects the period to be the decimal delimiter. 如果在Point XAML 中指定了, 则应避免使用逗号字符作为小数分隔符, 因为这将与Point属性值到XY组件的字符串类型转换冲突。You should avoid using the comma character as the decimal delimiter if specifying a Point in XAML, because that will clash with the string type conversion of a Point attribute value into the X and Y components.

XAML 属性用法XAML Attribute Usage

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

XAML 值XAML Values

xx
Point 的 x 坐标。The x-coordinate of this Point.

yy
Point 的 y 坐标。The y-coordinate of this Point.

构造函数

Point(Double, Double) Point(Double, Double) Point(Double, Double) Point(Double, Double)

创建一个包含指定坐标的新 Point 结构。Creates a new Point structure that contains the specified coordinates.

属性

X X X X

获取或设置此 X 结构的 Point 坐标值。Gets or sets the X-coordinate value of this Point structure.

Y Y Y Y

获取或设置此 YPoint 坐标值。Gets or sets the Y-coordinate value of this Point.

方法

Add(Point, Vector) Add(Point, Vector) Add(Point, Vector) Add(Point, Vector)

VectorPoint 相加并将结果以 Point 结构返回。Adds a Vector to a Point and returns the result as a Point structure.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的 Object 是否是 Point 以及它是否包含与此 Point 相同的坐标。Determines whether the specified Object is a Point and whether it contains the same coordinates as this Point.

Equals(Point) Equals(Point) Equals(Point) Equals(Point)

比较两个 Point 结构是否相等。Compares two Point structures for equality.

Equals(Point, Point) Equals(Point, Point) Equals(Point, Point) Equals(Point, Point)

比较两个 Point 结构是否相等。Compares two Point structures for equality.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回该 Point 的哈希代码。Returns the hash code for this Point.

Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix)

使用指定的 Point 结构转换指定的 Matrix 结构。Transforms the specified Point structure by the specified Matrix structure.

Offset(Double, Double) Offset(Double, Double) Offset(Double, Double) Offset(Double, Double)

将某个点的 X 坐标和 Y 坐标偏移指定的量。Offsets a point's X and Y coordinates by the specified amounts.

Parse(String) Parse(String) Parse(String) Parse(String)

从指定的 Point 构造 StringConstructs a Point from the specified String.

Subtract(Point, Point) Subtract(Point, Point) Subtract(Point, Point) Subtract(Point, Point)

从指定的 Point 中减去另一个指定的 Point 并将差作为 Vector 返回。Subtracts the specified Point from another specified Point and returns the difference as a Vector.

Subtract(Point, Vector) Subtract(Point, Vector) Subtract(Point, Vector) Subtract(Point, Vector)

从指定的 Vector 减去指定的 Point 并返回所得的 PointSubtracts the specified Vector from the specified Point and returns the resulting Point.

ToString() ToString() ToString() ToString()

创建此 StringPoint 表示形式。Creates a String representation of this Point.

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

创建此 StringPoint 表示形式。Creates a String representation of this Point.

操作员

Addition(Point, Vector) Addition(Point, Vector) Addition(Point, Vector) Addition(Point, Vector)

将指定的 Point 平移指定的 Vector 并返回结果。Translates the specified Point by the specified Vector and returns the result.

Equality(Point, Point) Equality(Point, Point) Equality(Point, Point) Equality(Point, Point)

比较两个 Point 结构是否相等。Compares two Point structures for equality.

Explicit(Point to Vector) Explicit(Point to Vector) Explicit(Point to Vector) Explicit(Point to Vector)

创建一个 Vector 结构,该结构的 X 值等于该点的 X 值,且 Y 值等于该点的 Y 值。Creates a Vector structure with an X value equal to the point's X value and a Y value equal to the point's Y value.

Explicit(Point to Size) Explicit(Point to Size) Explicit(Point to Size) Explicit(Point to Size)

创建一个 Size 结构,该结构的 Width 等于此点的 X 值,且 Height 等于此点的 Y 值。Creates a Size structure with a Width equal to this point's X value and a Height equal to this point's Y value.

Inequality(Point, Point) Inequality(Point, Point) Inequality(Point, Point) Inequality(Point, Point)

比较两个 Point 结构是否不相等。Compares two Point structures for inequality.

Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix)

将指定的 Point 转换为指定的 MatrixTransforms the specified Point by the specified Matrix.

Subtraction(Point, Point) Subtraction(Point, Point) Subtraction(Point, Point) Subtraction(Point, Point)

从指定的 Point 中减去另一个指定的 Point 并将差作为 Vector 返回。Subtracts the specified Point from another specified Point and returns the difference as a Vector.

Subtraction(Point, Vector) Subtraction(Point, Vector) Subtraction(Point, Vector) Subtraction(Point, Vector)

从指定的 Vector 减去指定的 Point 并返回所得的 PointSubtracts the specified Vector from the specified Point and returns the resulting Point.

显式界面实现

IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider)

此成员支持 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基础结构,但不能在代码中直接使用。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 有关此成员的说明,请参见 ToString(String, IFormatProvider)For a description of this member, see ToString(String, IFormatProvider).

适用于