PointConverter 类

Point 对象从一种数据类型转换为另一种数据类型。通过 TypeDescriptor 对象访问此类。

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Class PointConverter
    Inherits TypeConverter
用法
Dim instance As PointConverter
public class PointConverter : TypeConverter
public ref class PointConverter : public TypeConverter
public class PointConverter extends TypeConverter
public class PointConverter extends TypeConverter

示例

下面的代码示例演示如何使用 PointConverterop_Subtraction 运算符。此示例是针对使用 Windows 窗体而设计的。将此代码粘贴到一个窗体中,然后在处理窗体的 Paint 事件时调用 ShowPointConverter 方法,将 e 作为 PaintEventArgs 传递。

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
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);
}
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.
    PointConverter converter = new PointConverter();
    Point point1 = (Point)converter.ConvertFromString("200, 200");

    // Use the subtraction operator to get a second point.
    Point point2 = Point.op_Subtraction(point1 , new Size(190, 190));

    // Draw a line between the two points.
    e.get_Graphics().DrawLine(Pens.get_Black(), point1, point2);
} //ShowPointConverter

继承层次结构

System.Object
   System.ComponentModel.TypeConverter
    System.Drawing.PointConverter

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

PointConverter 成员
System.Drawing 命名空间