Point.Explicit Point.Explicit Point.Explicit Operator

定义

重载

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)

创建一个 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.

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.

public:
 static explicit operator System::Windows::Vector(System::Windows::Point point);
public static explicit operator System.Windows.Vector (System.Windows.Point point);
static member op_Explicit : System.Windows.Point -> System.Windows.Vector

参数

point
Point Point Point

要变换的点。The point to convert.

返回

一个向量,它的 X 值等于该点的 X 值,且 Y 值等于该点的 Y 值。A vector with an X value equal to the point's X value and a Y value equal to the point's Y value.

示例

下面的示例演示如何将显式转换Point Vector为。The following example shows how to explicitly convert a Point into a Vector.

private Vector overloadedExplicitOperatorVectorExample()
{

    Point point1 = new Point(10, 5);

    // Explicitly converts a Point structure into a Vector structure.
    // returnVector is equal to (10,5).
    Vector returnVector = (Vector)point1;

    return returnVector;

}
Private Function overloadedExplicitOperatorVectorExample() As Vector

    Dim point1 As New Point(10, 5)

    ' Explicitly converts a Point structure into a Vector structure.
    ' returnVector is equal to (10,5).
    Dim returnVector As Vector = CType(point1, Vector)

    Return returnVector

End Function

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.

public:
 static explicit operator System::Windows::Size(System::Windows::Point point);
public static explicit operator System.Windows.Size (System.Windows.Point point);
static member op_Explicit : System.Windows.Point -> System.Windows.Size

参数

point
Point Point Point

要变换的点。The point to convert.

返回

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

示例

下面的示例演示如何将显式转换Point Size为。The following example shows how to explicitly convert a Point into a Size.

private Size overloadedExplicitOperatorSizeExample()
{

    Point point1 = new Point(10, 5);

    // Explicitly converts a Point structure into a Size structure.
    // returnSize has a width of 10 and a height of 5  
    Size returnSize = (Size)point1;

    return returnSize;
    
}
Private Function overloadedExplicitOperatorSizeExample() As Size

    Dim point1 As New Point(10, 5)

    ' Explicitly converts a Point structure into a Size structure.
    ' returnSize has a width of 10 and a height of 5  
    Dim returnSize As Size = CType(point1, Size)

    Return returnSize

End Function

注解

由于结构不能为负数, 因此使用点的XY属性的绝对值。 SizeBecause a Size structure cannot be negative, the absolute values of the point's X and Y properties are used.

适用于