Graphics.ResetTransform Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Resetuje macierz transformacji świata tego Graphics do macierzy tożsamości.
public:
void ResetTransform();
public void ResetTransform ();
member this.ResetTransform : unit -> unit
Public Sub ResetTransform ()
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z formularzami Systemu Windows i wymaga PaintEventArgse
, który jest parametrem programu obsługi zdarzeń Paint. Kod wykonuje następujące akcje:
Przekształca świat formularza systemu Windows przez wektor (100, 0).
Zapisuje stan grafiki formularza.
Resetuje świat transformacji formularza do tożsamości i wypełnia prostokąt stałym czerwonym pędzlem.
Przywraca przetłumaczony stan grafiki i wypełnia prostokąt niebieskim pędzlem.
Wynik jest nieprzetłumaczonym czerwonym prostokątem i przetłumaczonym niebieskim prostokątem.
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
Uwagi
Macierz tożsamości reprezentuje transformację bez skalowania, rotacji ani tłumaczenia. Zresetowanie światowej transformacji tego Graphics do macierzy tożsamości oznacza, że jego transformacja światowa nie zmienia geometrii przekształconych elementów.
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla