Point.Subtraction(Point, Size) Point.Subtraction(Point, Size) Point.Subtraction(Point, Size) Point.Subtraction(Point, Size) Operator

定義

根據指定 Point 的負數來轉換 SizeTranslates 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

參數

pt
Point Point Point Point

要轉換的 PointThe Point to translate.

sz
Size Size Size Size

Size,指定要減去 pt 座標的數字配對。A Size that specifies the pair of numbers to subtract from the coordinates of pt.

傳回

Point 結構,由指定的 Size 結構的負數所轉譯。A Point structure that is translated by the negative of a given Size structure.

範例

下列程式碼範例示範如何使用PointConverter Subtraction和運算子。The following code example demonstrates how to use the PointConverter and the Subtraction operator. 這個範例是設計來與 Windows Forms 搭配使用。This example is designed to be used with Windows Forms. 將此程式碼貼入表單, 並ShowPointConverter在處理表單的Paint事件時呼叫方法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

適用於