GraphicsUnit Wyliczenie

Definicja

Określa jednostkę miary dla danych.

public enum class GraphicsUnit
public enum GraphicsUnit
type GraphicsUnit = 
Public Enum GraphicsUnit
Dziedziczenie
GraphicsUnit

Pola

Display 1

Określa jednostkę miary urządzenia wyświetlania. Zazwyczaj piksele wyświetlaczy wideo i 1/100 cala dla drukarek.

Document 5

Określa jednostkę dokumentu (1/300 cala) jako jednostkę miary.

Inch 4

Określa cal jako jednostkę miary.

Millimeter 6

Określa milimetr jako jednostkę miary.

Pixel 2

Określa piksel urządzenia jako jednostkę miary.

Point 3

Określa punkt drukarki (1/72 cala) jako jednostkę miary.

World 0

Określa jednostkę układu współrzędnych świata jako jednostkę miary.

Przykłady

W poniższym przykładzie kodu pokazano, jak załadować mapę bitową z Icon uchwytu, przy użyciu GraphicsUnit wyliczenia oraz użyć Round metody , aby narysować granice prostokąta mapy bitowej.

Ten przykład jest przeznaczony do użycia z Windows Forms. Utwórz formularz zawierający przycisk o nazwie Button2. Wklej kod do formularza i skojarz tę metodę ze zdarzeniem przycisku 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

Dotyczy