public void AddNodeToUndo(Event task, int A, int B,Lesson lessonToUndo,bool undoEventAfter,bool redoEventAfter) { undoRedoEvent eventToAdd = new undoRedoEvent(task, A, B,lessonToUndo,undoEventAfter,redoEventAfter); if (redoStack.Count != 0) redoStack.Clear(); //when undoing, this will automatically get rid of all redo values. undoStack.Push(eventToAdd); undoToolStripMenuItem.Enabled = undoStack.Count > 1; redoToolStripMenuItem.Enabled = redoStack.Count > 1; }
private void UndoRedoEvents(undoRedoEvent e) { switch (e.task) { case Event.MovePeriod: if (e.lessonToUndo.PeriodIndex == e.B) currentTT.MovePeriods(e.lessonToUndo, Convert.ToByte(e.A)); else throw new Exception(); break; case Event.MoveYear: if (e.lessonToUndo.YearIndex == e.B) currentTT.MoveYears(e.lessonToUndo, Convert.ToByte(e.A)); else throw new Exception(); break; case Event.MoveStaff: if (e.lessonToUndo.TeacherAbbreviation == currentTT.Staff[e.B].TeacherAbbreviation) currentTT.MoveTeacher(e.lessonToUndo, Convert.ToByte(e.A)); else throw new Exception(); break; case Event.MoveRoom: if (e.lessonToUndo.RoomCode == currentTT.Rooms[e.B].RoomCode) currentTT.MoveRooms(e.lessonToUndo, Convert.ToByte(e.A)); else throw new Exception(); break; case Event.MoveForm: if (e.lessonToUndo.FormIndex == e.B) currentTT.MoveForms(e.lessonToUndo, Convert.ToByte(e.A)); else throw new Exception(); break; case Event.MoveToTray: break; case Event.MoveFromTray: break; case Event.MoveSubject: if (e.B == currentTT.GetIndexOfSubject(e.lessonToUndo.SubjectAbbreviation)) { e.lessonToUndo.SubjectAbbreviation = currentTT.Subjects[e.A].SubjectAbbreviation; } else throw new Exception(); break; case Event.ChangeHomework: e.lessonToUndo.homeworkAmount = Convert.ToByte(e.A); break; case Event.ChangeLocked: e.lessonToUndo.locked = (e.A == 255); break; case Event.ChangeInvisible: e.lessonToUndo.invisible = (e.A == 255); break; default: break; } }