예제 #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 UndoStack_HasItemsChanged(object sender, EventArgs e)
 {
     CanUndoChanged?.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_CanUndoChanged(object sender, EventArgs e)
 {
     CanUndoChanged?.Invoke(this, e);
 }
예제 #6
0
        }         // proc Redo

        private void RaiseCanUndo()
        => CanUndoChanged?.Invoke(this, EventArgs.Empty);
예제 #7
0
 private void UndoRedoHandler_CanUndoChanged(object sender, EventArgs e)
 {
     CanUndoChanged?.Invoke(null, EventArgs.Empty);
 }