private void addWorkTime() { Task.WorkTime workTime = new Task.WorkTime(); workTime.StartedAt = this.dateTimePickerFrom.Value; workTime.StoppedAt = this.dateTimePickerFrom.Value + (this.dateTimePickerDuration.Value - new DateTime(1970, 1, 1, 0, 0, 0)); this.task.AddWorkTime(workTime); this.populateFields(); // Find the new task, and select int index = this.task.WorkTimes.FindIndex(x => x.StartedAt == workTime.StartedAt && x.StoppedAt == workTime.StoppedAt); this.listBoxWorkTimes.SelectedIndex = index; this.labelTotalDuration.Text = this.task.Duration.ToString("hh':'mm':'ss"); }
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); }