internal static void SuggestTask()
 {
     SetPidginStatus("Available", "");
     Notification notify;
     Tasks tasks = new Tasks();
     tasks.Load();
     Task task = tasks.GetPriority();
     if (task != null)
     {
         notify = new Notification("Tasks", "This is the next priority task:\n" + task.Summary);
         notify.AddAction("select", "Select", HandleSelectTask);
         notify.AddAction("postpone", "Delay", HandlePostponeTask);
         notify.AddAction("AddTask", "Add Task", HandleAddTask);
         notify.Timeout = 0;
         notify.Urgency = Urgency.Critical;
         notify.Show();
     }
     else
     {
         notify = new Notification("Tasks", "What are you working on?");
         notify.AddAction("AddTask", "Add Task", HandleAddTask);
         notify.Timeout = 0;
         notify.Urgency = Urgency.Critical;
         notify.Show();
     }
 }
 static void HandleDoNothing(object sender, ActionArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     Task current = tasks.CurrentTask();
     if (!current.IsWorked(DateTime.Now))
     {
         current.Worked.Add(DateTime.Now);
     }
     tasks.Save();
     SetPidginStatus("Busy", current.Summary);
 }
Exemple #3
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();
     }
 }
 internal static void DisplayMessage()
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     Task current = tasks.CurrentTask();
     Notification notify;
     if (current != null)
     {
         notify = new Notification("Tasks", "Are you still working on this task?\n" + current.Summary);
         notify.AddAction("yes", "Yes", HandleDoNothing);
         notify.AddAction("view", "View", HandleEditTask);
         notify.AddAction("finish", "Finish", HandleFinishedTask);
         notify.Timeout = 0;
         notify.Urgency = Urgency.Critical;
         notify.Show();
     }
     else
     {
         SuggestTask();
     }
 }
 static void HandleEditTask(object sender, ActionArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     EditTask(tasks.CurrentTask());
 }
 static void SelectTask()
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     tasks.FinishCurrentTaskAndStartPriorityTask();
     Task current = tasks.CurrentTask();
     SetPidginStatus("Busy", current.Summary);
 }
 static void HandlePostponeTask(object sender, ActionArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     tasks.PostponePriorityTask();
     SuggestTask();
 }
 static void HandleFinishedTask(object sender, ActionArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     Task task = tasks.CurrentTask();
     tasks.SetCurrentTaskFinished();
     Notification notify = new Notification();
     notify.Summary = "Task Finished";
     notify.Body = task.Summary;
     notify.Urgency = Urgency.Critical;
     notify.Show();
     SuggestTask();
 }
Exemple #9
0
 internal static int GenerateRandomID()
 {
     Random rand;
     Tasks tasks = new Tasks ();
     tasks.Load ();
     bool done = true;
     int id;
     do {
         rand = new Random (DateTime.Now.Millisecond + DateTime.Now.Second + DateTime.Now.Minute + DateTime.Now.Hour + DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year); // So we don't get stuck in an infinite loop
         id = rand.Next (100000000, 999999999); //Generate a random ID.
         foreach (Task task in tasks.tasks) {
             foreach (Subtask subtask in task.Subtasks) {
                 if (subtask.ID == id)
                     done = false;
             }
             if (task.ID == id)
                 done = false;
         }
     } while (!done);
     return id;
 }
        void PopulateWindow()
        {
            tasks = new Tasks();

            TreeViewColumn inProgress = new TreeViewColumn();
            TreeViewColumn summary = new TreeViewColumn();
            TreeViewColumn date = new TreeViewColumn();
            TreeViewColumn id = new TreeViewColumn();
            id.Visible = false;

            taskTreeView.HeadersVisible = false;
            taskTreeView.AppendColumn(inProgress);
            taskTreeView.AppendColumn(summary);
            taskTreeView.AppendColumn(date);
            taskTreeView.AppendColumn(id);

            taskList = new ListStore(typeof (bool), typeof (string), typeof (string), typeof (string));
            taskTreeView.Model = taskList;

            //Render the cells
            CellRendererToggle inProgressCell = new CellRendererToggle();
            inProgress.PackStart(inProgressCell, true);
            inProgressCell.Xpad = 10;
            inProgressCell.Ypad = 10;
            CellRendererText summaryCell = new CellRendererText();
            summary.PackStart(summaryCell, true);
            summaryCell.Xpad = 10;
            summaryCell.Ypad = 10;
            summaryCell.Editable = true;
            summaryCell.Edited += HandleSummaryCellEdited;
            CellRendererText dateCell = new CellRendererText();
            date.PackStart(dateCell, true);
            dateCell.Xpad = 10;
            dateCell.Ypad = 10;
            CellRendererText idCell = new CellRendererText();
            id.PackStart(idCell, true);
            idCell.Xpad = 10;
            idCell.Ypad = 10;

            inProgress.AddAttribute(inProgressCell, "active", 0);
            summary.AddAttribute(summaryCell, "text", 1);
            date.AddAttribute(dateCell, "text", 2);
            id.AddAttribute(idCell, "text", 3);

            Refresh();
        }
Exemple #11
0
 static void HandleEditTaskActivated(object sender, EventArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     RequestWork.EditTask(tasks.CurrentTask());
 }
Exemple #12
0
 static void MenuViewTaskActivated(object sender, EventArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     Task current = tasks.CurrentTask();
     Notification notify = new Notification(current.Summary, current.Description.Substring(0, (current.Description.Length > 1000 ? 1000 : current.Description.Length)));
     notify.AddAction("edit", "Edit", HandleEditTaskActivated);
     notify.AddAction("finish", "Mark Finished", MenuFinishTaskActivated);
     notify.AddAction("list", "Tasks", HandleViewTaskListActivated);
     notify.Urgency = Urgency.Critical;
     notify.Show();
 }
Exemple #13
0
 static void MenuFinishTaskActivated(object sender, EventArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     Task task = tasks.CurrentTask();
     tasks.SetCurrentTaskFinished();
     Notification notify = new Notification();
     notify.Summary = "Task Finished";
     notify.Body = task.Summary;
     notify.Urgency = Urgency.Critical;
     notify.Show();
     RequestWork.SuggestTask();
 }