Ejemplo n.º 1
0
        public static void Redo()
        {
            UndoRedoAction action = NextAction;

            if (action == null)
            {
                return;
            }
            actionIndex++;
            action.Do();
            OnStackChanged();
        }
Ejemplo n.º 2
0
        private static void AppendAction(UndoRedoAction action, bool performAction)
        {
            if (action.IsVoid)
            {
                return;
            }
            if (macroBeginCount > 0)
            {
                UndoRedoAction prev = macroList.Count > 0 ? macroList[macroList.Count - 1] : null;
                if (prev != null && prev.CanAppend(action))
                {
                    prev.Append(action, performAction);
                }
                else
                {
                    macroList.Add(action);
                    if (performAction)
                    {
                        action.Do();
                    }
                }
            }
            else
            {
                if (Sandbox.IsActive)
                {
                    if (performAction)
                    {
                        action.Do();
                    }
                    return;
                }

                bool hadNext = false;
                if (actionStack.Count - actionIndex - 1 > 0)
                {
                    actionStack.RemoveRange(actionIndex + 1, actionStack.Count - actionIndex - 1);
                    hadNext = true;
                }

                UndoRedoAction prev = PrevAction;
                if (!lastActionFinished && !hadNext && prev != null && prev.CanAppend(action))
                {
                    prev.Append(action, performAction);
                }
                else
                {
                    lastActionFinished = false;
                    actionStack.Add(action);
                    actionIndex++;
                    if (performAction)
                    {
                        action.Do();
                    }
                }

                if (actionStack.Count > maxActions)
                {
                    actionIndex -= actionStack.Count - maxActions;
                    actionStack.RemoveRange(0, actionStack.Count - maxActions);
                }

                OnStackChanged();
            }
        }
		private static void AppendAction(UndoRedoAction action, bool performAction)
		{
			if (action.IsVoid) return;
			if (macroBeginCount > 0)
			{
				UndoRedoAction prev = macroList.Count > 0 ? macroList[macroList.Count - 1] : null;
				if (prev != null && prev.CanAppend(action))
				{
					prev.Append(action, performAction);
				}
				else
				{
					macroList.Add(action);
					if (performAction) action.Do();
				}
			}
			else
			{
				if (Sandbox.IsActive)
				{
					if (performAction) action.Do();
					return;
				}

				bool hadNext = false;
				if (actionStack.Count - actionIndex - 1 > 0)
				{
					actionStack.RemoveRange(actionIndex + 1, actionStack.Count - actionIndex - 1);
					hadNext = true;
				}

				UndoRedoAction prev = PrevAction;
				if (!lastActionFinished && !hadNext && prev != null && prev.CanAppend(action))
				{
					prev.Append(action, performAction);
				}
				else
				{
					lastActionFinished = false;
					actionStack.Add(action);
					actionIndex++;
					if (performAction) action.Do();
				}

				if (actionStack.Count > maxActions)
				{
					actionIndex -= actionStack.Count - maxActions;
					actionStack.RemoveRange(0, actionStack.Count - maxActions);
				}

				OnStackChanged();
			}
		}