Skip to content

EditHistory<TPixel>

Namespace Nfty.Core.Editing in assembly Nfty.Core.

public sealed class EditHistory<TPixel>

Undo/redo stack of reversible edit commands over one surface.

Type parameters

  • TPixel - The pixel that surface stores.

Constructors

EditHistory()

public EditHistory();

Properties

CanRedo

public bool CanRedo { get; }

Whether an undone command is available to reapply.

CanUndo

public bool CanUndo { get; }

Whether there is an applied command to undo.

Methods

Do(IEditCommand<TPixel>, IEditSurface<TPixel>)

public bool Do(IEditCommand<TPixel> cmd, IEditSurface<TPixel> surface);

Applies cmd and records it for undo. A no-op edit (Apply reports no pixel changed) is not recorded and returns false, so CanUndo does not light for an edit that produced nothing.

Parameters

  • cmd (IEditCommand<TPixel>) - The edit to apply.
  • surface (IEditSurface<TPixel>) - The surface to edit.

Returns. True when the edit changed something and was recorded.

Redo(IEditSurface<TPixel>)

public void Redo(IEditSurface<TPixel> surface);

Reapplies the most recently undone command.

Parameters

  • surface (IEditSurface<TPixel>) - The surface to edit.

Undo(IEditSurface<TPixel>)

public void Undo(IEditSurface<TPixel> surface);

Undoes the most recent command.

Parameters

  • surface (IEditSurface<TPixel>) - The surface to restore.