Class History

The History API is disabled by default. It includes methods to undo and redo annotation operations: creation, updates and deletions may be reverted and restored by means of this API.

The implementation does not fully revert an annotation to its previous state:

  • The UpdatedAt field will have changed to the current time.

  • If an annotation deletion is undone, the restored annotation will have a different id than the original.

  • If an annotation deletion is undone, the restored annotation will appear at the front, regardless of its original stacking position.

  • Annotation changes that only affect the UpdatedAt property are not tracked, and the updated annotation is considered identical to the previous one in this case.

The feature only accounts for annotations modified locally, whether using the API or the toolbar UndoAsync and RedoAsync buttons.If an annotation is modified externally, by another Instant client, for example, undoing will not revert the annotation state to the one just before the external change, but to the previous to that one: external annotation operations are not undone, but overridden.

Annotation operations performed while the History API is disabled can also be considered external for that effect. This is also the case for annotation operations that result from Instant Comments changes, like deleting the last comment of a comment thread, which results on the comment marker being deleted, and which cannot therefore be undone. However, comment markers directly deleted with the API may be restored with its former comments.

Annotation presets are not restored by undo and redo operations.

Inheritance
System.Object
History
Namespace: PSPDFKit.Document
Assembly: PSPDFKit.dll
Syntax
public sealed class History

Methods

CanRedoAsync()

Returns true if it's possible to redo a previously undone operation, false otherwise, also if the History API is disabled.

Declaration
public IAsyncOperation<bool> CanRedoAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

Boolean representing if redo action can be performed

CanUndoAsync()

Returns true if it's possible to undo a previous operation, false otherwise, also if the History API is disabled.

Declaration
public IAsyncOperation<bool> CanUndoAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

Boolean representing if undo action can be performed

ClearAsync()

Removes all undoable and redoable operations available.

Declaration
public IAsyncAction ClearAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

DisableAsync()

Disables the History API: attempting to undo or redo previous operations with the API or the UI will not be possible, but the previous undoable and redoable operations will be preserved, and available if the History API is enabled again.

Declaration
public IAsyncAction DisableAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

Asynchronous action responsible for disabling History APIs.

EnableAsync()

Enables the History API, making undoing and redoing possible. If there were previous undoable or redoable operations, they will be now available.

Declaration
public IAsyncAction EnableAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

Asynchronous action responsible for enabling History APIs.

RedoAsync()

When called, the last undone annotation operation will be performed again.

Note that if an annotation deletion has been undone, and then redone by calling this function, it will reappear in front of any other annotations, even if that was not its original stacking order.

Returns true if the operation has been redone successfully, false if there are no redoable operations available or the History API is disabled.

Declaration
public IAsyncOperation<bool> RedoAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

The result of the redo operation.

UndoAsync()

When called, the last local annotation operation will be reverted. The outcome will vary depending on the type of that operation:

  • Annotation creation: the annotation will be deleted.
  • Annotation modification: the previous state of the annotation will be reverted.
  • Annotation deletion: the annotation will be restored.

Note that if a deleted annotation is restored by calling this function, it will reappear in front of any other annotations, even if that was not its original stacking order.

Returns true if the operation has been undone successfully, false if there are no undoable operations available or the History API is disabled.

Declaration
public IAsyncOperation<bool> UndoAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

The result of the undo operation.

Events

Cleared

Occurs after calling ClearAsync().

Declaration
public event TypedEventHandler<History, object> Cleared
Event Type
Type Description
Windows.Foundation.TypedEventHandler<History, System.Object>

HistoryChanged

Occurs after calling UndoAsync() or RedoAsync() or after pressing the main toolbar Undo or Redo button, which are optionally available.

Declaration
public event TypedEventHandler<History, HistoryEventArgs> HistoryChanged
Event Type
Type Description
Windows.Foundation.TypedEventHandler<History, HistoryEventArgs>

RedoEvent

Occurs after calling RedoAsync() or after pressing the main toolbar Redo button, which is optionally available.

Declaration
public event TypedEventHandler<History, HistoryEventArgs> RedoEvent
Event Type
Type Description
Windows.Foundation.TypedEventHandler<History, HistoryEventArgs>

UndoEvent

Occurs after calling UndoAsync() or after pressing the main toolbar Undo button, which is optionally available.

Declaration
public event TypedEventHandler<History, HistoryEventArgs> UndoEvent
Event Type
Type Description
Windows.Foundation.TypedEventHandler<History, HistoryEventArgs>