Freigeben über


GraphicsUnit-Enumeration

Gibt die Maßeinheit für die angegebenen Daten an.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Enumeration GraphicsUnit
'Usage
Dim instance As GraphicsUnit
public enum GraphicsUnit
public enum class GraphicsUnit
public enum GraphicsUnit
public enum GraphicsUnit

Member

  Membername Beschreibung
Display Gibt die Maßeinheit des Anzeigegerätes an. Für Bildschirme ist dies i. d. R. Pixel und 1/100 Zoll für Drucker. 
Document Gibt die Dokumenteinheit (1/300 Zoll) als Maßeinheit an. 
Inch Gibt Zoll als Maßeinheit an. 
Millimeter Gibt Millimeter als Maßeinheit an. 
Unterstützt von .NET Compact Framework Pixel Gibt ein Gerätepixel als Maßeinheit an. 
Point Gibt einen Druckerpunkt (1/72 Zoll) als Maßeinheit an. 
World Gibt die Einheit des globalen Koordinatensystems als Maßeinheit an. 

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie mithilfe der GraphicsUnit-Enumeration eine Bitmap über ein Icon-Handle geladen und die Round-Methode zum Zeichnen des umschließenden Rechtecks einer Bitmap verwendet wird.

Dieses Beispiel ist für die Verwendung mit Windows Forms vorgesehen. Erstellen Sie ein Formular, das eine Schaltfläche mit dem Namen Button2 enthält. Fügen Sie den Code in das Formular ein, und ordnen Sie diese Methode dem Click-Ereignis der Schaltfläche zu.

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
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();
}
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.get_Hand().get_Handle());
    Graphics formGraphics = this.CreateGraphics();
    GraphicsUnit units = GraphicsUnit.Point;
    RectangleF bmpRectangleF = bitmap1.GetBounds(units);
    Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF);

    formGraphics.DrawRectangle(Pens.get_Blue(), bmpRectangle);
    formGraphics.Dispose();
} //button2_Click

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

System.Drawing-Namespace