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>
        /// Adding Items to the user list by importing the list from file. Adding to the list and then saving the list.
        /// After enter the item the user is returned to the main menu
        /// </summary>
        public void AddToListMenu()
        {
            MenuDisplaySettings();

            ClassLists cL = new ClassLists();

            Files files = new Files();

            List <Tuple <string, bool> > MyList = files.LoadItem();

            Console.WriteLine("\n\tAdd Task Menu");

            // Change text
            Console.Write("Add Something: ");

            string userInput = Console.ReadLine();

            cL.AddThingsToMyList(userInput, MyList);
        }
        /// <summary>
        /// View menu pulls from the load method > which opens the file location and assigns the list values to "MyList"
        /// </summary>
        public void ViewListMenu()
        {
            Files      files      = new Files();
            ClassLists classLists = new ClassLists();
            List <Tuple <string, bool> > MyList = files.LoadItem();

            /// The base that the item numbers in the console display calculate from.
            int i = 1;

            /// used to calulate list position
            int currentPage = 0;

            int totalPages = (int)Math.Ceiling(MyList.Count() / 25.0);

            /// To Do

            bool loopComplete = false;

            do
            {
                /// Menu display clears the console and resets the color to white.
                MenuDisplaySettings();
                /// view list is the text displayed for the user in the console window.
                ViewList();
                int lowerLimit = currentPage * 25;

                /// the count must consider if there are less than 25 items on the list. The else statement covers the
                /// range should there be more than 25 items. The code will not run without the first if statement.
                int count;
                if (MyList.Count < 25)
                {
                    count = MyList.Count;
                }
                else
                {             /// needs to start with 1
                    count = (currentPage + 1 == totalPages) ? (MyList.Count - currentPage * 25) : 25;
                }
                /// Creates the list of the items currently on the list. Also evaluates if the task is complete.
                foreach (Tuple <string, bool> item in MyList.GetRange(lowerLimit, count))
                {
                    if (item.Item2 == true)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        Console.WriteLine($"{i++}) {item.Item1}");
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine($"{i++}) {item.Item1}");
                    }
                }
                /// re-sets the counter to one so that the list only displays items 1 - 25 for each page.
                i = 1;
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine($"\nCurrent Page #{currentPage + 1} of {totalPages}");
                Console.WriteLine("---------------------");
                // condition next && previous pages

                Console.WriteLine($"'n') Next Page");
                Console.WriteLine($"'p') Previous Page");


                Console.Write("\nEnter Your Selection: ");
                string userInput = Console.ReadLine().ToLower();

                try
                {
                    MenuDisplaySettings();

                    int intUserInput = Convert.ToInt32(userInput);

                    /// calculates list index position
                    int indexNumber = ((currentPage * 25) + intUserInput) - 1;


                    Console.WriteLine($"\nTask:\t{MyList[indexNumber].Item1}");

                    Console.WriteLine("\n\n1) Complete");

                    Console.WriteLine("\n2) Do It Later");

                    Console.ForegroundColor = ConsoleColor.Gray;

                    Console.WriteLine("   This Option will mark the item as\n" +
                                      "   complete and create a Incomplete\n" +
                                      "   at the end of the list. ");

                    Console.Write("\nPlease make your selection: ");
                    string completeOrDoItLater = Console.ReadLine();

                    string newTask = MyList[indexNumber].Item1;

                    if (completeOrDoItLater == "1")
                    {
                        classLists.MarkedAsComplete(MyList, indexNumber);
                        Console.WriteLine("\nYour task has been marked complete");
                        Console.ReadLine();
                    }
                    else if (completeOrDoItLater == "2")
                    {
                        classLists.MarkedAsComplete(MyList, indexNumber);
                        classLists.AddThingsToMyList(newTask, MyList);
                        Console.WriteLine("\nYour list has been updated");
                        Console.ReadLine();
                    }
                    else
                    {
                        continue;
                    }


                    Console.ReadLine();
                }
                catch (Exception)
                {
                    /// handles next page input
                    if (userInput == "n")
                    {
                        if (currentPage == totalPages)
                        {
                            currentPage = 0;
                            continue;
                        }
                        else
                        {
                            currentPage++;
                            continue;
                        }
                    }

                    /// handles previous page input
                    else if (userInput == "p")
                    {
                        if (currentPage == 0)
                        {
                            currentPage = (totalPages - 1);
                            continue;
                        }
                        else
                        {
                            currentPage--;
                            continue;
                        }
                    }
                    else
                    {
                        loopComplete = true;
                    }


                    //Console.ReadLine();
                }
                /// Previous
            } while (!loopComplete);
            Console.ReadLine();
        }
Example #4
0
        /// <summary>
        /// View menu pulls from the load method > which opens the file location and assigns the list values to "MyList"
        /// </summary>
        public void ViewListMenu()
        {
            Files files = new Files();

            List <Tuple <string, bool> > MyList = files.LoadItem();


            int i           = 1;
            int currentPage = 0;
            int totalPages  = (int)Math.Ceiling(MyList.Count() / 25.0);

            /// To Do



            do
            {
                MenuDisplaySettings();
                ViewList();

                int lowerLimit = currentPage * 25;
                int count      = (currentPage == totalPages) ? (MyList.Count - currentPage * 25) : 25;
                /// Creates the list of the items currently on the list. Also evaluates if the task is complete.
                foreach (Tuple <string, bool> item in MyList.GetRange(lowerLimit, count))
                {
                    if (item.Item2 == true)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkGray;
                        Console.WriteLine($"{i++}){item.Item1}");
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine($"{i++}) {item.Item1}");
                    }
                }
                i = 1;

                /// bottom of the list view page.
                Console.WriteLine($"\nCurrent Page #{currentPage + 1} of {totalPages}");
                Console.WriteLine("---------------------");
                // condition next && previous pages

                Console.WriteLine($"'n') Next Page");
                Console.WriteLine($"'p') Previous Page");


                Console.Write("\nEnter Your Selection: ");
                string userInput = Console.ReadLine().ToLower();

                try
                {
                    if (userInput != "p" || userInput != "n" || userInput != "q")
                    {
                        MenuDisplaySettings();
                        int intUserInput = Convert.ToInt32(userInput);
                        Console.WriteLine($"Task:\t{MyList[( (currentPage*25)+ intUserInput) - 1].Item1}");
                        Console.WriteLine("\n\n1) Complete");
                        Console.WriteLine("\n2) Do It Later");
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.WriteLine("   This Option will mark the item as\n" +
                                          "   complete and create a Incomplete\n" +
                                          "   at the end of the list. ");
                        /// Add Method to Complete or Do Later
                        Console.ReadLine();
                    }
                    /// Next
                    else if (userInput == "n")
                    {
                        if (currentPage == totalPages)
                        {
                            currentPage = 0;
                        }
                        else
                        {
                            currentPage++;
                        }
                    }
                    else if (userInput == "p")
                    {
                        if (currentPage == 0)
                        {
                            currentPage = (totalPages - 1);
                        }
                        else
                        {
                            currentPage--;
                        }
                    }
                }
                catch (Exception)
                {
                    break;
                }
                /// Previous
            } while (true);
            Console.ReadLine();



            /// Takes the user selection from the list view menu



            ///     a.Mark as Complete
            ///     b.Mark as Incomplete
            ///
            /// Next page (if more than 25)
            /// Previous page



            Console.ReadLine();
        }
Example #5
0
        public void Formalities()
        {
            Files files = new Files();

            files.LoadItem();
        }