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 窗体 一起使用。 将此代码粘贴到窗体中, ShowPointConverter
并在处理窗体 Paint 的事件时调用 方法,作为 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