示例#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;
        }
示例#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;
        }
示例#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;
        }
示例#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;
        }
示例#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);
        }
示例#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();
 }
示例#7
0
 public void Clear()
 {
     UndoList.Clear();
     RedoList.Clear();
 }
示例#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);
 }
示例#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;
 }
示例#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();
 }