GraphicsUnit 列挙型
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定のデータの長さの単位を指定します。
public enum class GraphicsUnit
public enum GraphicsUnit
type GraphicsUnit =
Public Enum GraphicsUnit
- 継承
名前 | 値 | 説明 |
---|---|---|
Display | 1 | 表示デバイスの長さの単位を指定します。 通常、ビデオ ディスプレイにはピクセル、プリンターには 1/100 インチを指定します。 |
Document | 5 | ドキュメント単位 (1/300 インチ) を長さの単位に指定します。 |
Inch | 4 | インチを長さの単位に指定します。 |
Millimeter | 6 | ミリメートルを長さの単位に指定します。 |
Pixel | 2 | デバイス ピクセルを長さの単位に指定します。 |
Point | 3 | プリンター ポイント (1/72 インチ) を長さの単位に指定します。 |
World | 0 | ワールド座標系を長さの単位に指定します。 |
次のコード例では、 列挙を使用してハンドルからビットマップを Icon 読み込み、 メソッドを使用して GraphicsUnit ビットマップの Round 四角形の境界を描画する方法を示します。
この例は、Windows フォームで使用するように設計されています。 Button2 という名前のボタンを含むフォームをCreateします。 コードをフォームに貼り付け、このメソッドをボタンの Click イベントに関連付けます。
void Button2_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Bitmap^ bitmap1 = Bitmap::FromHicon( SystemIcons::Hand->Handle );
Graphics^ formGraphics = this->CreateGraphics();
GraphicsUnit units = GraphicsUnit::Point;
RectangleF bmpRectangleF = bitmap1->GetBounds( units );
Rectangle bmpRectangle = Rectangle::Round( bmpRectangleF );
formGraphics->DrawRectangle( Pens::Blue, bmpRectangle );
delete formGraphics;
}
private void Button2_Click(System.Object sender, System.EventArgs e)
{
Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.Hand.Handle);
Graphics formGraphics = this.CreateGraphics();
GraphicsUnit units = GraphicsUnit.Point;
RectangleF bmpRectangleF = bitmap1.GetBounds(ref units);
Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF);
formGraphics.DrawRectangle(Pens.Blue, bmpRectangle);
formGraphics.Dispose();
}
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim bitmap1 As Bitmap = Bitmap.FromHicon(SystemIcons.Hand.Handle)
Dim formGraphics As Graphics = Me.CreateGraphics()
Dim units As GraphicsUnit = GraphicsUnit.Point
Dim bmpRectangleF As RectangleF = bitmap1.GetBounds(units)
Dim bmpRectangle As Rectangle = Rectangle.Round(bmpRectangleF)
formGraphics.DrawRectangle(Pens.Blue, bmpRectangle)
formGraphics.Dispose()
End Sub
製品 | バージョン |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。