コード例 #1
0
ファイル: ToDoApp.cs プロジェクト: stefanfeurle/C-
        private void btnAddTask_Click(object sender, EventArgs e)
        {
            var time = dateTimePicker.Value;
            var task = rtbTask.Text;
            var todo = new ToDoList()
            {
                dateTime = time, task = task, hasDoneTask = 0
            };

            MessageBox.Show(controller.NewTask(todo));
            rtbTask.Text = null;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: emkristi/ToDoApp
        public static void Main(string[] args)
        {
            Console.WriteLine("Choose command: Add \"example task\" or Add example task | Do #tasknumber | Print ");

            string      filename = @"/Users/eline/Projects/ToDoApp/ToDoApp/TextFile.txt";
            List <Task> list     = new List <Task>();
            ToDoList    thelist  = new ToDoList();

            thelist.UpdateList(list, filename);


            while (true)
            {
                string input       = Console.ReadLine();
                string commandVerb = "";

                if (input.Contains(" "))
                {
                    commandVerb = input.Substring(0, input.IndexOf(' '));
                }

                if (commandVerb == "Add")
                {
                    string taskRead = thelist.CheckAddString(input);
                    int    taskid   = thelist.AssignId(list);
                    list.Add(new Task(taskRead, taskid));
                    thelist.WriteListToFile(list, filename);

                    Console.WriteLine("#" + taskid + " " + taskRead);
                }
                else if (commandVerb == "Do")
                {
                    thelist.DoTask(list, input);
                    thelist.WriteListToFile(list, filename);
                }
                else if (input == "Print")
                {
                    thelist.PrintListFromFile(filename);
                }
                else
                {
                    Console.WriteLine("No such command.");
                }
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            ToDoList toDoList = new ToDoList();

            string fileLocation = "../../SavedList.txt";

            toDoList.readListFromFile(fileLocation);

            Console.WriteLine("Welcome to your to-do list app! Write:\n" +
                              "Add \"new item\" like Add \"Buy birthday gift to mom\" to add a new task to the to-do list\n" +
                              "Do # + number of task you want to do, like Do #3, to complete a task on the to-do list, and delete it\n" +
                              "Print to print to-do list\n" +
                              "Exit to exit program (remember to exit program properly with Exit command to save your to-do list)\n");


            while (true)
            {
                string input = Console.ReadLine();

                if (input.Length > 6 && input.Substring(0, 5) == "Add \"")
                {
                    toDoList.addToToDoList(input.Substring(4, input.Length - 4));
                }
                else if (input.Length > 4 && input.Substring(0, 4) == "Do #")
                {
                    toDoList.completeToDo(input.Substring(4));
                    toDoList.printToDoList();
                }
                else if (input == "Print")
                {
                    toDoList.printToDoList();
                }
                else if (input == "Exit")
                {
                    toDoList.writeListToFile();
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid input, please try again.\n");
                }
            }
        }