Graphics.Save Method ()
Assembly: System.Drawing (in System.Drawing.dll)
When you call the Graphics, an information block that holds the state of the Graphics is put on a stack. The method returns a GraphicsState that identifies that information block. When you pass the identifying GraphicsState to the Restore method, the information block is removed from the stack and is used to restore the Graphics to the state it was in at the time of the method call. Note that the GraphicsState returned by a given call to the method can be passed only once to the Restore method.method of a
Calls to the Restore method. Each time you call the method, an information block is put on the stack, and you receive aGraphicsState for the information block. When you pass one of those objects to the Restore method, the Graphics is returned to the state it was in at the time of the method call that returned that particular GraphicsState. The information block placed on the stack by that method call is removed from the stack, and all information blocks placed on that stack after that method call are also removed.method can be nested; that is, you can call the method several times before you call the
Calls to the BeginContainer method place information blocks on the same stack as calls to the method. Just as a Restore call is paired with a call, a EndContainer method call is paired with a BeginContainer method call.
When you call the Restore method, all information blocks placed on the stack (by the method or by the BeginContainer method) after the corresponding call to the method are removed from the stack. Likewise, When you call the EndContainer method, all information blocks placed on the stack (by the method or by the BeginContainer method) after the corresponding call to the BeginContainer method are removed from the stack.
Translates the world transform of the Windows Form by a vector (100, 0).
Saves the graphics state of the form.
Resets the world transform of the form to an identity (2x2 identity matrix plus a zero-vector translation) and fills a rectangle with a solid red brush.
Restores the translated graphics state and fills a rectangle with a solid blue brush.
The result is an untranslated red-filled rectangle on the left and a translated blue-filled rectangle on the right of the form.
Available since 1.1