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); }
static void HandleEditTask(object sender, ActionArgs e) { Tasks tasks = new Tasks(); tasks.Load(); EditTask(tasks.CurrentTask()); }
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(); } }
static void HandleEditTaskActivated(object sender, EventArgs e) { Tasks tasks = new Tasks(); tasks.Load(); RequestWork.EditTask(tasks.CurrentTask()); }
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(); } }
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(); }
static void HandlePostponeTask(object sender, ActionArgs e) { Tasks tasks = new Tasks(); tasks.Load(); tasks.PostponePriorityTask(); SuggestTask(); }
static void SelectTask() { Tasks tasks = new Tasks(); tasks.Load(); tasks.FinishCurrentTaskAndStartPriorityTask(); Task current = tasks.CurrentTask(); SetPidginStatus("Busy", current.Summary); }
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(); } }
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(); } }
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); }
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(); }
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(); }
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(); }
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 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(); } }
public Reports() { tasks.Load(); FindFinishedTasks(); finishedTasks.Sort(CompareTasks); }
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; }