/// <summary> /// Switch in edition mode for current task /// </summary> public void EditCurrentTask() { if (_selectedTask == null) { return; } TaskToDo editedTask = null; using (FormTaskEditor form = new FormTaskEditor(_selectedTask)) { if (form.ShowDialog() == DialogResult.OK) { editedTask = form.Task; } } if (editedTask != null) { //proceed to task replacement _tasks.ReplaceTask(_selectedTask, editedTask); SaveTasksToFile(); //Change the selection with current task _selectedTask = editedTask; _selectedSubtask = editedTask; //Refresh GUI RefreshContext refresher = new RefreshContext(); refresher.SetAll(); RefreshGui(refresher); } }
/// <summary> /// Create a new task /// </summary> public void CreateNewTask() { TaskToDo newTask = null; using (FormTaskEditor dialog = new FormTaskEditor("- New task")) { if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { newTask = dialog.Task; } } if (newTask != null) { //save the new task _tasks.AddTask(newTask); SaveTasksToFile(); //select this new task _selectedTask = newTask; _selectedSubtask = newTask; //Refresh GUI RefreshContext refresher = new RefreshContext(); refresher.SetAll(); RefreshGui(refresher); } }
/// <summary> /// init the controller and the main view /// </summary> public void Init() { //try to load the saved file if (File.Exists(_saveFileName)) { _tasks.LoadFromFile(_saveFileName); } else { _view.DisplayMessageBox(String.Format("{0} doesn't exist, create a new empty collection of tasks", _saveFileName), "New file"); } //Refresh all the GUI RefreshContext refresher = new RefreshContext(); refresher.SetAll(); RefreshGui(refresher); }
/// <summary> /// Removes the currently selected task from the collection /// </summary> public void DeleteSelectedTask() { if (_selectedTask == null) { return; } //remove the task _tasks.RemoveTask(_selectedTask); SaveTasksToFile(); //Delete the selection _selectedTask = null; _selectedSubtask = null; //Refresh the GUI RefreshContext refresher = new RefreshContext(); refresher.SetAll(); RefreshGui(refresher); }