/// <summary> /// Redo the last undone entity change /// </summary> /// <remarks> /// Unlike the undo operation, we don't need to copy the undo list out /// because we want the item we're redoing being added back to the redo /// list. /// </remarks> public void Redo() { _IsInUndoRedoOperation = true; if (RedoList.Count > 0) { // Extract the item from the redo list. int redoActionId = RedoList.Last().ActionId; UndoRedoEntityInfo <TEntity> item; for (int i = RedoList.Count - 1; i >= 0; i--) { item = RedoList.Last(); if (item.ActionId == redoActionId) { // Now, remove it from the list. RedoList.RemoveAt(RedoList.Count - 1); // Here we need to copy the redo list out because // we will clear the list when the Add is called and // the Redo is cleared there. List <UndoRedoEntityInfo <TEntity> > redoList = RedoList.ToList(); //Redo actionId should be the same as undo action id SetActionId(item.ActionId); // Redo the last operation. FuncRedo(item); // Add the last redo item into undo list AddUndo(item.ChangedEntity, item.PropertyName, item.OldValue, item.NewValue, item.MessageType); // Now reset the redo list. UpdateRedoList(redoList); } } } _IsInUndoRedoOperation = false; }
/// <summary> /// Removes the first operation in <see cref="RedoList"/>, perform it again and adds it to <see cref="UndoList"/>. /// </summary> public virtual void Redo() { Debug.Assert(RedoList.Count > 0); IReversibleOperation Operation = RedoList[0]; RedoList.RemoveAt(0); UndoList.Insert(0, Operation); Operation.Redo(); LastOperation = Operation; }