public void Push(IReversibleCommand command) { command.Run(); if (HasUndoneItems()) { RemoveUndoneItems(); _commands.Add(command); _commandIndex = _commands.Count - 1; return; } if (_commandIndex == null) _commandIndex = 0; else _commandIndex++; _commands.Add(command); }