Point.Subtraction(Point, Size) 運算子
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
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
參數
傳回
範例
下列程式代碼範例示範如何使用 PointConverter 和 Subtraction 運算符。 此範例的設計目的是要與 Windows Forms 搭配使用。 將此程式代碼貼到表單中,並在處理表單的事件Paint時呼叫 ShowPointConverter
方法,並傳遞e
為 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