public TaskEdit(TaskList taskList, Task task) { this.taskList = taskList; this.task = task; InitializeComponent(); this.populateFields(); }
private void editWorkTime(Task.WorkTime workTime) { workTime.StartedAt = this.dateTimePickerFrom.Value; workTime.StoppedAt = this.dateTimePickerFrom.Value + (this.dateTimePickerDuration.Value - new DateTime(1970, 1, 1, 0, 0, 0)); this.task.SortWorkTimes(); this.populateFields(); // Find the moved task, and select int index = this.task.WorkTimes.FindIndex(x => x.StartedAt == workTime.StartedAt && x.StoppedAt == workTime.StoppedAt); this.listBoxWorkTimes.SelectedIndex = index; this.task.EditWorkTime(); this.labelTotalDuration.Text = this.task.Duration.ToString("hh':'mm':'ss"); }
private void editTask(int task_index, Task task) { this.stopTask(); // Copy the task so they don't edit the original copy Task taskNew = new Task(task.Serialize()); // Don't display on top any more, otherwise forces self on top of new window bool wasOnTop = this.TopMost; this.TopMost = false; using (TaskEdit taskEdit = new TaskEdit(this.taskList, taskNew)) { DialogResult result = taskEdit.ShowDialog(); if (result != DialogResult.OK) { this.TopMost = wasOnTop; return; } this.taskList.ReplaceTask(task_index, taskEdit.Task); this.populateProjects(); this.populateProjectTasks(); this.comboBoxProjectTasks.SelectedValue = taskEdit.Task.Project; } this.fileHandler.SaveTasks(this.taskList.Serialize()); this.TopMost = wasOnTop; }
private void deleteTask(Task task) { if (MessageBox.Show("Do you really want to delete this task?", "Really delete task?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.OK) return; // Stop the task if it's the current one bool currentTask = this.taskList.CurrentTask == task; if (currentTask) this.stopTask(); this.taskList.DeleteTask(task); // If it was the current task, re-populate this.populateProjects(); this.populateProjectTasks(); this.populateTaskInfo(); this.populateTaskList(); this.fileHandler.SaveTasks(this.taskList.Serialize()); }
private void continueTask(Task task) { this.stopTask(); this.taskList.SetCurrentTask(task); // order of projects will have changed this.populateProjects(); this.populateTaskInfo(); this.startTask(); }
private void deleteWorkTime(Task.WorkTime workTime) { this.task.DeleteWorkTime(workTime); this.populateFields(); }
private void populateFromDuration(Task.WorkTime workTime) { this.dateTimePickerFrom.Value = workTime.StartedAt; this.dateTimePickerDuration.Value = new DateTime(1970, 1, 1, 0, 0, 0) + (workTime.StoppedAt.Value - workTime.StartedAt); }
public void ReplaceTask(int old_index, Task task) { //int old_index = this.tasks. this.tasks.RemoveAt(old_index); this.tasks.Insert(old_index, task); if (!this.projects.Contains(task.Project)) this.projects.Insert(0, task.Project); this.generateProjects(); }
public void DeleteTask(Task task) { if (!this.tasks.Contains(task)) throw new Exception("Can't find that task when deleteing"); this.tasks.Remove(task); this.generateProjects(); this.currentProjectFinishedTime = this.calcCurrentProjectFinishedTime(); }
public void SetCurrentTask(Task task) { if (!this.tasks.Contains(task)) throw new Exception("Can't find that task when setting it as current"); // Take the task and stick it at the top this.tasks.Remove(task); this.tasks.Insert(0, task); this.currentProjectFinishedTime = this.calcCurrentProjectFinishedTime(); }