Пример #1
0
        /// <summary>
        /// 重做
        /// 并指定是否引发OnRedo事件
        /// </summary>
        /// <param name="redoEvent"></param>
        public void Redo(bool redoEvent)
        {
            this.Working = true;

            SEUndoUnitAbstract unit = null;

            Debug.Assert(_redoStack.Count > 0, "_redoStack.Count <= 0");

            if (_redoStack.Count > 0)
            {
                try
                {
                    unit = _redoStack.Pop();
                    unit.Redo();
                    _undoStack.Push(unit);

                    Debug.WriteLine("Redo:" + unit.ToString());

                    //触发重做后的事件
                    if (redoEvent && this.OnRedo != null)
                    {
                        OnRedo(unit);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Assert(false, ex.Message);
                }
            }

            this.Working = false;
        }
Пример #2
0
        private SEUndoUnitAbstract RedoUnit()
        {
            if (_redoStack.Count == 0)
            {
                return(null);
            }
            SEUndoUnitAbstract unit = _redoStack.Pop();

            unit.Redo();
            _undoStack.Push(unit);
            Debug.WriteLine("Redo:" + unit.ToString());
            return(unit);
        }
Пример #3
0
        /// <summary>
        /// 多步重做,并指定是否在每一步Redo中引发事件
        /// </summary>
        /// <param name="step"></param>
        /// <param name="redoEvent"></param>
        public void Redo(int step, bool redoEvent)
        {
            this.Working = true;

            if (step < 1)
            {
                return;
            }

            Dictionary <SEUndoUnitAbstract, Action <SEUndoUnitAbstract, SEUndoEngine.Type> > _actions
                = new Dictionary <SEUndoUnitAbstract, Action <SEUndoUnitAbstract, Type> >();

            for (int i = 0; i < step; i++)
            {
                Debug.Assert(_redoStack.Count > 0, "_redoStack.Count <= 0");

                SEUndoUnitAbstract unit = null;

                if (_redoStack.Count > 0)
                {
                    try
                    {
                        unit = _redoStack.Pop();
                        if (unit.MergeAction && unit.Action != null)
                        {
                            if ((from c in _actions where c.Key.GetType().Equals(unit.GetType()) select c).Count() == 0)
                            {
                                _actions.Add(unit, unit.Action);
                            }

                            unit.Redo(false);
                        }
                        else
                        {
                            unit.Redo(true);
                        }
                        _undoStack.Push(unit);

                        Debug.WriteLine("Redo:" + unit.ToString());

                        //触发重做后的事件
                        if (this.OnRedo != null && redoEvent)
                        {
                            OnRedo(unit);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Assert(false, ex.Message);
                    }
                }
            }

            foreach (KeyValuePair <SEUndoUnitAbstract, Action <SEUndoUnitAbstract, SEUndoEngine.Type> > pair in _actions)
            {
                pair.Value(pair.Key, SEUndoEngine.Type.Redo);
            }

            if (OnStepRedo != null)
            {
                OnStepRedo(step);
            }

            this.Working = false;
        }