| 0: | // UndoQueue.cs | |
| 1: | // Copyright (c) 2000 Mike Krueger | |
| 2: | // | |
| 3: | // This program is free software; you can redistribute it and/or modify | |
| 4: | // it under the terms of the GNU General Public License as published by | |
| 5: | // the Free Software Foundation; either version 2 of the License, or | |
| 6: | // (at your option) any later version. | |
| 7: | // | |
| 8: | // This program is distributed in the hope that it will be useful, | |
| 9: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 11: | // GNU General Public License for more details. | |
| 12: | // | |
| 13: | // You should have received a copy of the GNU General Public License | |
| 14: | // along with this program; if not, write to the Free Software | |
| 15: | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 16: | ||
| 17: | using System; | |
| 18: | using System.Diagnostics; | |
| 19: | using System.Collections; | |
| 20: | using SharpDevelop.Internal.Text; | |
| 21: | ||
| 22: | namespace SharpDevelop.Internal.Undo { | |
| 23: | ||
| 24: | /// <summary> | |
| 25: | /// This class stacks the last x operations from the undostack and makes | |
| 26: | /// one undo/redo operation from it. | |
| 27: | /// </summary> | |
| 28: | public class UndoQueue : IUndoableOperation | |
| 29: | { | |
| 30: | ArrayList undolist = new ArrayList(); | |
| 31: | ||
| 32: | public UndoQueue(UndoStack stack, int numops) | |
| 33: | { | |
| 34: | if (stack == null) | |
| 35: | throw new ArgumentNullException("UndoQueue(UndoStack stack, int numops) : buffer can't be null"); | |
| 36: | ||
| 37: | Debug.Assert(numops > 0 , "SharpDevelop.Internal.Undo.UndoQueue : numops should be > 0"); | |
| 38: | ||
| 39: | for (int i = 0; i < numops; ++i) { | |
| 40: | if (stack._UndoStack.Count > 0) { | |
| 41: | undolist.Add(stack._UndoStack.Pop()); | |
| 42: | } | |
| 43: | } | |
| 44: | } | |
| 45: | ||
| 46: | public void Undo() | |
| 47: | { | |
| 48: | for (int i = 0; i < undolist.Count; ++i) | |
| 49: | ((IUndoableOperation)undolist[i]).Undo(); | |
| 50: | } | |
| 51: | ||
| 52: | public void Redo() | |
| 53: | { | |
| 54: | for (int i = 0; i < undolist.Count; ++i) | |
| 55: | ((IUndoableOperation)undolist[i]).Redo(); | |
| 56: | } | |
| 57: | } | |
| 58: | } | |
| 59: |
This page was automatically generated by SharpDevelop.