Example #1
0
        /// <summary>
        ///     Adds an operation to <see cref="RedoList"/> but without performing it.
        /// </summary>
        public virtual void AddOperation(IReversibleOperation operation)
        {
            Assert.ValidateReference(operation);

            RedoList.Clear();
            UndoList.Insert(0, operation);
            LastOperation = null;
        }
Example #2
0
        /// <summary>
        ///     Adds an operation to <see cref="RedoList"/> and performs it.
        /// </summary>
        public virtual void AddAndExecuteOperation(IReversibleOperation operation)
        {
            Assert.ValidateReference(operation);

            RedoList.Clear();
            UndoList.Insert(0, operation);

            operation.Redo();
            LastOperation = operation;
        }
Example #3
0
        /// <summary>
        /// Adds an operation to <see cref="RedoList"/> but without performing it.
        /// </summary>
        /// <param name="operation">The operation to add.</param>
        public virtual void AddOperation(IReversibleOperation operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            RedoList.Clear();
            UndoList.Insert(0, operation);
            LastOperation = IdentityOperation.Default;
        }
Example #4
0
        /// <summary>
        /// Adds an operation to <see cref="RedoList"/> and performs it.
        /// </summary>
        /// <param name="operation">The operation to add and execute.</param>
        public virtual void AddAndExecuteOperation(IReversibleOperation operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            RedoList.Clear();
            UndoList.Insert(0, operation);

            operation.Redo();
            LastOperation = operation;
        }
Example #5
0
        /// <summary>
        /// Performs an <see cref="T:Action" /> and adds it to the undo list if the <see cref="T:Action" /> can be undone.
        /// </summary>
        /// <param name="action">
        /// The <see cref="T:Action" />.
        /// </param>
        public bool Do(ICommand action)
        {
            if (action == null)
            {
                return(false);
            }
            bool flag = true;

            try
            {
                action.Execute(Context);
            }
            catch
            {
                flag = false;
            }
            if (Context is Excel excel)
            {
                excel.ResumeInvalidate();
            }
            if (AllowUndo)
            {
                IUndo undo = action as IUndo;
                if (!flag || (undo == null))
                {
                    return(flag);
                }
                if ((MaxLength > 0) && (UndoList.Count >= MaxLength))
                {
                    ShrinkUndoList((UndoList.Count - MaxLength) + 1);
                }
                UndoList.Push(action);
                RedoList.Clear();
                RaiseChanged(UndoRedoOperation.Do, action.ToString());
            }
            return(flag);
        }
Example #6
0
 /// <summary>
 /// Adds a property from the view to the undo list
 /// </summary>
 /// <param name="entityHashCode">Hash code of the property instance</param>
 /// <param name="propertyName">Name of the property</param>
 /// <param name="oldValue">Old value of the property</param>
 /// <param name="newValue">New value of the property</param>
 /// <param name="actionId">Undo/Redo action id</param>
 /// <param name="messageType">Action to take when undoing/redoing</param>
 public void AddUndo(TEntity changedEntity, string propertyName, object oldValue, object newValue, EntityMessageType messageType)
 {
     UndoList.Add(new UndoRedoEntityInfo <TEntity>(changedEntity, propertyName, oldValue, newValue, ActionId, messageType));
     RedoList.Clear();
 }
Example #7
0
 public void Clear()
 {
     UndoList.Clear();
     RedoList.Clear();
 }
Example #8
0
 /// <summary>
 /// Refreshes the redo list with new entries
 /// </summary>
 /// <param name="redoList"></param>
 private void UpdateRedoList(List <UndoRedoEntityInfo <TEntity> > redoList)
 {
     RedoList.Clear();
     RedoList.AddRange(redoList);
 }
Example #9
0
 /// <summary>
 /// Returns the manager to a state with no operation that can be performed or reversed.
 /// </summary>
 public virtual void Reset()
 {
     UndoList.Clear();
     RedoList.Clear();
     LastOperation = IdentityOperation.Default;
 }
Example #10
0
 /// <summary>
 ///     Returns the manager to a state with no operation that can be performed or reversed.
 /// </summary>
 public virtual void Reset()
 {
     UndoList.Clear();
     RedoList.Clear();
     LastOperation = null;
 }
 public void ResetUndo()
 {
     UndoList.Clear();
     RedoList.Clear();
 }