コード例 #1
0
        protected void OnButtonOkClicked(object sender, System.EventArgs e)
        {
            Tasks tasks = new Tasks();

            tasks.Load();
            if (current.Active)
            {
                tasks.SetTaskNotActive();
            }
            List <Subtask> subtasks = Subtasks();

            if (!edit)
            {
                task = new Task(DateTime.Now, summary.Text, description.Buffer.Text, priority.Active * 5, current.Active);
                if (current.Active)
                {
                    task.Start = DateTime.Now;
                    if (!task.IsWorked(DateTime.Now))
                    {
                        task.Worked.Add(DateTime.Now);
                    }
                }
                task.Subtasks = subtasks;
                tasks.tasks.Add(task);
                tasks.Save();
            }
            else
            {
                DateTime        start  = task.Date;
                List <DateTime> worked = new List <DateTime>();
                foreach (DateTime date in task.Worked)
                {
                    worked.Add(date);
                }
                tasks.Remove(task);
                task = new Task(start, summary.Text, description.Buffer.Text, priority.Active * 5, current.Active);
                foreach (DateTime date in worked)
                {
                    task.Worked.Add(date);
                }
                if (current.Active)
                {
                    task.Start = DateTime.Now;
                    if (!task.IsWorked(DateTime.Now))
                    {
                        task.Worked.Add(DateTime.Now);
                    }
                }
                task.Subtasks = subtasks;
                tasks.tasks.Add(task);
                tasks.Save();
            }
        }
コード例 #2
0
ファイル: Reports.cs プロジェクト: dmulder/Task-Tracker
 private void FindFinishedTasks()
 {
     foreach (Task task in tasks.tasks)
     {
         if (task.Finished != DateTime.MinValue)
         {
             finishedTasks.Add(task);
         }
     }
     foreach (Task task in finishedTasks)
     {
         tasks.Remove(task);
     }
 }
コード例 #3
0
        protected void OnTaskTreeViewKeyPressEvent(object o, Gtk.KeyPressEventArgs args)
        {
            if (args.Event.Key == Gdk.Key.Delete)
            {
                Task          task    = SelectedTask();
                string        msg     = "Are you sure you want to delete this task?";
                MessageDialog message = new MessageDialog(null, DialogFlags.Modal, MessageType.Warning, ButtonsType.OkCancel, msg);
                int           result  = message.Run();
                message.Destroy();

                if (result == -5)
                {
                    tasks.Load();
                    tasks.Remove(task);
                    tasks.Save();
                }
                Refresh();
            }
        }
コード例 #4
0
ファイル: AddTask.cs プロジェクト: DavidMulder/Task-Tracker
 protected void OnButtonOkClicked(object sender, System.EventArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     if (current.Active)
     {
         tasks.SetTaskNotActive();
     }
     List<Subtask> subtasks = Subtasks();
     if (!edit)
     {
         task = new Task(DateTime.Now, summary.Text, description.Buffer.Text, priority.Active*5, current.Active);
         if (current.Active)
         {
             task.Start = DateTime.Now;
             if (!task.IsWorked(DateTime.Now))
             {
                 task.Worked.Add(DateTime.Now);
             }
         }
         task.Subtasks = subtasks;
         tasks.tasks.Add(task);
         tasks.Save();
     }
     else
     {
         DateTime start = task.Date;
         List<DateTime> worked = new List<DateTime>();
         foreach (DateTime date in task.Worked)
         {
             worked.Add(date);
         }
         tasks.Remove(task);
         task = new Task(start, summary.Text, description.Buffer.Text, priority.Active*5, current.Active);
         foreach (DateTime date in worked)
         {
             task.Worked.Add(date);
         }
         if (current.Active)
         {
             task.Start = DateTime.Now;
             if (!task.IsWorked(DateTime.Now))
             {
                 task.Worked.Add(DateTime.Now);
             }
         }
         task.Subtasks = subtasks;
         tasks.tasks.Add(task);
         tasks.Save();
     }
 }