private UndoCommand SpreadSheetUndo() { ICommandInterface command = this.undoStack.Pop(); UndoCommand newCommand = command as UndoCommand; while (newCommand.Content == null) { command = this.undoStack.Pop(); newCommand = command as UndoCommand; } if (newCommand.CommandType == CommandType.Text) { ICommandInterface newRedoCommand = new RedoCommand(newCommand.CommandType, newCommand.Cell, newCommand.Cell.Text); this.redoStack.Push(newRedoCommand); } else if (newCommand.CommandType == CommandType.Color) { ICommandInterface newRedoCommand = new RedoCommand(newCommand.CommandType, newCommand.Cell, newCommand.Cell.Color.ToString()); this.redoStack.Push(newRedoCommand); } command.Action(); return(newCommand); }
/// <summary> /// Spreadsheet undo execute. /// </summary> public void SpreadSheetUndo() { ICommandInterface command = this.undoStack.Pop(); UndoCommand newCommand = command as UndoCommand; if (newCommand.CommandType == CommandType.Text) { ICommandInterface newRedoCommand = new RedoCommand(newCommand.CommandType, newCommand.Cell, newCommand.Cell.Text); this.redoStack.Push(newRedoCommand); } else if (newCommand.CommandType == CommandType.Color) { ICommandInterface newRedoCommand = new RedoCommand(newCommand.CommandType, newCommand.Cell, newCommand.Cell.Color.ToString()); this.redoStack.Push(newRedoCommand); } command.Action(); }
private RedoCommand SpreadSheetRedo() { ICommandInterface command = this.redoStack.Pop(); RedoCommand newCommand = command as RedoCommand; if (newCommand.CommandType == CommandType.Text) { ICommandInterface newUndoCommand = new UndoCommand(newCommand.CommandType, newCommand.Cell, newCommand.Cell.Text); this.UndoStack.Push(newUndoCommand); } else if (newCommand.CommandType == CommandType.Color) { ICommandInterface newUndoCommand = new UndoCommand(newCommand.CommandType, newCommand.Cell, newCommand.Cell.Color.ToString()); this.undoStack.Push(newUndoCommand); } command.Action(); return(newCommand); }