Graphics.ResetTransform Methode

Definition

Setzt die globale Transformationsmatrix dieses Graphics auf die Identitätsmatrix zurück.

public:
 void ResetTransform();
public void ResetTransform ();
member this.ResetTransform : unit -> unit
Public Sub ResetTransform ()

Beispiele

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgse, was ein Parameter des Paint Ereignishandlers ist. Der Code führt die folgenden Aktionen aus:

  • Übersetzt die Welttransformation von Windows Form durch einen Vektor (100, 0).

  • Speichert den Grafikzustand des Formulars.

  • Setzt die Welttransformation des Formulars auf eine Identität zurück und füllt ein Rechteck mit einem durchgehenden roten Pinsel.

  • Stellt den übersetzten Grafikzustand wieder her und füllt ein Rechteck mit einem einfarbigen blauen Pinsel aus.

Das Ergebnis ist ein nicht übersetztes rot gefülltes Rechteck und ein übersetztes blau gefülltes Rechteck.

public:
   void SaveRestore1( PaintEventArgs^ e )
   {
      // Translate transformation matrix.
      e->Graphics->TranslateTransform( 100, 0 );

      // Save translated graphics state.
      GraphicsState^ transState = e->Graphics->Save();

      // Reset transformation matrix to identity and fill rectangle.
      e->Graphics->ResetTransform();
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Red ), 0, 0, 100, 100 );

      // Restore graphics state to translated state and fill second
      // rectangle.
      e->Graphics->Restore( transState );
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 100, 100 );
   }
private void SaveRestore1(PaintEventArgs e)
{

    // Translate transformation matrix.
    e.Graphics.TranslateTransform(100, 0);

    // Save translated graphics state.
    GraphicsState transState = e.Graphics.Save();

    // Reset transformation matrix to identity and fill rectangle.
    e.Graphics.ResetTransform();
    e.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 100, 100);

    // Restore graphics state to translated state and fill second

    // rectangle.
    e.Graphics.Restore(transState);
    e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 100, 100);
}
Private Sub SaveRestore1(ByVal e As PaintEventArgs)

    ' Translate transformation matrix.
    e.Graphics.TranslateTransform(100, 0)

    ' Save translated graphics state.
    Dim transState As GraphicsState = e.Graphics.Save()

    ' Reset transformation matrix to identity and fill rectangle.
    e.Graphics.ResetTransform()
    e.Graphics.FillRectangle(New SolidBrush(Color.Red), 0, 0, 100, 100)

    ' Restore graphics state to translated state and fill second

    ' rectangle.
    e.Graphics.Restore(transState)
    e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _
    100, 100)
End Sub

Hinweise

Die Identitätsmatrix stellt eine Transformation ohne Skalierung, Drehung oder Übersetzung dar. Das Zurücksetzen der Welttransformation dieser Graphics auf die Identitätsmatrix bedeutet, dass die Welttransformation die Geometrie der transformierten Elemente nicht ändert.

Gilt für: