public EditTaskDialog(string des, TimeSpan ts) { InitializeComponent(); taskUpdate = new TimedTask(des, ts); update = false; tbUDescription.Text = taskUpdate.description; tbUEstimatedTime.Text = taskUpdate.estimatedTime.TotalMinutes.ToString(); }
private void bAddTask_Click(object sender, EventArgs e) { int minutes; if (int.TryParse(tbEstimatedTime.Text, out minutes)) { TimedTask temp = new TimedTask(tbDescription.Text, new TimeSpan(0, minutes, 0)); TTlist.Add(temp); lvTasks.Items.Add(new ListViewItem(new string[] { temp.description, String.Format(timeFormattingEstimated, temp.estimatedTime.Minutes, temp.estimatedTime.Seconds), String.Format(timeFormattingActual, temp.actualTime.Minutes, temp.actualTime.Seconds) })); tbDescription.Text = ""; HandleListVewStrikout(); statusStrip1.Items[0].Text = "Total Estimated Time: " + CalculateTotalEstimatedTime(); } else { tbEstimatedTime.Text = ""; tbEstimatedTime.Select(); } }
private void lvTasks_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); LoadFromFile(fileNames[0]); } int i = lvTasks.InsertionMark.Index; if (i == -1) { return; } if (lvTasks.InsertionMark.AppearsAfterItem) { i++; } ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem)); int index = lvTasks.Items.IndexOf(lvTasks.FindItemWithText(draggedItem.SubItems[0].Text)); TimedTask temp = TTlist[index]; TTlist.Insert(i, temp); if (i <= index) { TTlist.RemoveAt(index + 1); } else { TTlist.RemoveAt(index); } lvTasks.Items.Insert(i, (ListViewItem)draggedItem.Clone()); lvTasks.Items.Remove(draggedItem); }