GraphicsUnit 列舉

定義

指定所指定資料的測量單位。

public enum class GraphicsUnit
public enum GraphicsUnit
type GraphicsUnit = 
Public Enum GraphicsUnit
繼承
GraphicsUnit

欄位

Display 1

指定顯示裝置的測量單位。 一般來說,視訊顯示會使用像素,而印表機會使用 1/100 英吋。

Document 5

指定文件單位 (1/300 英吋) 做為測量單位。

Inch 4

指定英吋做為測量單位。

Millimeter 6

指定公釐做為測量單位。

Pixel 2

指定裝置像素做為測量單位。

Point 3

指定印表機的點 (1/72 英吋) 做為測量單位。

World 0

指定全局座標系統的單位做為測量單位。

範例

下列程式碼範例示範如何使用 列舉從控制碼 GraphicsUnit 載入點陣圖 Icon ,以及使用 Round 方法來繪製點陣圖的矩形界限。

此範例的設計目的是要與Windows Forms搭配使用。 建立表單,其中包含名為 Button2 的按鈕。 將程式碼貼到表單中,並將這個方法與按鈕的事件 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

適用於