Ejemplo n.º 1
0
        public void ABCfull()
        {
            FileStream readerStream = new FileStream("ToDoList.txt", FileMode.Open);

            string[] content = null;

            using (StreamReader reader = new StreamReader(readerStream))
            {
                content = reader.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                readerStream.SetLength(0);
            }

            FileStream writerStream = new FileStream("ToDoList.txt", FileMode.OpenOrCreate);

            using (StreamWriter writer = new StreamWriter(writerStream))
            {
                Array.Sort(content);
                writer.Write(string.Join(Environment.NewLine, content));
            }

            Console.WriteLine("Tasks sorted alphabetically");
            Console.WriteLine("Press Enter to refresh");
            Console.ReadLine();
            FullList fulllist = new FullList();

            fulllist.ShowFullList();
        }
Ejemplo n.º 2
0
        public void ShowCompletedList()
        {
            Console.Clear();
            var completedList = File.ReadAllText("Completed.txt");

            string[] removeDuplicates = File.ReadAllLines("Completed.txt");
            File.WriteAllLines("Completed.txt", removeDuplicates.Distinct().ToArray()); // panaikina duplikatus is full list ir priorities

            Console.WriteLine("COMPLETED:\n--------------------------------------");

            if (new FileInfo("Completed.txt").Length == 0)
            {
                Console.WriteLine("COMPLETED SECTION IS EMPTY");
            }
            else
            {
                Console.WriteLine(completedList);
            }

Start:
            Console.WriteLine("-------------------------------------------  ");
            Console.WriteLine("| 1: Show all |  2: Priority |   3: Empty |  ");
            Console.WriteLine("-------------------------------------------  ");

            string select = Console.ReadLine();

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

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

            case "3":
                File.WriteAllText("Completed.txt", String.Empty);
                Console.WriteLine("Completed tasks successfully deleted!");
                Console.WriteLine("Press enter to refresh");
                Console.ReadLine();
                Console.Clear();
                Completed completed = new Completed();
                completed.ShowCompletedList();
                break;

            default:
                Console.WriteLine("Wrong input, please try again:");
                goto Start;
            }
        }
Ejemplo n.º 3
0
        public void AddNewTask()
        {
            Console.Write("Write task: ");
            string writeTask        = Console.ReadLine();
            string convertToNewLine = (writeTask);

            File.AppendAllText("ToDoList.txt", convertToNewLine);
            Console.WriteLine("Task successfully added!");
            Console.WriteLine("Press Enter to refresh");
            Console.ReadLine();
            FullList fulllist = new FullList();

            fulllist.ShowFullList();
        }
Ejemplo n.º 4
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.º 5
0
        public void ShowMainScreen()
        {
            Console.Clear();
            Console.WriteLine();
            Console.WriteLine("    ▀█▀ █▀█   █▀▄ █▀█   █   █ █▀ ▀█▀    ");
            Console.WriteLine("     █  █▄█   █▄▀ █▄█   █▄▄ █ ▄█  █     ");
            Console.WriteLine();
            Console.WriteLine("----------------------------------------------    ");
            Console.WriteLine("| 1: Show all |  2: Priority |  3: Completed |    ");
            Console.WriteLine("----------------------------------------------    ");

Start:
            string select = Console.ReadLine(); // konvertuoju input i string, kad vietoj skaiciaus ivedus teksta programa neuzluztu

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

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

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

            default:
                Console.Write("Wrong input. Please try again: ");
                goto Start;
            }
        }
Ejemplo n.º 6
0
        public void WriteToComplete()
        {
            var toDoList      = File.ReadAllLines("ToDoList.txt");
            var priorityList  = File.ReadAllLines("ToDoListPriority.txt");
            var completedList = "Completed.txt";

Start:
            Console.Write("\nEnter task you completed: ");
            var itemToMove = Console.ReadLine();
            var wasFound   = false;

            foreach (var item in toDoList)
            {
                if (item.Contains(itemToMove, StringComparison.InvariantCultureIgnoreCase))
                {
                    wasFound = true;
                    if (!File.Exists(completedList))
                    {
                        using var file = File.Create(completedList);
                    }
                    File.AppendAllLines(completedList, new[] { item });
                    Console.WriteLine($"Task {item} moved to Completed");

                    var tempFile    = Path.GetTempFileName();
                    var linesToKeep = toDoList.Where(l => l != item);
                    File.WriteAllLines(tempFile, linesToKeep);
                    File.Delete("ToDoList.txt");
                    File.Move(tempFile, "ToDoList.txt");
                }
            }
            if (!wasFound)
            {
                Console.WriteLine("No such task exist, please try again:");
                goto Start;
            }
            foreach (var item in priorityList)
            {
                if (item.Contains(itemToMove, StringComparison.InvariantCultureIgnoreCase))
                {
                    wasFound = true;
                    if (!File.Exists(completedList))
                    {
                        using var file = File.Create(completedList);
                    }
                    File.AppendAllLines(completedList, new[] { item });
                    Console.WriteLine($"Priority task {item} moved to Completed");

                    var tempFile    = Path.GetTempFileName();
                    var linesToKeep = priorityList.Where(l => l != item);
                    File.WriteAllLines(tempFile, linesToKeep);
                    File.Delete("ToDoListPriority.txt");
                    File.Move(tempFile, "ToDoListPriority.txt");
                }
            }
            if (!wasFound)
            {
                Console.WriteLine("No such task exist, please try again:");
                goto Start;
            }

RestartZone:
            Console.WriteLine("----------------------------------------------------------------------  ");
            Console.WriteLine("| 1: Show all | 2: Mark another completed task |  3: View completed  |  ");
            Console.WriteLine("----------------------------------------------------------------------  ");
            string select = Console.ReadLine();

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

            case "2":
                goto Start;

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

            default:
                Console.WriteLine("Wrong number, please try again:");
                goto RestartZone;
            }
        }