Graphics.ResetTransform Metodo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Reimposta la matrice di trasformazione globale di questo Graphics alla matrice di identità.
public:
void ResetTransform();
public void ResetTransform();
member this.ResetTransform : unit -> unit
Public Sub ResetTransform ()
L'esempio di codice seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse
, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:
Converte la trasformazione globale di Windows Form da un vettore (100, 0).
Salva lo stato grafico del form.
Reimposta la trasformazione globale del modulo in un'identità e riempie un rettangolo con un pennello rosso a tinta unita.
Ripristina lo stato della grafica tradotta e riempie un rettangolo con un pennello blu a tinta unita.
Il risultato è un rettangolo con riempimento rosso non convertito e un rettangolo con riempimento blu convertito.
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
La matrice di identità rappresenta una trasformazione senza ridimensionamento, rotazione o traslazione. La reimpostazione della trasformazione globale di questa Graphics nella matrice di identità significa che la trasformazione globale non modifica la geometria degli elementi trasformati.
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: