public void Formalities() { ClassLists classLists = new ClassLists(); Files files = new Files(); List <Tuple <string, bool> > MyList = files.LoadItem(); if (MyList.Count > 25) { int count = 0; /// Looks at the first 25 items on the list to see if they are complete. If all 25 are complete they are deleted. foreach (Tuple <string, bool> item in MyList.GetRange(0, 25)) { /// if a single item is uncomplete all 25 remain if (item.Item2 == false) { } else { count++; } } /// removes the 25 complete items and saves the list. if (count == 25) { classLists.RemoveThingsFromMyList(MyList, 25); files.SaveItem(MyList); } } }
/// <summary> /// Adds a new item to the list and then updates the Data File /// t.2 is set to false indicating the item has not been completed. /// </summary> public void AddThingsToMyList(string userInput, List <Tuple <string, bool> > MyList) { Files files = new Files(); MyList.Add(new Tuple <string, bool>(userInput, false)); files.SaveItem(MyList); }
/// <summary> /// Marks the item in the list complete by creating a tuple with the altered bool value /// in the same position as the previous version. The list is then saved /// to the data file. /// </summary> public void MarkedAsComplete(List <Tuple <string, bool> > MyList, int indexNumber) { Files files = new Files(); // Unpack the tuple var myTuple = MyList[indexNumber]; var row = myTuple.Item1; // value of 0 var col = myTuple.Item2; // value of 1 // creates a new tuple in the index position of the old value MyList[indexNumber] = new Tuple <string, bool>(row, true); files.SaveItem(MyList); }