コード例 #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (G.glb.lstTask.Exists(o => o.TaskName == txtTask.Text))
     {
         MessageBox.Show("Task exists!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         CTask newTask = new CTask();
         newTask.TaskName   = txtTask.Text;
         newTask.DeadLine   = dtpDeadLine.Value.Date;
         newTask.TaskState  = ETaskState.NotStartedYet;
         newTask.IsBottom   = chkBottom.Checked;
         newTask.IsInfinite = chkInfinite.Checked;
         G.glb.lstTask.Add(newTask);
         RSubTask newRSubTask = new RSubTask();
         int      maxIndex;
         if (G.glb.lstSubTask.Exists(o => o.Task == UpperTask))
         {
             List <RSubTask> sameLevel = G.glb.lstSubTask.FindAll(o => o.Task == UpperTask).ToList();
             sameLevel = sameLevel.OrderByDescending(o => o.index).ToList();
             maxIndex  = sameLevel[0].index + 1;
         }
         else
         {
             maxIndex = 0;
         }
         newRSubTask.Task    = UpperTask;
         newRSubTask.SubTask = txtTask.Text;
         newRSubTask.index   = maxIndex;
         G.glb.lstSubTask.Add(newRSubTask);
         AddChildNode(txtTask.Text);
         Dispose();
     }
 }
コード例 #2
0
ファイル: frmTask.cs プロジェクト: isaac0821/LifeGame
 private void LoadTask(string taskName)
 {
     chkBottom.Enabled   = false;
     chkFinished.Enabled = false;
     dtpDeadline.Enabled = false;
     chkInfinite.Enabled = false;
     dgvLog.Rows.Clear();
     if (G.glb.lstTask.Exists(o => o.TaskName == taskName))
     {
         CTask task = G.glb.lstTask.Find(o => o.TaskName == taskName);
         lblTaskTitle.Text = task.TaskName;
         chkBottom.Checked = task.IsBottom;
         if (task.TaskState == ETaskState.Finished)
         {
             chkFinished.Checked = true;
         }
         calculate C = new calculate();
         lblTaskTimeSpent.Text = Math.Round(C.CalTimeSpentInTask(task.TaskName, G.glb.lstSubTask, G.glb.lstLog), 2).ToString() + "h";
         DateTime?NextTimeMarker = C.FindNextTimeMarker(task.TaskName, G.glb.lstSubTask, G.glb.lstTask);
         if (NextTimeMarker != null)
         {
             dtpNextTimeMarker.Value = (DateTime)NextTimeMarker;
         }
         else
         {
             dtpNextTimeMarker.Value = new DateTime(9998, 12, 31);
         }
         if (task.IsInfinite)
         {
             chkInfinite.Checked = true;
             dtpDeadline.Value   = new DateTime(9998, 12, 31);
         }
         else
         {
             chkInfinite.Checked = false;
             dtpDeadline.Value   = task.DeadLine;
         }
         List <string> bottomTasks = C.FindAllBottomTask(taskName, G.glb.lstSubTask);
         foreach (string bottomTask in bottomTasks)
         {
             List <CLog> logs = G.glb.lstLog.FindAll(o => o.ContributionToTask == bottomTask);
             foreach (CLog log in logs)
             {
                 TimeSpan span = log.EndTime - log.StartTime;
                 dgvLog.Rows.Add(
                     log.StartTime.ToString("MM/dd/yyyy"),
                     bottomTask,
                     log.LogName,
                     span.TotalHours
                     );
             }
         }
         lsbTaskNote.Items.Clear();
         List <CNote> notes = G.glb.lstNote.FindAll(o => C.FindAllHeirTask(taskName, G.glb.lstSubTask).Exists(p => p == o.TaskName));
         foreach (CNote note in notes)
         {
             lsbTaskNote.Items.Add(note.TagTime.Year.ToString() + "." + note.TagTime.Month.ToString() + "." + note.TagTime.Day.ToString() + " - " + note.Topic);
         }
     }
     else
     {
         lblTaskTitle.Text     = "(No Record)";
         chkBottom.Checked     = false;
         chkFinished.Checked   = false;
         chkInfinite.Checked   = false;
         lblTaskTimeSpent.Text = "----";
         lsbTaskNote.Items.Clear();
         dtpNextTimeMarker.Value = DateTime.Today;
         dtpDeadline.Value       = DateTime.Today;
     }
 }