/// <inheritdoc/>
        public void Transact(IReversableCommand command, object parameter)
        {
            RedoStack.Clear();
            Action undo = command.Execute(parameter);

            Action redo() => command.Execute(parameter);

            UndoStack.Push(new UndoRedo(undo, redo));
            Transacted?.Invoke();
        }
 private void InitCommands()
 {
     OpenCommand = new OpenCommand(this);
     ApplyCommand = new ApplyCommand(this);
     FlipCommand = new FlipCommand(this);
     HistogramEqualizeCommand = new HistogramEqualizeCommand(this);
     HistogramStretchCommand = new HistogramStretchCommand(this);
     CropCommand = new CropCommand(this);
     InpaintCommand = new InpaintCommand(this);
     ResizeCommand = new ResizeCommand(this);
     RotateCommand = new RotateCommand(this);
     SaveAsCommand = new SaveAsCommand(this);
     SaveCommand = new SaveCommand(this);
     ZoomCommand = new ZoomCommand(this);
     ResetCommand = new ResetCommand(this);
     CloseCommand = new CloseCommand(this);
     SelectToolCommand = new SelectToolCommand(this);
     UndoCommand = new UndoCommand(this);
     RedoCommand = new RedoCommand(this);
     DropboxCommand = new DropboxCommand(this);
     DownloadCommand = new DownloadCommand(this);
     UploadCommand = new UploadCommand(this);
     DCommand = new DCommand(this);
     ECommand = new ECommand(this);
     PrewittCommand = new PrewittCommand(this);
 }
 /// <summary>
 /// Adds a command to the list of commands that <see cref="Execute(ITransactor, object)"/> will execute.
 /// </summary>
 /// <param name="command">The command to add.</param>
 public void ComposeCommand(IReversableCommand command)
 {
     _composedCommands.Add(command);
 }
 /// <summary>
 /// Creates a new instance of <see cref="UnwireNodeCommand"/>.
 /// </summary>
 /// <param name="diagram">The diagram to unwire the node from.</param>
 public UnwireNodeCommand(Diagram diagram)
 {
     _diagram           = diagram;
     _removeWireCommand = new DeleteWireCommand(_diagram);
 }
 /// <summary>
 /// Creates a new instance of <see cref="CustomUndoCommand"/>.
 /// </summary>
 /// <param name="command">The command to execute during do.</param>
 /// <param name="undoCommand">The command to execute to undo the original <paramref name="command"/></param>
 public CustomUndoCommand(IReversableCommand command, IReversableCommand undoCommand)
 {
     _command     = command;
     _undoCommand = undoCommand;
 }
 // imageEditor context
 // command params
 public CommandContext(IReversableCommand command)
 {
     _command = command;
 }
Example #7
0
 /// <inheritdoc/>
 public void Transact(IReversableCommand command, object parameter)
 {
     command.Execute(parameter);
     Transacted?.Invoke();
 }
 /// <summary>
 /// Creates a new instance of <see cref="MapCommand"/>.
 /// </summary>
 /// <param name="commandToMap">The command to map a list parameter onto.</param>
 public MapCommand(IReversableCommand commandToMap)
 {
     _commandToMap = commandToMap;
 }
Example #9
0
 /// <summary>
 /// Executes a command without providing a parameter.
 /// </summary>
 /// <param name="transactor">The transactor to execute the command with.</param>
 /// <param name="command">The command to execute with a null parameter.</param>
 public static void Transact(this ITransactor transactor, IReversableCommand command)
 {
     transactor.Transact(command, parameter: null);
 }
Example #10
0
        /// <summary>
        /// Execute a command with a custom undo command. Useful for complex undo scenarios.
        /// </summary>
        /// <param name="transactor">The transactor to execute the command with.</param>
        /// <param name="command">The command to execute.</param>
        /// <param name="undoCommand">The command that will undo the <paramref name="command"/>.</param>
        /// <param name="parameter">The parameter to pass into the command.</param>
        public static void Transact(this ITransactor transactor, IReversableCommand command, IReversableCommand undoCommand, object parameter)
        {
            var commandWithCustomUndo = new CustomUndoCommand(command, undoCommand);

            transactor.Transact(commandWithCustomUndo, parameter);
        }
Example #11
0
 /// <summary>
 /// Creates a new instance of <see cref="UndoCommand"/>.
 /// </summary>
 /// <param name="command">The command to add to the undo stack.</param>
 public UndoCommand(IReversableCommand command)
 {
     _command = command;
 }