Interface IUndoBuffer
Information about the undo/redo commands for content changes in the edit control.
Namespace: SdlSdl.DesktopEditorEditorApi
Assembly: Sdl.DesktopEditor.EditorApi.dll
Syntax
public interface IUndoBuffer
Remarks
All operations that change the content of the edit control are inserted in the undo buffer.
Once the Undo command for an operation is executed the operation can be re-executed through the Redo command, however if an other edit operation is performed all Redo operations are removed from the buffer and can no longer be executed.
Properties
AbortMessage
When a composite operation is being aborted this property contains the message that explains to the user why the operation is not permitted.
Declaration
string AbortMessage { get; }
Property Value
Type | Description |
---|---|
string |
See Also
CanRedo
true
if there is at least one operation in the buffer that can be re-done
(after an Undo operation).
Declaration
bool CanRedo { get; }
Property Value
Type | Description |
---|---|
bool |
CanUndo
true
if there is at least one operation in the buffer that can be un-done.
Declaration
bool CanUndo { get; }
Property Value
Type | Description |
---|---|
bool |
Count
Total number of undo plus redo operations in the buffer.
Declaration
long Count { get; }
Property Value
Type | Description |
---|---|
long |
IsAbortingCompositeOperation
true
if the current composite operation is flagged for aborting.
Declaration
bool IsAbortingCompositeOperation { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
If this is true
the reason the operation is being aborted
can be retrieved from the AbortMessage property.
See Also
IsCurrentlyOperating
Flag that determines whether the undo buffer is currently in operation so that external operations can ignore changes, etc.
Declaration
bool IsCurrentlyOperating { get; }
Property Value
Type | Description |
---|---|
bool |
IsSource
Flag to determine if buffer is in source mode. If true, all added commands get the IsSource flag set.
Declaration
bool IsSource { get; set; }
Property Value
Type | Description |
---|---|
bool |
RedoOperationCount
The number of operations that can be re-done.
Declaration
long RedoOperationCount { get; }
Property Value
Type | Description |
---|---|
long |
RedoOperationIsSource
Used in SideBySide editor to determine which control to use
Declaration
bool RedoOperationIsSource { get; }
Property Value
Type | Description |
---|---|
bool |
RedoOperationName
The name of the next operation that can be re-done, null
if none, or an
empty string if the operation has not been named.
Declaration
string RedoOperationName { get; }
Property Value
Type | Description |
---|---|
string |
RedoOperationNames
A list of all operations that can be re-done.
Declaration
string[] RedoOperationNames { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
The number of strings returned always correspond to the number of available redo operations. Operations that are not named show up as null or an empty string in the list.
The next redo operation is first in the list.
This can be used to implement a visual list of redo operations. You can call RedoMultiple(long) to execute several redo operations in one go.
See Also
UndoOperationCount
The number of operations that can be un-done.
Declaration
long UndoOperationCount { get; }
Property Value
Type | Description |
---|---|
long |
UndoOperationIsSource
Used in SideBySide editor to determine which control to use
Declaration
bool UndoOperationIsSource { get; }
Property Value
Type | Description |
---|---|
bool |
UndoOperationName
The name of the next operation that can be un-done, null
if none, or an
empty string if the operation has not been named.
Declaration
string UndoOperationName { get; }
Property Value
Type | Description |
---|---|
string |
UndoOperationNames
A list of all operations that can be un-done.
Declaration
string[] UndoOperationNames { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
The number of strings returned always correspond to the number of available undo operations. Operations that are not named show up as null or an empty string in the list.
The next undo operation is first in the list.
This can be used to implement a visual list of undo operations. You can call UndoMultiple(long) to execute several undo operations in one go.
See Also
Methods
AbortCompositeOperation(string)
Flags the composite operation for aborting. This call should match a preceding call to BeginCompositeOperation(string). Once all currently nested composite operations have been ended the entire composite command will be rolled back and removed from the undo buffer. The associated message will be passed to the AfterEditOperationAborted event, and may be shown to the user to indicate why the operation was not allowed.
Declaration
void AbortCompositeOperation(string message)
Parameters
Type | Name | Description |
---|---|---|
string | message | A message explaining to the user why the operation was not permitted. If an operation is already flagged for aborting you can get the current message from the AbortMessage property. |
Remarks
You may want to check the IsAbortingCompositeOperation property before calling this method, in order to determine if the operation is already being aborted (in which case you should not abort it again, as that may overwrite the original message to the user with something that may not be the root cause of the problem).
The original call to BeginCompositeOperation(string) should always be matched with either a call to EndCompositeOperation() or a call to AbortCompositeOperation(string), never both.
After calling this method you may also want to throw an exception, to properly abort other related processing.
AddCommand(IUndoCommand)
Adds the command to the undo buffer.
Declaration
void AddCommand(IUndoCommand command)
Parameters
Type | Name | Description |
---|---|---|
IUndoCommand | command | The command to add to the buffer. |
BeginCommonCompositeOperation(string)
Creates a composite command in the undo buffer, wrapping all commands in both the source and target into one command common to both controls. This should only be used for operations where the document structure for both source and target may change without controls getting to know about it (e.g. when splitting and merging segments).
Declaration
void BeginCommonCompositeOperation(string operationName)
Parameters
Type | Name | Description |
---|---|---|
string | operationName | User-friendly name of the operation or |
Remarks
Each call to BeginCommonCompositeOperation(string) should have a corresponding call to EndCommonCompositeOperation() to mark the end of the operation.
BeginCompositeOperation(string)
Initiates a composite operation that should be treated as one unit during Undo and Redo.
Declaration
void BeginCompositeOperation(string operationName)
Parameters
Type | Name | Description |
---|---|---|
string | operationName | User friendly name of the operation, or |
Remarks
Each call to BeginCompositeOperation(string) should have a corresponding call to EndCompositeOperation() (or AbortCompositeOperation(string)) to mark the end of the composite operation.
For nested composite operations only the "outermost" operation (i.e. the one that was initiated first) will be effectively used and named (since all parts of it should be treated as one unit, whether those parts are themselves composite operations or not).
BeginCompositeOperationExtendingLastOperation(string)
Begin a composite operation extending the last edit operation in the history. The last operation executed will be removed from the history and added to this composite operation.
Declaration
void BeginCompositeOperationExtendingLastOperation(string commandName)
Parameters
Type | Name | Description |
---|---|---|
string | commandName | User friendly name of the operation, or |
Remarks
This is used, for example, to merge a segment status change with the content change operation that triggered it.
EndCommonCompositeOperation()
Closes a composite command in the undo buffer that was started with BeginCommonCompositeOperation(string). This should only be used for operations where the document structure for both source and target may change without controls getting to know about it (e.g. when splitting and merging segments).
Declaration
void EndCommonCompositeOperation()
EndCompositeOperation()
Marks the successful end of a composite operation that was initiated with BeginCompositeOperation(string).
Declaration
void EndCompositeOperation()
Flush()
Remove all operations from the buffer.
Declaration
void Flush()
Remarks
This operation cannot be undone :-)
RedoMultiple(long)
Execute multiple redo operations in one go.
Declaration
void RedoMultiple(long count)
Parameters
Type | Name | Description |
---|---|---|
long | count | The number of operations to redo. This must be a number between 0 and the value of RedoOperationCount. |
Remarks
If a control is available it is preferable to execute undo and redo operations through the control instead, as that will move the selection in the control to the correct location too.
UndoMultiple(long)
Execute multiple undo operations in one go.
Declaration
void UndoMultiple(long count)
Parameters
Type | Name | Description |
---|---|---|
long | count | The number of operations to undo. This must be a number between 0 and the value of UndoOperationCount. |
Remarks
If a control is available it is preferable to execute undo and redo operations through the control instead, as that will move the selection in the control to the correct location too.
Events
ContentChanged
Raised when content of the Undo buffer changes in any way.
Declaration
event EventHandler<UndoBufferContentChangedEventArgs> ContentChanged
Event Type
Type | Description |
---|---|
EventHandlerUndoBufferContentChangedEventArgs |