Skip to content

TargetedHistory<TKey, TPixel>

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

public sealed class TargetedHistory<TKey, TPixel>

One undo/redo history across many surfaces: each step remembers WHICH surface it edited, so undoing restores that surface and says which one it was.

Type parameters

  • TKey - Identifies a surface.
  • TPixel - The pixel the surfaces store.

Remarks

The same contract as EditHistory<TPixel> (a no-op edit is not recorded, a new edit clears redo), keyed. The caller resolves a key to its surface at undo time, so surfaces may be created lazily and outlive whatever the page is currently showing.

Constructors

TargetedHistory()

public TargetedHistory();

Properties

CanRedo

public bool CanRedo { get; }

Whether an undone step is available to reapply.

CanUndo

public bool CanUndo { get; }

Whether there is an applied step to undo.

PeekRedo

public TKey? PeekRedo { get; }

The surface the next redo would touch, or default when there is none.

PeekUndo

public TKey? PeekUndo { get; }

The surface the next undo would touch, or default when there is none.

Methods

Clear()

public void Clear();

Forgets every step.

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

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

Applies a command to a surface and records it. A no-op edit is not recorded.

Parameters

  • key (TKey) - The surface's key.
  • cmd (IEditCommand<TPixel>) - The edit.
  • surface (IEditSurface<TPixel>) - The surface to edit.

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

Redo(Func<TKey, IEditSurface<TPixel>>, TKey)

public bool Redo(Func<TKey, IEditSurface<TPixel>> surfaceOf, out TKey key);

Reapplies the most recently undone step on the surface it touched.

Parameters

  • surfaceOf (Func<TKey, IEditSurface<TPixel>>) - Resolves a key to its surface.
  • key (TKey) - The surface that was edited.

Returns. False when there was nothing to redo.

Undo(Func<TKey, IEditSurface<TPixel>>, TKey)

public bool Undo(Func<TKey, IEditSurface<TPixel>> surfaceOf, out TKey key);

Undoes the most recent step on the surface it touched.

Parameters

  • surfaceOf (Func<TKey, IEditSurface<TPixel>>) - Resolves a key to its surface.
  • key (TKey) - The surface that was restored.

Returns. False when there was nothing to undo.