private void UndoLastActionClick(object sender, System.EventArgs e) { // button2.Enabled = false; //have to disable button if calling this // foreach (DoesSomething thing in _allDoesSomethings) // { // counter = counter + 1; // if (counter == _allDoesSomethings.Count) // { // // thing.DoIt(); // _allDoesSomethings.RemoveAt(counter - 1); // counter = 0; // break; // } // // else // // { // // // } // // } int lastIndex = _allDoesSomethings.Count - 1; if (lastIndex >= 0) { DoesSomething lastAction = _allDoesSomethings[lastIndex]; lastAction.DoIt(); } else { MessageBox.Show("No 'last action' to Do or Undo!"); } }
private void RevertLastAction(object sender, System.EventArgs e) { if (LastUpdatedFormReference.Done == true) { LastUpdatedFormReference.UndoIt(); } else { LastUpdatedFormReference.DoIt(); } }
private void UndoLastAction(object sender, System.EventArgs e) { DoesSomething lastAction = _allDoesSomethings[_allDoesSomethings.Count - 1]; lastAction.DoIt(); }