示例#1
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);
        }
示例#2
0
        static void HandleEditTask(object sender, ActionArgs e)
        {
            Tasks tasks = new Tasks();

            tasks.Load();
            EditTask(tasks.CurrentTask());
        }
示例#3
0
        static internal 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();
            }
        }
示例#4
0
        static void HandleEditTaskActivated(object sender, EventArgs e)
        {
            Tasks tasks = new Tasks();

            tasks.Load();
            RequestWork.EditTask(tasks.CurrentTask());
        }
示例#5
0
 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();
     }
 }
示例#6
0
        private void HandleSummaryCellEdited(object o, EditedArgs args)
        {
            TreeIter iter;

            taskList.GetIterFromString(out iter, args.Path);
            taskList.SetValue(iter, 1, args.NewText);

            tasks.Load();
            int  id   = Convert.ToInt32((string)taskList.GetValue(iter, 3));
            Task task = tasks.Find(id);

            if (task != null)
            {
                task.Summary = args.NewText;
            }
            tasks.Save();
        }
示例#7
0
        static void HandlePostponeTask(object sender, ActionArgs e)
        {
            Tasks tasks = new Tasks();

            tasks.Load();
            tasks.PostponePriorityTask();
            SuggestTask();
        }
示例#8
0
        static void SelectTask()
        {
            Tasks tasks = new Tasks();

            tasks.Load();
            tasks.FinishCurrentTaskAndStartPriorityTask();
            Task current = tasks.CurrentTask();

            SetPidginStatus("Busy", current.Summary);
        }
示例#9
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();
            }
        }
示例#10
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();
     }
 }
示例#11
0
        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);
        }
示例#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();
        }
示例#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();
        }
示例#14
0
        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();
        }
示例#15
0
 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();
     }
 }
示例#16
0
        static internal 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();
            }
        }
示例#17
0
 static void SelectTask()
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     tasks.FinishCurrentTaskAndStartPriorityTask();
     Task current = tasks.CurrentTask();
     SetPidginStatus("Busy", current.Summary);
 }
示例#18
0
 static void HandlePostponeTask(object sender, ActionArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     tasks.PostponePriorityTask();
     SuggestTask();
 }
示例#19
0
 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();
 }
示例#20
0
 static void HandleEditTaskActivated(object sender, EventArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     RequestWork.EditTask(tasks.CurrentTask());
 }
示例#21
0
 public Reports()
 {
     tasks.Load();
     FindFinishedTasks();
     finishedTasks.Sort(CompareTasks);
 }
示例#22
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();
 }
示例#23
0
 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);
 }
示例#24
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;
 }
示例#25
0
 static void HandleEditTask(object sender, ActionArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     EditTask(tasks.CurrentTask());
 }
示例#26
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();
 }