示例#1
0
 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));
        }
示例#3
0
 public MemMemento getRedoMemento()
 {
     if (RedoStack.Count != 0)
     {
         MemMemento m = RedoStack.Pop();
         UndoStack.Push(m);
         return(m);
     }
     else
     {
         return(null);
     }
 }
示例#4
0
        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());
        }
示例#6
0
        public void SetStateForUndoRedo()
        {
            MemMemento memento = mementoOriginator.getMemento();

            careTaker.InsertMementoForUndoRedo(memento);
        }