public void PerformCommand(IUndoCommand command) { if (performingCommandSequence) { commandSequence.PerformCommand(command); } else { try { command.Perform(); index++; commands.Insert(index, command); if (index < capacity && commands.Count > index + 1) { commands.RemoveRange(index + 1, commands.Count - (index + 1)); } if (commands.Count > capacity) { commands.RemoveRange(0, commands.Count - capacity); } CommandPerformed?.Invoke(this, new EventArgs()); } catch (Exception ex) { HandleError(command, ex); } } }
public void BeginCommandSequence(string description) { performingCommandSequence = true; commandSequence = new UndoSequence(description, errorSink); commandSequence.CommandPerformed += (sender, e) => CommandPerformed?.Invoke(this, e); }
public void PerformCommand() { if (!Enabled || Text.Length == 0) { return; } CommandPerformed?.Invoke(Text); Clear(); }
public void Redo() { if (index + 1 == commands.Count) { return; } IUndoCommand command = commands.ElementAt(index + 1); try { command.Perform(); index++; CommandPerformed?.Invoke(this, new EventArgs()); } catch (Exception ex) { HandleError(command, ex); } }
public void Undo() { if (index < 0) { return; } IUndoCommand command = commands.ElementAt(index); try { command.Rollback(); index--; CommandPerformed?.Invoke(this, new EventArgs()); } catch (Exception ex) { HandleError(command, ex); } }
public void Do(CommandBase com) { MyGame.DebugAlert(DebugMode.Commands, "Doing " + com.ToString(MyGame)); if (!(com is CommandGroup)) { UndoStack.Push(com); } com.Do(MyGame); if (!SuspendViewUpdates) { com.UpdateViews(MyGame); } if (triggerOnCommandTypes.Contains(com.GetType()) && !IsLoading) { MyGame.MyTriggerHandler.GatherTriggers(com); } CommandPerformed?.Invoke(com); }
internal void NotifyCommandPerformed(CommandReply repl) { CommandPerformed?.Invoke(this, repl); m_wasPerformed = true; }