Ejemplo n.º 1
0
        public bool Memorize()
        {
            if (!ShouldMemorize)
            {
                return(false);
            }
            //Delete index: current to end
            //If there are 3 and now on index 2, index 3 to 0 -> don't delete
            //If there are 3 and now on index 1, index 2 to 1 -> delete
            int startIndex  = curIndex + 1;
            int removeCount = infos.Count - 1 - curIndex;

//            Debug.WriteLine("RemoveRange({0}, {1})", startIndex, removeCount);
            infos.RemoveRange(startIndex, removeCount);
            if (UndoBufferCount > 0 && infos.Count > UndoBufferCount)
            {
                removeCount = infos.Count - UndoBufferCount;
                infos.RemoveRange(0, removeCount);
            }
            //Replication of the model after changing its properties are stored.

            EDOModel newModel = EDOSerializer.Clone(curModel);

            infos.Add(new UndoInfo(newModel, stateProvider.SaveState()));
            curIndex = infos.Count - 1;
//            Debug.WriteLine("model's count=" + models.Count + " curIndex=" + curIndex);
//            Debug.Assert(curIndex == models.Count - 1); // points at the bottom end
            OnModelChanged();
            return(true);
        }
Ejemplo n.º 2
0
        public bool ReplaceMemorize()
        {
            if (!ShouldMemorize)
            {
                return(false);
            }
            //replace the model of the last model of the current.
            EDOModel newModel = EDOSerializer.Clone(curModel);
            UndoInfo info     = new UndoInfo(newModel, stateProvider.SaveState());

            infos[curIndex] = info;
            OnModelChanged();
            return(true);
        }
Ejemplo n.º 3
0
 public UndoInfo Copy()
 {
     return(new UndoInfo(EDOSerializer.Clone(edoModel), (VMState)state.Clone()));
 }