Пример #1
0
 //Create a new task
 private void createTaskButton_Click(object sender, EventArgs e)
 {
     createTaskForm Form = new createTaskForm(this.DataManager.Definitions);
     Form.ShowDialog();
     if (Form.IsFinished)
     {
         this.DataManager.Tasks.TaskList.Add(this.DataManager.Tasks.GetTaskNonConflictingName(Form.Task));
         updateTaskListBox();
     }
     this.DataManager.Save();
 }
Пример #2
0
 //Edit an existing task
 private void editTaskButton_Click(object sender, EventArgs e)
 {
     if (taskGroupDisplayListBox.SelectedIndex == -1 || taskDisplayListBox.SelectedIndex == -1)
     {
         MessageBox.Show("Please select a task");
         return;
     }
     Task Original = this.DataManager.Tasks.GetTask(taskGroupDisplayListBox.SelectedItem.ToString(), taskDisplayListBox.SelectedItem.ToString());
     //Store if task is active
     bool TaskIsActive = Original.Active;
     //Disable task for editing
     Original.Active = false;
     createTaskForm Form = new createTaskForm(this.DataManager.Definitions, Original);
     Form.ShowDialog();
     if (Form.IsFinished)
     {
         //If not canceled overwrite the task with its new counterpart
         Original.Dispose();
         Task EditedTask = Form.Task;
         EditedTask.Active = TaskIsActive;
         this.DataManager.Tasks.TaskList[this.DataManager.Tasks.TaskList.IndexOf(Original)] = EditedTask;
     }
     else
         Original.Active = TaskIsActive;
     updateTaskListBox();
     this.DataManager.Save();
 }