PointConverter クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Point オブジェクトをあるデータ型から別のデータ型に変換します。
public ref class PointConverter : System::ComponentModel::TypeConverter
public class PointConverter : System.ComponentModel.TypeConverter
type PointConverter = class
inherit TypeConverter
Public Class PointConverter
Inherits TypeConverter
- 継承
例
次のコード例では、 PointConverter 演算子と Subtraction 演算子を使用する方法を示します。 この例は、Windows フォームで使用するように設計されています。 フォームにこのコードを貼り付け、フォームの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
注釈
PointConverter クラスは、通常、Point型のプロパティを持つコントロールのデザイン時エクスペリエンスを作成するために使用され、デザイナーに表示するためにポイントを文字列に変換したり、デザイナーに入力された文字列をPoint オブジェクトに変換したりするために使用されます。 TypeDescriptor オブジェクトを使用してこのクラスにアクセスします。
コンストラクター
| 名前 | 説明 |
|---|---|
| PointConverter() |
PointConverter クラスの新しいインスタンスを初期化します。 |