RectangleF コンストラクタ (Single, Single, Single, Single)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文Dim x As Single Dim y As Single Dim width As Single Dim height As Single Dim instance As New RectangleF(x, y, width, height)
使用例RectangleF メンバ、Round メンバ、および Truncate メンバの使用方法を示すコード例を次に示します。この例は、Windows フォームでの使用を意図してデザインされています。このコードをフォームに貼り付け、フォームの Paint イベントを処理するときに PaintEventArgs の e を渡して RoundingAndTruncatingRectangles メソッドを呼び出します。
Private Sub RoundingAndTruncatingRectangles( _ ByVal e As PaintEventArgs) ' Construct a new RectangleF. Dim myRectangleF As New RectangleF(30.6F, 30.7F, 40.8F, 100.9F) ' Call the Round method. Dim roundedRectangle As Rectangle = Rectangle.Round(myRectangleF) ' Draw the rounded rectangle in red. Dim redPen As New Pen(Color.Red, 4) e.Graphics.DrawRectangle(redPen, roundedRectangle) ' Call the Truncate method. Dim truncatedRectangle As Rectangle = _ Rectangle.Truncate(myRectangleF) ' Draw the truncated rectangle in white. Dim whitePen As New Pen(Color.White, 4) e.Graphics.DrawRectangle(whitePen, truncatedRectangle) ' Dispose of the custom pens. redPen.Dispose() whitePen.Dispose() End Sub
private void RoundingAndTruncatingRectangles(PaintEventArgs e) { // Construct a new RectangleF. RectangleF myRectangleF = new RectangleF(30.6F, 30.7F, 40.8F, 100.9F); // Call the Round method. Rectangle roundedRectangle = Rectangle.Round(myRectangleF); // Draw the rounded rectangle in red. Pen redPen = new Pen(Color.Red, 4); e.Graphics.DrawRectangle(redPen, roundedRectangle); // Call the Truncate method. Rectangle truncatedRectangle = Rectangle.Truncate(myRectangleF); // Draw the truncated rectangle in white. Pen whitePen = new Pen(Color.White, 4); e.Graphics.DrawRectangle(whitePen, truncatedRectangle); // Dispose of the custom pens. redPen.Dispose(); whitePen.Dispose(); }
private: void RoundingAndTruncatingRectangles( PaintEventArgs^ e ) { // Construct a new RectangleF. RectangleF myRectangleF = RectangleF(30.6F,30.7F,40.8F,100.9F); // Call the Round method. Rectangle roundedRectangle = Rectangle::Round( myRectangleF ); // Draw the rounded rectangle in red. Pen^ redPen = gcnew Pen( Color::Red,4.0f ); e->Graphics->DrawRectangle( redPen, roundedRectangle ); // Call the Truncate method. Rectangle truncatedRectangle = Rectangle::Truncate( myRectangleF ); // Draw the truncated rectangle in white. Pen^ whitePen = gcnew Pen( Color::White,4.0f ); e->Graphics->DrawRectangle( whitePen, truncatedRectangle ); // Dispose of the custom pens. delete redPen; delete whitePen; }
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照RectangleF コンストラクタ (PointF, SizeF)
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
使用例op_Implicit メンバ、RectangleF メンバ、および op_Equality メンバの使用方法を示すコード例を次に示します。この例は、Windows フォームでの使用を意図してデザインされています。このコードをフォームに貼り付け、フォームの Paint イベントを処理するときに PaintEventArgs の e を渡して ConvertRectangleToRectangleF メソッドを呼び出します。
Private Sub ConvertRectangleToRectangleF( _ ByVal e As PaintEventArgs) ' Create a rectangle. Dim rectangle1 As New Rectangle(30, 40, 50, 100) ' Convert it to a RectangleF. Dim convertedRectangle As RectangleF = _ RectangleF.op_Implicit(rectangle1) ' Create a new RectangleF. Dim rectangle2 As New RectangleF(New PointF(30.0F, 40.0F), _ New SizeF(50.0F, 100.0F)) ' Create a custom, partially transparent brush. Dim redBrush As New SolidBrush(Color.FromArgb(40, Color.Red)) ' Compare the converted rectangle with the new one. If they ' are equal, draw and fill the rectangles on the form. If (RectangleF.op_Equality(convertedRectangle, rectangle2)) Then e.Graphics.FillRectangle(redBrush, rectangle2) End If ' Dispose of the custom brush. redBrush.Dispose() End Sub
private void ConvertRectangleToRectangleF(PaintEventArgs e) { // Create a rectangle. Rectangle rectangle1 = new Rectangle(30, 40, 50, 100); // Convert it to a RectangleF. RectangleF convertedRectangle = rectangle1; // Create a new RectangleF. RectangleF rectangle2 = new RectangleF(new PointF(30.0F, 40.0F), new SizeF(50.0F, 100.0F)); // Create a custom, partially transparent brush. SolidBrush redBrush = new SolidBrush(Color.FromArgb(40, Color.Red)); // Compare the converted rectangle with the new one. If they // are equal draw and fill the rectangles on the form. if (convertedRectangle == rectangle2) { e.Graphics.FillRectangle(redBrush, rectangle2); } // Dispose of the custom brush. redBrush.Dispose(); }
private: void ConvertRectangleToRectangleF( PaintEventArgs^ e ) { // Create a rectangle. Rectangle rectangle1 = Rectangle(30,40,50,100); // Convert it to a RectangleF. RectangleF convertedRectangle = rectangle1; // Create a new RectangleF. RectangleF rectangle2 = RectangleF(PointF(30.0F,40.0F),SizeF(50.0F,100.0F)); // Create a custom, partially transparent brush. SolidBrush^ redBrush = gcnew SolidBrush( Color::FromArgb( 40, Color::Red ) ); // Compare the converted rectangle with the new one. If they // are equal draw and fill the rectangles on the form. if ( convertedRectangle == rectangle2 ) { e->Graphics->FillRectangle( redBrush, rectangle2 ); } // Dispose of the custom brush. delete redBrush; } };
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照RectangleF コンストラクタ
オーバーロードの一覧| 名前 | 説明 |
|---|---|
| RectangleF (PointF, SizeF) | 指定した位置とサイズで、RectangleF クラスの新しいインスタンスを初期化します。 |
| RectangleF (Single, Single, Single, Single) | 指定した位置とサイズで、RectangleF クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
参照RectangleF フィールド
RectangleF プロパティ
RectangleF メソッド
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Contains | オーバーロードされます。 指定した点が RectangleF 構造体に含まれているかどうかを判断します。 |
| Equals | オーバーロードされます。 オーバーライドされます。 2 つの RectangleF オブジェクトが等しいかどうかを判断します。 |
| FromLTRB | 左上隅および右下隅が指定の位置に設定された RectangleF 構造体を作成します。 |
| GetHashCode | オーバーライドされます。 この RectangleF 構造体のハッシュ コードを取得します。ハッシュ コードの使い方の詳細については、Object.GetHashCodeのトピックを参照してください。 |
| GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
| Inflate | オーバーロードされます。 この RectangleF を指定の量だけ膨らませます。 |
| Intersect | オーバーロードされます。 2 つの四角形の交差部分を表す RectangleF 構造体を確認します。 |
| IntersectsWith | この四角形が rect と交差するかどうかを判断します。 |
| Offset | オーバーロードされます。 四角形の位置を指定した量によって調節します。 |
| op_Equality | 2 つの RectangleF 構造体の位置およびサイズが同じかどうかをテストします。 |
| op_Implicit | 指定した Rectangle 構造体を RectangleF 構造体に変換します。 |
| op_Inequality | 2 つの RectangleF 構造体の位置またはサイズが異なるかどうかをテストします。 |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
| ToString | オーバーライドされます。 この RectangleF の Location および Size をユーザーが判読できる文字列に変換します。 |
| Union | 和集合を形成する 2 つの四角形の両方を含めることができる最小の 3 番目の四角形を作成します。 |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
参照RectangleF メンバ
四角形の位置とサイズを表す 4 つの浮動小数点数を格納します。より高度な領域関数を使用する場合は Region オブジェクトを使用します。
RectangleF データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック フィールド
パブリック プロパティ
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Contains | オーバーロードされます。 指定した点が RectangleF 構造体に含まれているかどうかを判断します。 |
| Equals | オーバーロードされます。 オーバーライドされます。 2 つの RectangleF オブジェクトが等しいかどうかを判断します。 |
| FromLTRB | 左上隅および右下隅が指定の位置に設定された RectangleF 構造体を作成します。 |
| GetHashCode | オーバーライドされます。 この RectangleF 構造体のハッシュ コードを取得します。ハッシュ コードの使い方の詳細については、Object.GetHashCodeのトピックを参照してください。 |
| GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
| Inflate | オーバーロードされます。 この RectangleF を指定の量だけ膨らませます。 |
| Intersect | オーバーロードされます。 2 つの四角形の交差部分を表す RectangleF 構造体を確認します。 |
| IntersectsWith | この四角形が rect と交差するかどうかを判断します。 |
| Offset | オーバーロードされます。 四角形の位置を指定した量によって調節します。 |
| op_Equality | 2 つの RectangleF 構造体の位置およびサイズが同じかどうかをテストします。 |
| op_Implicit | 指定した Rectangle 構造体を RectangleF 構造体に変換します。 |
| op_Inequality | 2 つの RectangleF 構造体の位置またはサイズが異なるかどうかをテストします。 |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
| ToString | オーバーライドされます。 この RectangleF の Location および Size をユーザーが判読できる文字列に変換します。 |
| Union | 和集合を形成する 2 つの四角形の両方を含めることができる最小の 3 番目の四角形を作成します。 |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
参照RectangleF 構造体
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
解説
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- RectangleFのページへのリンク