/// <summary> /// Method to handle user input and run the main command loop of the compare menu /// </summary> public void Handle() { //Initialize the result of the command loop to null /*backSelected is used to end text entry and return user to MainMenu * If backSelected was not used, the user has to click Back once to cancel text entry * and then again to return to Main Menu */ if (!backSelected) { result = null; } else { result = "Back"; } //Create a timetable setting values to defaults _toPrint.Create(); //While the result string is null or the window close is not requested by the user while ((result == null) && (!(SwinGame.WindowCloseRequested()))) { //Process user input SwinGame.ProcessEvents(); //Draw the main menu this.Draw(); //If the user clicks the left mouse button call the clicked function and set result to the return string if (SwinGame.MouseClicked(MouseButton.LeftButton)) { result = this.clicked(SwinGame.MousePosition()); } } //Check the value result picked up from the button clicked and navigate to the menu or function requested switch (result) { case "Back": GlobalState.State = State.Back; backSelected = false; _TTnames.Clear(); _toCompare.Clear(); break; case "Add": GetFileName(); this.Handle(); break; case "Compare": CompareTimetables(); OutputTimetableInfo(); break; default: break; } }
/// <summary> /// Utility method that takes in a string from a textfile and returns a timetable of the values /// </summary> private Timetable FormatInputForTimetableEntry(String text) { char[] chars = text.ToCharArray(); Timetable result = new Timetable(); result.Create(); //Pass the array to the timetables populate method result.PopulateTimetable(chars); return(result); }
/// <summary> /// Method to handle user input and run the main command loop of the manage menu /// </summary> public void Handle() { //Display and create the timetable //New timetable prevents the timetable from being overridden if a user is returning from the Name Entry page _timetabledisplayed = true; if (!newTimetable) { _timetable.Create(); } //Initialize the result of the command loop to null string result = null; //While the result string is null or the window close is not requested by the user while ((result == null) && (!(SwinGame.WindowCloseRequested()))) { //Process user input SwinGame.ProcessEvents(); //Draw the manage menu this.Draw(); //If the user clicks or holds the left mouse button call the clicked function and set result to the return string if (SwinGame.MouseClicked(MouseButton.LeftButton)) { //Add all blocks in the timetable to the NotYetAltered list, part of the click and drag functionality foreach (Block b in _timetable.Times) { b.NotYetAltered = true; } result = this.clicked(SwinGame.MousePosition()); } //Used for click and drag when changing timetable blocks //Only in effect when the mouse is within the boundaries of the timetable else if (SwinGame.MouseDown(MouseButton.LeftButton) && SwinGame.MouseY() > 100 && SwinGame.MouseY() < 230 && SwinGame.MouseX() > 80) { result = this.clicked(SwinGame.MousePosition()); } } string ColOrRowToChange = result; if (result == null) { return; } if (result.Length < 3) { result = "Col"; } else if (result.Contains("day")) { result = "Row"; } //Check the value result picked up from the button clicked and navigate to the menu or function requested switch (result) { case "Back": GlobalState.State = State.Back; break; case "Save": Save(); break; case "Change": _toChange = true; Handle(); break; case "Row": _changeRow = true; //Prevents the timetable from resetting //Before this was included, every block was set to NO and then the selected Row was toggled newTimetable = true; ToChange(ColOrRowToChange); Handle(); break; case "Col": _changeCol = true; //Prevents the timetable from resetting //Before this was included, every block was set to NO and then the selected Col was toggled newTimetable = true; ToChange(ColOrRowToChange); Handle(); break; default: break; } }