예제 #1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            //prompt user to open file
            if (open.ShowDialog() == DialogResult.OK)
            {
                StreamReader sr = null;
                // read the current tasks in from file
                try {
                    sr = new StreamReader(open.OpenFile());
                    string[] curTasks = sr.ReadLine().Split('|');
                    foreach (string task in curTasks)
                    {
                        //load tasks into current tasks list
                        task.Task t = new task.Task(task);
                        if (t.getText() != "")
                        {
                            taskHolder.Rows.Add(t.getText());
                        }
                    }
                    //create string array to hold tasks
                    string[] completedTasks = sr.ReadLine().Split(',');
                    if (completedTasks[0] != null)
                    {
                        //load tasks into completed tasks list
                        foreach (string task in completedTasks)
                        {
                            task.Task t = new task.Task(task);
                            taskCompletedHolder.Rows.Add(t.getText());
                        }
                    }
                }
                catch
                {
                }
                finally
                {
                    //close the stream reader
                    if (sr != null)
                    {
                        sr.Close();
                    }
                }
            }
        }
예제 #2
0
 private void addButton_Click(object sender, EventArgs e)
 {
     if (taskBox.Text != "")
     {
         //creates a new Task and adds it to the todo list
         task.Task newTask = new task.Task(taskBox.Text);
         taskHolder.Rows.Add(newTask.getText());
         taskBox.Text = null;
     }
 }