Exemplo n.º 1
0
 /// <summary>
 /// Add an undo state to the current stage (if one is active) or directly
 /// to the stack as a new stage (if one isn't).
 /// </summary>
 /// <param name="state"></param>
 /// <param name="clearRedo">If true, the redo stack will be invalidated</param>
 public void AddUndoState(UndoState state, bool clearRedo = true)
 {
     if (!Locked && Active)
     {
         if (state != null && state.IsValid)
         {
             if (ActiveStage != null)// && !ActiveStage.Contains(state))
             {
                 ActiveStage.Add(state);
                 if (!UndoStack.Contains(ActiveStage))
                 {
                     AddUndoStage(ActiveStage);
                 }
             }
             else
             {
                 UndoStage stage = new UndoStage();
                 stage.Add(state);
                 AddUndoStage(stage);
             }
         }
         if (clearRedo)
         {
             RedoStack.Clear();
         }
     }
 }