Graphics.EndContainer メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Graphics.EndContainer メソッドの意味・解説 

Graphics.EndContainer メソッド

現在のグラフィックス コンテナ閉じ、この Graphics の状態を、BeginContainer メソッド呼び出すことによって保存されていた状態に復元します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub EndContainer ( _
    container As GraphicsContainer _
)
Dim instance As Graphics
Dim container As GraphicsContainer

instance.EndContainer(container)
public void EndContainer (
    GraphicsContainer container
)
public:
void EndContainer (
    GraphicsContainer^ container
)
public void EndContainer (
    GraphicsContainer container
)
public function EndContainer (
    container : GraphicsContainer
)

パラメータ

container

このメソッド復元されるコンテナを表す GraphicsContainer。

解説解説

入れ子グラフィックス コンテナ作成するには、このメソッドと共に BeginContainer メソッド使用しますグラフィックス コンテナは、変換クリッピング領域レンダリング プロパティなど、グラフィックスの状態を保持します

GraphicsBeginContainer メソッド呼び出すと、Graphics の状態を保持している情報ブロックスタック格納されます。BeginContainer メソッドは、その情報ブロック識別する GraphicsContainer返します識別対象オブジェクトEndContainer メソッドに渡すと、情報ブロックスタックから削除されGraphicsBeginContainer メソッド呼び出し時の状態に復元するために使用されます。

コンテナ入れ子できます。つまり、EndContainer メソッド呼び出す前にBeginContainer メソッド複数呼び出すことができますBeginContainer メソッド呼び出すたびに、情報ブロックスタック格納され、その情報ブロックGraphicsContainer受け取ります。これらのオブジェクト1 つEndContainer メソッドに渡すと、Graphics は、その GraphicsContainer返した BeginContainer メソッド呼び出し時の状態に戻ります。その BeginContainer メソッド呼び出しによってスタック置かれ情報ブロックスタックから削除されます。さらに、BeginContainer メソッド呼び出し後にスタック置かれすべての情報ブロック削除されます。

Save メソッド呼び出しは、BeginContainer メソッド呼び出しと同じスタック情報ブロック配置しますEndContainer メソッド呼び出しBeginContainer メソッド呼び出しと対になっているのと同様にRestore メソッド呼び出しSave メソッド呼び出しと対になってます。

EndContainer メソッド呼び出すと、対応する BeginContainer メソッド呼び出し後に (Save メソッドまたは BeginContainer メソッドによって) スタック格納されすべての情報ブロックが、スタックから削除されます。同様にRestore メソッド呼び出すと、対応する BeginContainer メソッド呼び出し後に (Save メソッドまたは Save メソッドによって) スタック格納されすべての情報ブロックが、スタックから削除されます。

使用例使用例

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

緑の四角形が同じサイズの赤い四角形の上重ねられます。

Public Sub EndContainerState(ByVal
 e As PaintEventArgs)

    ' Begin graphics container.
    Dim containerState As GraphicsContainer
 = _
    e.Graphics.BeginContainer()

    ' Translate world transformation.
    e.Graphics.TranslateTransform(100.0F, 100.0F)

    ' Fill translated rectangle in container with red.
    e.Graphics.FillRectangle(New SolidBrush(Color.Red), 0, 0,
 _
    200, 200)

    ' End graphics container.
    e.Graphics.EndContainer(containerState)

    ' Fill untransformed rectangle with green.
    e.Graphics.FillRectangle(New SolidBrush(Color.Green), 0, 0,
 _
    200, 200)
End Sub
public void EndContainerState(PaintEventArgs
 e)
{
             
    // Begin graphics container.
    GraphicsContainer containerState = e.Graphics.BeginContainer();
             
    // Translate world transformation.
    e.Graphics.TranslateTransform(100.0F, 100.0F);
             
    // Fill translated rectangle in container with red.
    e.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0,
 200, 200);
             
    // End graphics container.
    e.Graphics.EndContainer(containerState);
             
    // Fill untransformed rectangle with green.
    e.Graphics.FillRectangle(new SolidBrush(Color.Green), 0, 0,
 200, 200);
}
public:
   void EndContainerState( PaintEventArgs^ e )
   {
      // Begin graphics container.
      GraphicsContainer^ containerState = e->Graphics->BeginContainer();

      // Translate world transformation.
      e->Graphics->TranslateTransform( 100.0F, 100.0F );

      // Fill translated rectangle in container with red.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Red ), 0, 0, 200,
 200 );

      // End graphics container.
      e->Graphics->EndContainer( containerState );

      // Fill untransformed rectangle with green.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Green ), 0, 0, 200,
 200 );
   }
public void EndContainerState(PaintEventArgs
 e) 
{
    // Begin graphics container.
    GraphicsContainer containerState = e.get_Graphics().BeginContainer();

    // Translate world transformation.
    e.get_Graphics().TranslateTransform(100, 100);

    // Fill translated rectangle in container with red.
    e.get_Graphics().FillRectangle(new SolidBrush(Color.get_Red()),
 0, 0,
        200, 200);

    // End graphics container.
    e.get_Graphics().EndContainer(containerState);

    // Fill untransformed rectangle with green.
    e.get_Graphics().FillRectangle(new SolidBrush(Color.get_Green()),
 0, 0,
        200, 200);
} //EndContainerState
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からGraphics.EndContainer メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からGraphics.EndContainer メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からGraphics.EndContainer メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Graphics.EndContainer メソッド」の関連用語

Graphics.EndContainer メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Graphics.EndContainer メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS