private void RedoLast() { if (redoStack.Count > 0) { CommandItem ci = redoStack.Peek(); if (!ci.TheRelayCommand.CanExecute(ci.Parm)) { while (!ci.TheRelayCommand.CanExecute(ci.Parm) && redoStack.Count > 0) { ci = redoStack.Pop(); } } else if (redoStack.Count > 0) { ci = redoStack.Pop(); } ci.TheRelayCommand.Execute(ci.Parm); } }
private void UndoAll() { CommandItem li = undoStack.Peek(); while (undoStack.Count > 1) { if (li.TheRelayCommand.CanUnExecute(li.Parm)) { UndoLast(); } else { li = undoStack.Pop(); busTubStack.Push(li); // Debugger.Break(); } if (undoStack.Count > 1) { li = undoStack.Peek(); } } }
private void UndoLast() { if (undoStack.Count > 0) { //If the next command is new Game Execute And Return CommandItem li = undoStack.Peek(); if (li.TheRelayCommand.DisplayText == "NewGameCommand") { li.TheRelayCommand.Execute(li.Parm); return; } //Some Commands are no longer available for Undo Put them in the BusTub while (!li.TheRelayCommand.CanUnExecute(li.Parm) && undoStack.Count > 0) { if (li.TheRelayCommand.DisplayText != "NewGameCommand") { li = undoStack.Pop(); busTubStack.Push(li); } li = undoStack.Peek(); } //Now the next Command is either NewGameCommand or available for re-execution if (undoStack.Count > 0) { li = undoStack.Peek(); if (li.TheRelayCommand.DisplayText != "NewGameCommand") { li = undoStack.Pop(); redoStack.Push(li); li.TheRelayCommand.UnExecute(li.Parm); } else { li.TheRelayCommand.Execute(li.Parm); } } } }
private void RaiseNewCommandItemEvent(object o, CommandItem li) { OnNewCommandItemEvent(li); }
private void RaiseRefreshStacksEvent(RelayCommand relayCommand, CommandItem li) { OnRefreshStacksEvent(li); }