コード例 #1
0
        /// <summary>
        /// Performs an undo action.
        /// </summary>
        /// <returns>
        /// Returns true if the undo action succeeds; otherwise, returns false.
        /// </returns>
        public bool Undo()
        {
            bool flag = true;

            if (AllowUndo && CanUndo)
            {
                IUndo undo = UndoList.Peek() as IUndo;
                try
                {
                    if ((undo != null) && undo.CanUndo)
                    {
                        flag = undo.Undo(Context);
                    }
                }
                catch
                {
                    flag = false;
                }
                if (Context is Excel excel)
                {
                    excel.ResumeInvalidate();
                }
                if (flag)
                {
                    RedoList.Push(UndoList.Pop());
                    RaiseChanged(UndoRedoOperation.Undo, undo.ToString());
                }
            }
            return(flag);
        }
コード例 #2
0
        public bool Undo()
        {
            if (UndoSize == 0)
            {
                return(false);
            }
            var action = UndoList.Pop();

            action.PerformRevertAction();
            RedoList.Push(action);
            return(true);
        }
コード例 #3
0
 public void Undo()
 {
     if (CanUndo == false)
     {
         return;
     }
     RedoList.Push(_value);
     _value = UndoList.Pop();
     OnPropertyChanged("Value");
     OnPropertyChanged("CanUndo");
     OnPropertyChanged("CanRedo");
 }