/// <summary> /// Constructor. /// </summary> /// <param name="referenceImage">The 'current' (or reference) <see cref="IPresentationImage"/>.</param> /// <param name="operation">The operation to be performed on the current <see cref="IPresentationImage"/> and/or its linked images.</param> public ImageOperationApplicator(IPresentationImage referenceImage, IUndoableOperation<IPresentationImage> operation) { Platform.CheckForNullReference(referenceImage, "referenceImage"); Platform.CheckForNullReference(operation, "operation"); _imageEnumerator = new LinkedImageEnumerator(referenceImage); _operation = operation; }
/// <summary> /// Call this method to push an UndoableOperation on the undostack, the redostack /// will be cleared, if you use this method. /// </summary> public void Push(IUndoableOperation operation) { if (operation == null) { throw new ArgumentNullException("UndoStack.Push(UndoableOperation operation) : operation can't be null"); } if (AcceptChanges) { undostack.Push(operation); ClearRedoStack(); } }
/// <summary> /// Call this method to push an UndoableOperation on the undostack, the redostack /// will be cleared, if you use this method. /// </summary> public void Push(IUndoableOperation operation) { if (operation == null) { throw new ArgumentNullException("操作不能为空."); } if (AcceptChanges) { undostack.Push(operation); if (TextEditorControl != null) { undostack.Push(new UndoableSetCaretPosition(this, TextEditorControl.ActiveTextAreaControl.Caret.Position)); UndoLast(2); } ClearRedoStack(); } }
/// <summary> /// Call this method to push an UndoableOperation on the undostack, the redostack /// will be cleared, if you use this method. /// </summary> public void Push(IUndoableOperation operation) { if (operation == null) { throw new ArgumentNullException("UndoStack.Push(UndoableOperation operation) : operation can't be null"); } if (AcceptChanges) { StartUndoGroup(); undostack.Push(operation); actionCountInUndoGroup++; if (TextEditorControl != null) { undostack.Push(new UndoableSetCaretPosition(this, TextEditorControl.ActiveTextAreaControl.Caret.Position)); actionCountInUndoGroup++; } EndUndoGroup(); ClearRedoStack(); } }
/// <summary> /// Redoes the last undone operation. /// </summary> public void Redo() { AssertNoUndoGroupOpen(); if (InternalRedoStack.Count > 0) { IUndoableOperation operation = InternalRedoStack.DequeueHead(); InternalUndoStack.EnqueueHead(operation); operation.Do(); OnOperationRedone(); if (InternalRedoStack.Count == 0) { OnPropertyChanged(new PropertyChangedEventArgs("CanRedo")); } if (InternalUndoStack.Count == 1) { OnPropertyChanged(new PropertyChangedEventArgs("CanUndo")); } EnforceSizeLimit(); } }
private void Push(IUndoableOperation operation, bool isOptional) { if (operation == null) { throw new ArgumentNullException("operation"); } if (state == StateListen && sizeLimit > 0) { bool wasEmpty = undostack.Count == 0; bool needsUndoGroup = undoGroupDepth == 0; if (needsUndoGroup) { StartUndoGroup(); } undostack.PushBack(operation); actionCountInUndoGroup++; if (isOptional) { optionalActionCount++; } else { FileModified(1); } if (needsUndoGroup) { EndUndoGroup(); } if (wasEmpty) { NotifyPropertyChanged("CanUndo"); } ClearRedoStack(); } }
/// <summary> /// Call this method to redo the last undone operation /// </summary> public void Redo() { ThrowIfUndoGroupOpen(); if (redostack.Count > 0) { lastGroupDescriptor = null; allowContinue = false; IUndoableOperation uedit = redostack.PopBack(); undostack.PushBack(uedit); state = StatePlayback; try { RunRedo(uedit); } finally { state = StateListen; } if (redostack.Count == 0) { NotifyPropertyChanged("CanRedo"); } if (undostack.Count == 1) { NotifyPropertyChanged("CanUndo"); } } }
/// <summary> /// Constructor. /// </summary> /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="item"/>.</param> /// <param name="item">The item to which the <paramref name="operation"/> should be applied.</param> public DrawableUndoableOperationCommand(IUndoableOperation <T> operation, T item) : base(operation, item) { }
public OperationEventArgs(IUndoableOperation op) { this.op = op; }
/// <summary> /// Call this method to push an UndoableOperation on the undostack. /// The redostack will be cleared if you use this method. /// </summary> public void Push(IUndoableOperation operation) { Push(operation, false); }
/// <summary> /// Call this method to push an UndoableOperation on the undostack, the redostack /// will be cleared, if you use this method. /// </summary> public void Push(IUndoableOperation operation) { if (operation == null) { throw new ArgumentNullException("operation"); } if (AcceptChanges) { StartUndoGroup(); undostack.Push(operation); actionCountInUndoGroup++; if (TextEditorControl != null) { undostack.Push(new UndoableSetCaretPosition(this, TextEditorControl.ActiveTextAreaControl.Caret.Position)); actionCountInUndoGroup++; } EndUndoGroup(); ClearRedoStack(); } }
void Push(IUndoableOperation operation, bool isOptional) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } if (state == StateListen && sizeLimit > 0) { bool wasEmpty = undostack.Count == 0; bool needsUndoGroup = undoGroupDepth == 0; if (needsUndoGroup) StartUndoGroup(); undostack.PushBack(operation); actionCountInUndoGroup++; if (isOptional) optionalActionCount++; else FileModified(1); if (needsUndoGroup) EndUndoGroup(); if (wasEmpty) NotifyPropertyChanged("CanUndo"); ClearRedoStack(); } }
public OperationEventArgs(IUndoableOperation op) { Operation = op; }
/// <summary> /// Call this method to push an UndoableOperation on the undostack. /// However, the operation will be only stored if the undo group contains a /// non-optional operation. /// Use this method to store the caret position/selection on the undo stack to /// prevent having only actions that affect only the caret and not the document. /// </summary> public void PushOptional(IUndoableOperation operation) { if (undoGroupDepth == 0) throw new InvalidOperationException("Cannot use PushOptional outside of undo group"); Push(operation, true); }
/// <summary> /// Constructor. /// </summary> /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="items"/>.</param> /// <param name="items">The items to which the <paramref name="operation"/> should be applied.</param> public DrawableUndoableOperationCommand(IUndoableOperation <T> operation, IEnumerable <T> items) : base(operation, items) { }
internal void RunRedo(IUndoableOperation op) { IUndoableOperationWithContext opWithCtx = op as IUndoableOperationWithContext; if (opWithCtx != null) opWithCtx.Redo(this); else op.Redo(); }
/// <summary> /// Adds an operation to the undo buffer. /// </summary> /// <param name="operation">The operation.</param> /// <remarks> /// <para> /// This methods needs to be called for every <see cref="IUndoableOperation"/> before or after /// it is executed by calling its <see cref="IUndoableOperation.Do"/> method. Note: /// <see cref="Add"/> does not execute the <see cref="IUndoableOperation"/> it will only record /// the operation. /// </para> /// <para> /// After the operation is recorded in the undo buffer it can be undone and redone by calling /// <see cref="Undo"/> and <see cref="Redo"/>. /// </para> /// <para> /// The recording of operations in the undo buffer can be temporarily disabled by setting /// <see cref="AcceptChanges"/> to <see langword="false"/>. /// </para> /// </remarks> /// <exception cref="ArgumentNullException"> /// <paramref name="operation"/> is <see langword="null"/>. /// </exception> /// <seealso cref="AcceptChanges"/> public void Add(IUndoableOperation operation) { if (operation == null) throw new ArgumentNullException("operation"); if (AcceptChanges) { InternalUndoStack.EnqueueHead(operation); if (IsUndoGroupOpen) _numberOfOperationsInGroup++; if (InternalUndoStack.Count == 1) OnPropertyChanged(new PropertyChangedEventArgs("CanUndo")); ClearRedoStack(); if (!IsUndoGroupOpen) EnforceSizeLimit(); } }
void Push(IUndoableOperation operation, bool isOptional) { if (operation == null) { throw new ArgumentNullException("operation"); } if (acceptChanges) { bool wasEmpty = undostack.Count == 0; StartUndoGroup(); undostack.Push(operation); actionCountInUndoGroup++; if (isOptional) optionalActionCount++; EndUndoGroup(); if (wasEmpty) NotifyPropertyChanged("CanUndo"); ClearRedoStack(); } }
/// <summary> /// Constructor. /// </summary> /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="item"/>.</param> /// <param name="item">The item to which the <paramref name="operation"/> should be applied.</param> public UndoableOperationCommand(IUndoableOperation <T> operation, T item) : this(operation, ToEnumerable(item)) { }
public void PushOptional(IUndoableOperation operation) { //TODO: UndoStack.PushOptional() throw new NotImplementedException(); }
/// <summary> /// Constructor. /// </summary> /// <param name="operation">The <see cref="IUndoableOperation{T}"/> that is to be applied to <paramref name="items"/>.</param> /// <param name="items">The items to which the <paramref name="operation"/> should be applied.</param> public UndoableOperationCommand(IUndoableOperation <T> operation, IEnumerable <T> items) { _operation = operation; _items = items; }