Point.Subtraction(Point, Size) 演算子

定義

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

パラメーター

pt
Point

移動する PointThe Point to translate.

sz
Size

Size の座標から減算する数の組み合わせを指定する ptA 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.

次のコード例は、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 メソッドを呼び出して、ePaintEventArgsとして渡します。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

適用対象