Click or drag to resize

GraphicsSaveTransformState Method

Gets an object that will restore to the current transform state when disposed.

Namespace:  Eto.Drawing
Assembly:  Eto (in Eto.dll) Version: 2.4.0
public IDisposable SaveTransformState()

Return Value

Type: IDisposable

[Missing <returns> documentation for "M:Eto.Drawing.Graphics.SaveTransformState"]

This saves the current transform state that can be changed by any of the transform calls. This is useful when calling into untrusted code that can leave the transform unbalanced. It also ensures that RestoreTransform() requires a matching SaveTransform(), until the return value is disposed. Disposing the return value guarantees that the transform state is restored to when this method was called.
This example shows how you can reliably restore state in a code block:
using (graphics.SaveTransformState())
    // ...


    // ... other messy drawing code that doesn't call RestoreTransform()
See Also