Пример #1
0
 private void AddTaskButton_Click(object sender, EventArgs e)
 {
     if (AddTaskForm != null)
     {
         AddTaskForm.Close();
     }
     AddTaskForm = new AddTask(this);
     AddTaskForm.Show();
 }
        static void Main(string[] args)
        {
            WriteOutTheManual();

            //var args = new string[2];
            //args[0] = "-r";
            //args[1] = "iuyabdsc";

            switch (args[0])
            {
            case "-l":
                var fh = new FileHandler("TodoApp.txt");
                fh.List();
                break;

            case "-a":
                try
                {
                    var at = new AddTask("TodoApp.txt", args[1]);
                    at.AddTaskToFile();
                    at.List();
                }
                catch (ArgumentNullException)
                {
                    Console.WriteLine("Unable to add: no task provided");
                }
                break;

            case "-r":
                try
                {
                    var rt = new RemoveTask("TodoApp.txt", Int32.Parse(args[1]));
                    rt.Remove();
                    rt.List();
                }
                catch (ArgumentNullException)
                {
                    Console.WriteLine("Unable to remove: no index provided");
                }
                catch (FormatException)
                {
                    Console.WriteLine("Unable to remove: index is not a number");
                }
                break;

            case "-t":
                try
                {
                    var ct = new CheckTask("TodoApp.txt", Int32.Parse(args[1]));
                    ct.CheckLine();
                    ct.List();
                }
                catch (ArgumentNullException)
                {
                    Console.WriteLine("Unable to check: no index provided");
                }
                catch (FormatException)
                {
                    Console.WriteLine("Unable to check: index is not a number");
                }
                break;

            default:
                WriteOutTheManual();
                break;
            }
            Console.ReadLine();
        }