Beispiel #1
0
        static void Main(string[] args)
        {
            XMLFile       file = new XMLFile();
            Navigation    nav  = new Navigation();
            List <MyTask> list = new List <MyTask>();

            file.Open(ref list); //Upload tasks from XML file
            if (list.Count <= 0) //if the XML file is empty then ask user input a new task
            {
                nav.AddTask(list);
                file.Save(list);
            }
            nav.KeyCatch(list);
        }
Beispiel #2
0
        const int TaskPerPage = 5; //Tasks per page
        public void KeyCatch(List <MyTask> taskList)
        {
            XMLFile file   = new XMLFile(); //needs it to save or open tasks in XML file
            int     index  = 0;             //current task
            int     cursor = 0;

            PrintTasks(index, taskList);
            ConsoleKeyInfo consoleKeyInfo;

            Console.SetCursorPosition(0, 0);

            if (index <= taskList.Count)
            {
                SelectTask(index, taskList);                                   //select current task first time
            }
            while ((consoleKeyInfo = Console.ReadKey()).Key != ConsoleKey.F12) //if pressed F12 close app
            {
                switch (consoleKeyInfo.Key)
                {
                case ConsoleKey.F1:    //skip
                    index++;
                    cursor++;
                    MoveToNext(ref index, ref cursor, taskList);
                    break;

                case ConsoleKey.F2:             //done
                    taskList[index].Status = 1; //cross-out current task
                    file.Save(taskList);
                    index++;
                    cursor++;
                    MoveToNext(ref index, ref cursor, taskList);
                    break;

                case ConsoleKey.F3:                  //Re-write
                    if (taskList[index].Status != 1) //if active task then re-write
                    {
                        taskList[index].Status = 1;
                        taskList.Add(new MyTask(0, taskList[index].TaskName, DateTime.Now));    //RewriteTask
                        file.Save(taskList);
                        PrintTasks(page, taskList);
                    }
                    cursor++;
                    index++;
                    MoveToNext(ref index, ref cursor, taskList);
                    break;

                case ConsoleKey.F4:    //add a new task
                    AddTask(taskList);
                    file.Save(taskList);
                    PrintTasks(page, taskList);
                    Console.SetCursorPosition(0, cursor);
                    SelectTask(index, taskList);
                    break;

                case ConsoleKey.PageDown:    //next page
                    cursor = TaskPerPage;
                    index  = page + TaskPerPage;
                    MoveToNext(ref index, ref cursor, taskList);
                    break;

                default:

                    break;
                }
            }
            clearConsol();//Clear console before closing app
        }