Ejemplo n.º 1
0
        public void ShowFullList()
        {
            Console.Clear();
            var toDoList         = File.ReadAllText("ToDoList.txt");
            var removeEmptySpace = File.ReadAllLines("ToDoList.txt").Where(arg => !string.IsNullOrWhiteSpace(arg));

            File.WriteAllLines("ToDoList.txt", removeEmptySpace); //pasalina tuscias eilutes po to kai uzduotys istrinamos

            Console.WriteLine("TO DO LIST:\n--------------------------------------");
            Console.WriteLine(toDoList);
Start:
            Console.WriteLine();
            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine("| 1: Add new |  2: Mark as complete |  3: Add to Priority |");
            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine("| 4: View Priority |  5: Sort alphabetically |  6: Back |  ");
            Console.WriteLine("---------------------------------------------------------  ");

            string select = Console.ReadLine();

            switch (select)
            {
            case "1":
                AddNew addNew = new AddNew();
                addNew.AddNewTask();
                break;

            case "2":
                Completed markcomplete = new Completed();
                markcomplete.WriteToComplete();
                break;

            case "3":
                Priority addToPriority = new Priority();
                addToPriority.WriteToPriority();
                break;

            case "4":
                Priority priority = new Priority();
                priority.PrioritySelection();
                break;

            case "5":
                SortByABCS sort = new SortByABCS();
                sort.ABCfull();
                break;

            case "6":
                MainScreen mainScreen = new MainScreen();
                mainScreen.ShowMainScreen();
                break;

            default:
                Console.WriteLine("Wrong input, please try again");
                goto Start;
            }
        }
Ejemplo n.º 2
0
        public void WriteToPriority()
        {
            var toDoList    = File.ReadAllLines("ToDoList.txt");
            var newFilePath = "ToDoListPriority.txt";

Start:
            Console.Write("\nEnter task to copy: ");
            var itemToCopy = Console.ReadLine();
            var wasFound   = false;

            foreach (var item in toDoList)
            {
                if (item.Contains(itemToCopy, StringComparison.InvariantCultureIgnoreCase))
                {
                    wasFound = true;
                    if (!File.Exists(newFilePath))
                    {
                        using var file = File.Create(newFilePath);
                    }
                    File.AppendAllLines(newFilePath, new[] { item });
                    Console.WriteLine($"Task {item} copied to Priorities");
                    Console.WriteLine();
                    Console.WriteLine("----------------------------------------------    ");
                    Console.WriteLine("| 1: View priority |  2: Completed |  3: Back |   ");
                    Console.WriteLine("----------------------------------------------    ");

                    string select = Console.ReadLine();

                    switch (select)
                    {
                    case "1":
                        Priority priority = new Priority();
                        priority.PrioritySelection();
                        break;

                    case "2":
                        Completed completed = new Completed();
                        completed.ShowCompletedList();
                        break;

                    case "3":
                        MainScreen mainscreen = new MainScreen();
                        mainscreen.ShowMainScreen();
                        break;

                    default:
                        Console.WriteLine("Wrong number, please try again:");
                        goto Start;
                    }
                }
            }
            if (!wasFound)
            {
                Console.WriteLine("No such task exist, please try again:");
                goto Start;
            }
        }
Ejemplo n.º 3
0
        public void PrioritySelection()
        {
            Console.Clear();
            // todoItemDataManager.GetItems();
            string priority = File.ReadAllText("ToDoListPriority.txt");

            Console.WriteLine("PRIORITY:\n--------------------------------------");
            Console.WriteLine(priority);
Start:
            Console.WriteLine("---------------------------------------------------------------------------------------------  ");
            Console.WriteLine("| 1: Show all |  2: Mark as complete |  3:  Sort alphabetically  | 4: Completed |  5: Back  |  ");
            Console.WriteLine("---------------------------------------------------------------------------------------------  ");

            string select = Console.ReadLine();

            switch (select)
            {
            case "1":
                FullList fulllist = new FullList();
                fulllist.ShowFullList();
                break;

            case "2":
                Completed markcomplete = new Completed();
                markcomplete.WriteToComplete();
                break;

            case "3":
                SortByABCS sort = new SortByABCS();
                sort.ABCpriority();
                break;

            case "4":
                Completed completed = new Completed();
                completed.ShowCompletedList();
                break;

            case "5":
                MainScreen mainscreen = new MainScreen();
                mainscreen.ShowMainScreen();
                break;

            default:
                Console.WriteLine("Wrong input, please try again:");
                goto Start;
            }
        }
Ejemplo n.º 4
0
        public static void ViewTasks()
        {
            //load current todo list
            string[] ToDoList = System.IO.File.ReadAllLines(@"C:\Users\WWStudent\source\repos\ToDoList\ToDoList\ToDoTasks.txt");
            foreach (string element in ToDoList)
            {
                Program.TaskList.Add(element);
            }

            //do while loop
            int correct = 0;

            do
            {
                //menu options
                Console.Clear();
                Console.WriteLine("0. Go to Main Menu");
                Console.WriteLine("1. Enter new task");
                Console.WriteLine("M. Mark a task as completed");
                Console.WriteLine("D. Delete a task\n");
                Console.WriteLine("--------CURRENT TO-DO LIST---------");

                // Display the file contents by using a for loop.
                for (int i = 0; i < Program.TaskList.Count; i++)
                {
                    Console.WriteLine($"{i+1}: " + Program.TaskList[i]);
                }

                var UserSelection = Console.ReadLine().ToUpper();
                if (UserSelection == "0")
                {
                    MainScreen.Intro();
                }
                else if (UserSelection == "1")
                {
                    Console.Write("Enter new task >");
                    var taskentry = Console.ReadLine();
                    if (UserSelection == "")
                    {
                        Console.WriteLine("Please enter a task");
                        UserSelection = Console.ReadLine();
                    }
                    else
                    {
                        Program.TaskList.Add(taskentry);
                        //Tasks added to current task list
                        System.IO.File.WriteAllLines(@"C:\Users\WWStudent\source\repos\ToDoList\ToDoList\ToDoTasks.txt", Program.TaskList);
                    }
                }
                else if (UserSelection == "M")
                {
                    //TODO: MOVE ITEM FROM CURRENT TASK TO LIST TO COMPLETED
                    Console.WriteLine("Which task have you completed?");
                    if (int.TryParse(Console.ReadLine(), out int complete))
                    {
                        if (complete <= Program.TaskList.Count && complete >= 0)
                        {
                            CompletedTaskList.AddRange(Program.TaskList);
                            //    System.IO.File.WriteAllLines(@"C:\Users\WWStudent\source\repos\ToDoList\ToDoList\CompletedTaskList.txt", CompletedTaskList);
                        }
                    }
                }



                //Delete a task from current list
                else if (UserSelection == "D")
                {
                    Console.WriteLine("Which task do you want to delete?");
                    if (int.TryParse(Console.ReadLine(), out int selection))
                    {
                        if (selection <= Program.TaskList.Count && selection >= 0)
                        {
                            Program.TaskList.RemoveAt(selection - 1);
                            System.IO.File.WriteAllLines(@"C:\Users\WWStudent\source\repos\ToDoList\ToDoList\ToDoTasks.txt", Program.TaskList);
                        }
                        else
                        {
                            Console.WriteLine("Invalid Input, try again: ");
                            Console.ReadKey();
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Selection");
                    UserSelection = Console.ReadLine().ToUpper();
                }
            } while (correct == 0);
        }
Ejemplo n.º 5
0
 //Task list loaded
 static void Main(string[] args)
 {
     MainScreen.Intro();
 }