public void InsertMementoForUndoRedo(MemMemento memento) { if (memento != null) { UndoStack.Push(memento); RedoStack.Clear(); } }
public MemMemento CloneMemento(MemMemento mem) { List <ObjectShape> objectShapes = new List <ObjectShape>(); foreach (ObjectShape obj in mem.getSavedObject()) { ObjectShape newObj = (ObjectShape)obj.Clone(); objectShapes.Add(newObj); } return(new MemMemento(objectShapes)); }
public MemMemento getRedoMemento() { if (RedoStack.Count != 0) { MemMemento m = RedoStack.Pop(); UndoStack.Push(m); return(m); } else { return(null); } }
public void Redo(int level) { MemMemento memento = null; for (int i = 1; i <= level; i++) { memento = careTaker.getRedoMemento(); } if (memento != null) { mementoOriginator.setMemento(memento); } }
public void setMemento(MemMemento memento) { MemMemento curMem = CloneMemento(memento); canvasState.setObjectShapes(curMem.getSavedObject()); }
public void SetStateForUndoRedo() { MemMemento memento = mementoOriginator.getMemento(); careTaker.InsertMementoForUndoRedo(memento); }