Graphics.ResetTransform Metoda

Definice

Resetuje svět transformační matici této Graphics matice na matici identit.

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

Příklady

Následující příklad kódu je určen pro použití s model Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny Paint události. Kód provede následující akce:

  • Přeloží světovou transformaci formuláře Windows Pomocí vektoru (100, 0).

  • Uloží stav grafiky formuláře.

  • Obnoví světovou transformaci formuláře na identitu a vyplní obdélník plným červeným štětcem.

  • Obnoví přeložený grafický stav a vyplní obdélník plným modrým štětcem.

Výsledkem je nepřelládaný červeně vyplněný obdélník a přeložený obdélník s modrou výplní.

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

Poznámky

Matice identit představuje transformaci bez škálování, obměně nebo překladu. Resetování světové transformace této Graphics transformace na matici identit znamená, že její transformace světa nezmění geometrii transformovaných položek.

Platí pro