示例#1
0
 /// <summary>
 /// Executes command, pushes it into the undo stack
 /// and clears the redo stack
 /// </summary>
 public void Execute(ICommand command)
 {
     command.Execute();
     UndoStack.Push(command);
     RedoStack.Clear();
     if (UndoStack.Count == 1)
     {
         CanUndoChanged?.Invoke(true, null);
     }
     CanRedoChanged?.Invoke(false, null);
 }
示例#2
0
        /// <summary>
        /// Redoes command
        /// </summary>
        public void Redo()
        {
            if (!CanRedo)
            {
                return;
            }
            var command = RedoStack.Pop();

            command.Execute();
            UndoStack.Push(command);
            if (!CanRedo)
            {
                CanRedoChanged?.Invoke(false, null);
            }
            if (UndoStack.Count == 1)
            {
                CanUndoChanged?.Invoke(true, null);
            }
        }
示例#3
0
 private void RedoStack_HasItemsChanged(object sender, EventArgs e)
 {
     CanRedoChanged?.Invoke(this, new EventArgs());
 }
示例#4
0
 /// <summary>
 /// 触发可撤销/重做状态变更事件;
 /// </summary>
 protected void RaiseCanUndoRedoChanged()
 {
     CanRedoChanged?.Invoke(this, new CanRedoChangedEventArgs(CanRedo));
     CanUndoChanged?.Invoke(this, new CanUndoChangedEventArgs(CanUndo));
 }
示例#5
0
 private void UndoService_CanRedoChanged(object sender, EventArgs e)
 {
     CanRedoChanged?.Invoke(this, e);
 }
示例#6
0
 private void RaiseCanRedo()
 => CanRedoChanged?.Invoke(this, EventArgs.Empty);
示例#7
0
 private void UndoRedoHandler_CanRedoChanged(object sender, EventArgs e)
 {
     CanRedoChanged?.Invoke(null, EventArgs.Empty);
 }