public void Undo(int levels)
 {
     writer.Write(string.Format("\n---- Undo {0} levels ", levels));
     // Perform undo operations
     for (int i = 0; i < levels; i++)
     {
         if (_current > 0)
         {
             Command_Calculator command = _commands[--_current] as Command_Calculator;
             command.UnExecute();
         }
     }
 }
 public void Redo(int levels)
 {
     writer.Write(string.Format("\n---- Redo {0} levels ", levels));
     // Perform redo operations
     for (int i = 0; i < levels; i++)
     {
         if (_current < _commands.Count - 1)
         {
             Command_Calculator command = _commands[_current++];
             command.Execute();
         }
     }
 }