Point.Subtraction(Point, Size) Operator

Definition

Point 平移给定 Size 的负数。Translates a Point by the negative of a given Size.

public:
 static System::Drawing::Point operator -(System::Drawing::Point pt, System::Drawing::Size sz);
public static System.Drawing.Point operator - (System.Drawing.Point pt, System.Drawing.Size sz);
static member ( - ) : System.Drawing.Point * System.Drawing.Size -> System.Drawing.Point
Public Shared Operator - (pt As Point, sz As Size) As Point

Parameters

pt
Point

要平移的 PointThe Point to translate.

sz
Size

Size,它指定要从 pt 的坐标减去的数字对。A Size that specifies the pair of numbers to subtract from the coordinates of pt.

Returns

Point

Point 结构,此结构按给定 Size 结构的负数平移。A Point structure that is translated by the negative of a given Size structure.

Examples

下面的代码示例演示如何使用 PointConverterSubtraction 运算符。The following code example demonstrates how to use the PointConverter and the Subtraction operator. 此示例旨在与 Windows 窗体一起使用。This example is designed to be used with Windows Forms. 将此代码粘贴到窗体中,并在处理窗体的 Paint 事件时调用 ShowPointConverter 方法,并将 e 作为 PaintEventArgs传递。Paste this code into a form and call the ShowPointConverter method when handling the form's Paint event, passing e as PaintEventArgs.

void ShowPointConverter( PaintEventArgs^ e )
{
   // Create the PointConverter.
   System::ComponentModel::TypeConverter^ converter = System::ComponentModel::TypeDescriptor::GetConverter( Point::typeid );
   Point point1 =  *dynamic_cast<Point^>(converter->ConvertFromString( "200, 200" ));

   // Use the subtraction operator to get a second point.
   Point point2 = point1 - System::Drawing::Size( 190, 190 );

   // Draw a line between the two points.
   e->Graphics->DrawLine( Pens::Black, point1, point2 );
}
private void ShowPointConverter(PaintEventArgs e)
{

    // Create the PointConverter.
    System.ComponentModel.TypeConverter converter = 
        System.ComponentModel.TypeDescriptor.GetConverter(typeof(Point));

    Point point1 = (Point) converter.ConvertFromString("200, 200");

    // Use the subtraction operator to get a second point.
    Point point2 = point1 - new Size(190, 190);

    // Draw a line between the two points.
    e.Graphics.DrawLine(Pens.Black, point1, point2);
}
Private Sub ShowPointConverter(ByVal e As PaintEventArgs)

    ' Create the PointConverter.
    Dim converter As System.ComponentModel.TypeConverter = _
        System.ComponentModel.TypeDescriptor.GetConverter(GetType(Point))

    Dim point1 As Point = _
        CType(converter.ConvertFromString("200, 200"), Point)

    ' Use the subtraction operator to get a second point.
    Dim point2 As Point = Point.op_Subtraction(point1, _
        New Size(190, 190))

    ' Draw a line between the two points.
    e.Graphics.DrawLine(Pens.Black, point1, point2)
End Sub

Applies to