Ejemplo n.º 1
0
        public UndoHistory(ControlGUI gui)
        {
            this.gui = gui;

            isEnabled = true;
            history   = new LinkedList <UndoHistoryState>();
            lastState = null;

            stateInterrupt = new UndoHistoryStateInterrupt();
        }
Ejemplo n.º 2
0
 public void RestoreState()
 {
     while (true)
     {
         UndoHistoryState newState = RestoreStateInternal();
         if (newState == null)
         {
             break;
         }
         if (newState is UndoHistoryStateBoneTransform)
         {
             break;
         }
     }
     //PrintUndoHistory();
 }
Ejemplo n.º 3
0
        private UndoHistoryState RestoreStateInternal()
        {
            if (history.Count == 0)
            {
                return(null);
            }

            UndoHistoryState state = history.Last.Value;

            history.RemoveLast();

            isEnabled = false;
            state.Apply(gui);
            isEnabled = true;

            lastState = (history.Count > 0 ? history.Last.Value : null);
            return(state);
        }
Ejemplo n.º 4
0
        public void SaveState(UndoHistoryState state)
        {
            if (!isEnabled)
            {
                return;
            }
            bool isSignificant = true;

            if (lastState != null)
            {
                isSignificant = state.DetermineSignificance(lastState);
            }
            if (isSignificant)
            {
                history.AddLast(state);
                if (history.Count > MaxHistorySize)
                {
                    history.RemoveFirst();
                }
                //PrintUndoHistory();
            }
            lastState = state;
        }
Ejemplo n.º 5
0
 public void Clear()
 {
     history.Clear();
     lastState = null;
 }