/// <summary> /// Creates a new command. As CommandManger (Context) the global GCommandManger Singleton is used. /// </summary> /// <param name="execute">The execution logic.</param> /// <param name="canExecute">The execution status logic.</param> public WrapperCommand(ICommandUndo command, ICommandManager context) { if (command == null) throw new ArgumentNullException("command"); if (context == null) throw new ArgumentNullException("context"); _context = context; _command = command; }
public CommandEventArgs(ICommandUndo command) { _command = command; }
/// <summary> /// Executes the given command <paramref name="cmd"/> and adds it to the executed commands for allowing undo/redo support. /// </summary> /// <param name="cmd"></param> /// <param name="commandArg"></param> public virtual void Execute(ICommandUndo cmd, object commandArg = null) { var undo = this.CanUndo; var redo = this.CanRedo; cmd.Execute(commandArg); if (CommandExecuted != null) { CommandExecuted(this, new CommandEventArgs(cmd)); } if (!cmd.IsTransparentCommand) { _commandsExecuted.Push(cmd.CloneCommand()); OnCommandsExecutedChanged(); } if (undo != this.CanUndo) OnCanUndoChanged(); if (redo != this.CanRedo) OnCanRedoChanged(); }