예제 #1
0
        private void DisplayToDoTasks()
        {
            bool            inDisplayToDoTasks = true;
            int             pageCount          = 1;
            bool            multiPage          = false;
            List <ToDoTask> toDoTasks          = ToDoApp.GetToDoTasksByListId(ToDoApp.SelectedTaskList.Id);

            while (inDisplayToDoTasks)
            {
                Console.Clear();

                Console.WriteLine();
                if (toDoTasks.Count > NumberOfToDoTasksToDisplayPerPage)
                {
                    multiPage = true;
                }

                if (!multiPage)
                {
                    int counter = 1;
                    foreach (ToDoTask task in toDoTasks)
                    {
                        Console.WriteLine($"[{counter}] {task.Name}");
                        counter++;
                    }
                }
                else
                {
                    if (pageCount == 1)
                    {
                        int counter = 1;
                        foreach (ToDoTask task in toDoTasks)
                        {
                            if (counter <= NumberOfToDoTasksToDisplayPerPage)
                            {
                                Console.WriteLine($"[{counter}] {task.Name}");
                            }
                            counter++;
                        }
                        Console.WriteLine();
                        Console.WriteLine("[F] Next Page");
                    }
                    if (pageCount > 1)
                    {
                        int counter = 1;
                        foreach (ToDoTask task in toDoTasks)
                        {
                            if ((counter <= (NumberOfToDoTasksToDisplayPerPage * pageCount)) && counter > (NumberOfToDoTasksToDisplayPerPage * (pageCount - 1)))
                            {
                                Console.WriteLine($"[{counter}] {task.Name}");
                            }
                            counter++;
                        }
                        Console.WriteLine();
                        Console.WriteLine("[B] Previous Page");
                        if (toDoTasks.Count > NumberOfTaskListstoDisplayPerPage * pageCount)
                        {
                            Console.WriteLine("[F] Next Page");
                        }
                    }
                }
                Console.WriteLine("[Q] Return to To Do Lists");

                Console.WriteLine();
                int selection = NavigationTools.SelectIntegerOrQorForB("Select a ToDo Task to see more details...", 1, toDoTasks.Count);
                if (selection == -1)
                {
                    inDisplayToDoTasks = false;
                    if (CategoryView)
                    {
                        List <TaskList> taskLists = ToDoApp.GetTaskListsByCategoryId(ToDoApp.SelectedCategory.Id);
                        DisplayToDoLists(taskLists);
                    }
                    else
                    {
                        DisplayToDoLists(ToDoApp.CurrentTaskLists);
                    }
                }
                else if (selection == -2)
                {
                    pageCount++;
                }
                else if (selection == -3)
                {
                    pageCount++;
                }
                else if (selection > 0 && selection <= toDoTasks.Count)
                {
                    inDisplayToDoTasks = false;
                    ToDoApp.SetSelectedToDoTask(toDoTasks[(selection - 1)].Id);
                    DisplayToDoTaskDetails();
                }
            }
        }
예제 #2
0
        private void DisplayToDoLists(List <TaskList> taskLists)
        {
            bool inDisplayToDoLists = true;
            bool multiPage          = false;
            int  pageCount          = 1;

            if (NumberOfTaskListstoDisplayPerPage < taskLists.Count)
            {
                multiPage = true;
            }

            while (inDisplayToDoLists)
            {
                Console.Clear();
                Console.WriteLine("Practice ToDo Console App: Currently Viewing Task Lists");
                Console.WriteLine();
                if (!multiPage)
                {
                    int counter = 1;
                    foreach (TaskList taskList in taskLists)
                    {
                        Console.WriteLine($"[{counter}] {taskList.Name}");
                        counter++;
                    }
                }
                else
                {
                    if (pageCount == 1)
                    {
                        int counter = 1;
                        foreach (TaskList taskList in taskLists)
                        {
                            if (counter <= NumberOfTaskListstoDisplayPerPage)
                            {
                                Console.WriteLine($"[{counter}] {taskList.Name}");
                            }
                            counter++;
                        }
                        Console.WriteLine();
                        Console.WriteLine("[F] Next Page");
                    }
                    if (pageCount > 1)
                    {
                        Console.WriteLine($"Page #{pageCount}");
                        int counter = 1;
                        foreach (TaskList taskList in taskLists)
                        {
                            if ((counter <= (NumberOfTaskListstoDisplayPerPage * pageCount)) && counter > (NumberOfTaskListstoDisplayPerPage * (pageCount - 1)))
                            {
                                Console.WriteLine($"[{counter}] {taskList.Name}");
                            }
                            counter++;
                        }
                        Console.WriteLine();
                        Console.WriteLine("[B] Previous Page");
                        if (taskLists.Count > NumberOfTaskListstoDisplayPerPage * pageCount)
                        {
                            Console.WriteLine("[F] Next Page");
                        }
                    }
                }
                Console.WriteLine("[Q] Return to Main Menu");

                int selection = NavigationTools.SelectIntegerOrQorForB("Select a list to view or make changes", 1, ToDoApp.CurrentTaskLists.Count);

                if (selection == -1)
                {
                    inDisplayToDoLists = false;
                    MainMenu();
                }
                else if (selection == -2)
                {
                    pageCount++;
                }
                else if (selection == -3)
                {
                    pageCount--;
                }
                else if (selection > 0 && selection <= ToDoApp.CurrentTaskLists.Count)
                {
                    ToDoApp.SetSelectedTaskList(ToDoApp.CurrentTaskLists[selection - 1].Id);
                    DisplayTaskListDetails();
                    inDisplayToDoLists = false;
                }
            }
        }