示例#1
0
		public TaskEdit(TaskList taskList, Task task) {
			this.taskList = taskList;
			this.task = task;

			InitializeComponent();

			this.populateFields();
		}
示例#2
0
		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");
		}
示例#3
0
文件: Main.cs 项目: modulexcite/timer
		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;

		}
示例#4
0
文件: Main.cs 项目: modulexcite/timer
		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());
		}
示例#5
0
文件: Main.cs 项目: modulexcite/timer
		private void continueTask(Task task) {
			this.stopTask();
			this.taskList.SetCurrentTask(task);
			// order of projects will have changed
			this.populateProjects();
			this.populateTaskInfo();
			this.startTask();
		}
示例#6
0
		private void deleteWorkTime(Task.WorkTime workTime) {
			this.task.DeleteWorkTime(workTime);
			this.populateFields();
		}
示例#7
0
		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);
		}
示例#8
0
		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();
		}
示例#9
0
		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();
		}
示例#10
0
		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();
		}