예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EditTaskForm"/> class.
 /// </summary>
 /// <param name="taskToEdit">The task to edit.</param>
 public EditTaskForm(Task taskToEdit)
 {
     editableTask = taskToEdit;
     InitializeComponent();
     saveEditButton.Enabled = false;
     this.editTaskBox.TextChanged += new System.EventHandler(CheckInput);
     this.editTagBox.TextChanged += new System.EventHandler(CheckInput);
 }
예제 #2
0
 /// <summary>
 /// Adds the task to the list of tasks.
 /// </summary>
 /// <param name="task">The task.</param>
 public void AddTask(Task task)
 {
     taskList.Add(task);
 }
예제 #3
0
        /// <summary>
        /// Sends a reminder for the task.
        /// </summary>
        /// <param name="task">The t.</param>
        /// <param name="email">The email.</param>
        /// <returns></returns>
        private bool SendReminder(Task task, Email email)
        {
            bool reminderSucceeded = true;
            string subject = "REMINDER: " + task.tag + " - " + task.task;
            string body;

            if (task.daysOfReminder == 0)
            {
                body = "Your deadline is today, " + task.date.ToLongDateString() + " for \"" + task.tag + " - " + task.task + "\".";
            }
            else if (task.daysOfReminder == 1)
            {
                if (task.completed)
                {
                    body = "You have 1 day to until your deadline \"" + task.tag + " - " + task.task
                        + "\".\nThat is your deadline is tommorow, " + task.date.ToLongDateString() + ".";
                }
                else
                {
                    body = "You have 1 day to complete \"" + task.tag + " - " + task.task
                         + "\".\nThat is your deadline is tommorow, " + task.date.ToLongDateString() + ".";
                }
            }
            else
            {
                if (task.completed)
                {
                    body = "You have " + task.daysOfReminder.ToString() + " days to until your deadline \"" + task.tag + " - " + task.task
                        + "\".\nThat is your deadline is, " + task.date.ToLongDateString() + ".";
                }
                else
                {
                    body = "You have " + task.daysOfReminder.ToString() + " days to complete \"" + task.tag + " - " + task.task
                        + "\".\nThat is your deadline is, " + task.date.ToLongDateString() + ".";
                }
            }
            if (task.notes.Length > 0)
            {
                body += "\n\nYour notes are provided below.\n";
                body += "-----------------------------------------------\n";
                body += task.notes;
                body += "\n-----------------------------------------------";
            }
            body += "\n\nThis Message is brought to you by Task Manager.";
            email.Send(subject, body, task.reminderEmail, ref reminderSucceeded);
            if (reminderSucceeded)
            {
                task.reminder = false;
            }

            return reminderSucceeded;
        }
예제 #4
0
        /// <summary>
        /// Returns true if the task passes the current filters selected.
        /// </summary>
        /// <param name="activeFilters">The active filters.</param>
        /// <param name="task">The task.</param>
        /// <returns>True iff the task passes the current filters selected.</returns>
        private bool AcceptTask(CheckedListBox.CheckedItemCollection activeFilters, Task task)
        {
            if (activeFilters.Contains("All") || activeFilters.Contains(task.tag))
            {
                return true;
            }
            else if (activeFilters.Contains("Today") && task.date.Date == System.DateTime.Today)
            {
                return true;
            }
            else if (activeFilters.Contains("Next 3 Days")
                && (task.date.Date <= System.DateTime.Today.AddDays(3))
                && task.date.Date >= System.DateTime.Today)
            {
                return true;
            }
            else if (activeFilters.Contains("Next 5 Days")
                && (task.date.Date <= System.DateTime.Today.AddDays(5))
                && task.date.Date >= System.DateTime.Today)
            {
                return true;
            }
            else if (activeFilters.Contains("Current Month") && task.date.Month == System.DateTime.Today.Month)
            {
                return true;
            }

            else if (activeFilters.Contains("Current Week"))
            {
                int offset = GetDayOfTheWeekOffset();
                if (task.date.Date >= System.DateTime.Today.AddDays(-offset).Date
                    && task.date.Date <= System.DateTime.Today.AddDays(6 - offset).Date)
                {
                    return true;
                }
            }
            else if (activeFilters.Contains("Next Week"))
            {
                int offset = GetDayOfTheWeekOffset();
                if (task.date.Date >= System.DateTime.Today.AddDays(-offset + 7).Date
                    && task.date.Date <= System.DateTime.Today.AddDays(6 - offset + 7).Date)
                {
                    return true;
                }
            }
            else if (activeFilters.Contains("Completed") && task.completed)
            {
                if (activeFilters.Count == 1)
                {
                    return true;
                }
                else
                {
                    return true;
                }
            }
            else if (activeFilters.Contains("Not Completed") && !task.completed)
            {
                return true;
            }
            else if (activeFilters.Contains("Over Due") && !task.completed && task.date.Date < System.DateTime.Today.Date)
            {
                return true;
            }

            return false;
        }
예제 #5
0
        /// <summary>
        /// Inserts the task the task into the task list in order of date.
        /// </summary>
        /// <param name="task">The task.</param>
        public void InsertTask(Task task)
        {
            int i = 0;
            while (i < taskList.Count)
            {
                if (task.date.Ticks < taskList[i].date.Ticks)
                {
                    taskList.Insert(i, task);
                    return;
                }

                i += 1;
            }
            this.AddTask(task);
        }
예제 #6
0
 /// <summary>
 /// Determines whether the task list [contains] [the specified task].
 /// </summary>
 /// <param name="task">The task.</param>
 /// <returns>
 ///   <c>true</c> if the task list [contains] [the specified task]; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(Task task)
 {
     foreach (Task otherTask in taskList)
     {
         if (otherTask.date.ToShortDateString() == task.date.ToShortDateString()
             && otherTask.tag == task.tag
             && otherTask.task == task.task)
         {
             return true;
         }
     }
     return false;
 }
예제 #7
0
파일: Task.cs 프로젝트: ajrod/Task-Manager
        /// <summary>
        /// Sets the list item visuals for the specified task.
        /// </summary>
        /// <param name="item">The list item.</param>
        /// <param name="task">The task.</param>
        public static void SetItemVisuals(ListViewItem item, Task task)
        {
            if (task.completed)
            {
                item.ToolTipText = "This task has finished.";
                item.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Strikeout, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }
            else
            {
                item.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
                item.ToolTipText = "";
            }

            if (task.date.Date < System.DateTime.Today.Date)
            {
                //list.Items[i].BackColor = ProfessionalColors.SeparatorDark;
                if (task.completed)
                {
                    item.BackColor = System.Drawing.Color.LightGray;
                    item.ToolTipText = "This task has finished and deadline passed.";
                }
                else
                {
                    item.ToolTipText = "This task is over due. If this task is actually completed check completed off in the settings box.";
                    item.BackColor = System.Drawing.Color.Red;
                }
            }
            else if (task.date.Date == System.DateTime.Today.Date)
            {
                if (task.completed)
                {
                    item.BackColor = System.Drawing.Color.LimeGreen;
                    item.ToolTipText = "This task is finished and the deadline is today.";
                }
                else
                {
                    item.ToolTipText = "This task is still not completed and the deadline is today.";
                    item.BackColor = System.Drawing.Color.Orange;
                }
            }
            else if (task.date.Date == System.DateTime.Today.AddDays(1).Date)
            {
                if (task.completed)
                {
                    item.BackColor = System.Drawing.Color.LimeGreen;
                    item.ToolTipText = "This task is finished and the deadline is tommorow.";
                }
                else
                {
                    item.ToolTipText = "This task is still not completed and the deadline is tommorow.";
                    item.BackColor = System.Drawing.Color.LightGoldenrodYellow;
                }
            }
            else
            {
                if (task.completed)
                {
                    item.BackColor = System.Drawing.Color.LightGreen;
                    int daysToSpare = (task.date.Date - System.DateTime.Today.Date).Days;
                    if (daysToSpare == 1)
                    {
                        item.ToolTipText = "This task has finished with " + daysToSpare.ToString() + " day to the deadline.";
                    }
                    else
                    {
                        item.ToolTipText = "This task has finished with " + daysToSpare.ToString() + " days to the deadline.";
                    }
                }
                else
                {
                    item.BackColor = System.Drawing.Color.White;
                    int daysToSpare = (task.date.Date - System.DateTime.Today.Date).Days;
                    if (daysToSpare == 1)
                    {
                        item.ToolTipText = "This task is incomplete with " + daysToSpare.ToString() + " day to the deadline.";
                    }
                    else
                    {
                        item.ToolTipText = "This task is incomplete with " + daysToSpare.ToString() + " days to the deadline.";
                    }
                }
            }
        }
예제 #8
0
 /// <summary>
 /// Handles the Click event of the SaveEditButton control. Updates the task selected with the new information gathered.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void SaveEditButton_Click(object sender, System.EventArgs e)
 {
     MainForm.idle = false;
     MainForm.TaskData.DeleteSelectedTasks(MainForm.ViewableTasks, MainForm.FilterList, MainForm.filters);
     Task task = new Task(this.editDateTimePicker.Value, this.editTagBox.Text, this.editTaskBox.Text);
     task.reminder = editableTask.reminder;
     task.notes = editableTask.notes;
     task.completed = editableTask.completed;
     task.daysOfReminder = editableTask.daysOfReminder;
     task.reminderEmail = editableTask.reminderEmail;
     MainForm.TaskData.InsertTask(task);
     MainForm.TaskData.UpdateTaskList(MainForm.ViewableTasks, MainForm.FilterList);
     MainForm.SetSelectedIndexOfTask(task);
     MainForm.TaskData.Save();
     this.Close();
 }