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

            careTaker.InsertMementoForUndoRedo(memento);
        }