Upravit

Sdílet prostřednictvím


SKAutoCanvasRestore Class

Definition

Convenience class used to restore the canvas state in a using statement.

public class SKAutoCanvasRestore : IDisposable
Inheritance
SKAutoCanvasRestore
Implements

Examples

SKCanvas canvas = ...;

using (new SKAutoCanvasRestore(canvas)) {
    // perform some transform
    canvas.RotateDegrees(45);

    // draw as usual
    var paint = new SKPaint ();
    canavs.DrawRect (10, 10, 100, 100, paint);

    // automatically restore to original transform
}

Remarks

This class can be used in a using statement to save the state of the canvas (matrix, clip and draw filter) allowing you to change these components and have them automatically undone by virtue of having the Dispose() method restore the canvas state to the state it was when this instance was created.

Constructors

SKAutoCanvasRestore(SKCanvas, Boolean)

Creates a canvas restore point.

SKAutoCanvasRestore(SKCanvas)

Creates a canvas restore point, invoking the Save() method.

Methods

Dispose()

Disposes the canvas restore point, restoring the state of the canvas (matrix, clip and draw filter) to the state it was when the object was created.

This operation will not do anything if you had previously manually called the Restore() method.

Restore()

Restores the canvas restore point, restoring the state of the canvas (matrix, clip and draw filter) to the state it was when the object was creatd.

Applies to