Point.Subtraction(Point, Size) Operatore

Definizione

Converte un oggetto Point in base al valore negativo di un oggetto specificato 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

Parametri

pt
Point

Oggetto Point da tradurre.

sz
Size

Oggetto Size che specifica la coppia di numeri da sottrarre dalle coordinate di pt.

Valori restituiti

Struttura Point tradotta dal valore negativo di una determinata Size struttura.

Esempio

Nell'esempio di codice seguente viene illustrato come usare e PointConverter l'operatore Subtraction . Questo esempio è progettato per essere usato con Windows Form. Incollare questo codice in una maschera e chiamare il metodo quando si gestisce l'evento ShowPointConverter del Paint modulo, passando e come 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

Si applica a