Graphics.ResetTransform メソッド

定義

この Graphics のワールド変換マトリックスを ID 行列にリセットします。

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

次のコード例は、Windows フォームで使用するように設計されており、PaintEventArgse が必要です。これは、Paint イベント ハンドラーのパラメーターです。 コードは次のアクションを実行します。

  • Windowsフォームのワールド変換をベクトル (100, 0) で変換します。

  • フォームのグラフィックス状態を保存します。

  • フォームのワールド変換を ID にリセットし、単色の赤いブラシで四角形を塗りつぶします。

  • 翻訳されたグラフィックスの状態を復元し、四角形に青い純色のブラシを塗りつぶします。

結果は、未翻訳の赤塗りの四角形と、青で塗りつぶされた変換された四角形になります。

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

注釈

ID 行列は、スケーリング、回転、または平行移動のない変換を表します。 この Graphics のワールド変換を ID 行列にリセットすることは、ワールド変換によって変換された項目のジオメトリが変更されないことを意味します。

適用対象