private void OK_Click(object sender, RoutedEventArgs e) { StartTime = this.startTimePicker.SelectedItem as CustomTimeSpan; DueTime = this.dueTimePicker.SelectedItem as CustomTimeSpan; StartDate = this.startDatePicker.SelectedDate.Value; DueDate = this.dueDatePicker.SelectedDate.Value; this.DialogResult = true; }
public void Flag(Element element, bool hasStart, DateTime startDate, CustomTimeSpan startTime, bool isStartAllDay, bool hasDue, DateTime dueDate, CustomTimeSpan dueTime, bool isDueAllDay, bool addToToday, bool addToReminder, bool addToTask) { Outlook.Application outlook_app = new Microsoft.Office.Interop.Outlook.Application(); Outlook.AppointmentItem app_item; Outlook.TaskItem task_item; if (hasStart || hasDue) { app_item = outlook_app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem) as Microsoft.Office.Interop.Outlook.AppointmentItem; if (isStartAllDay) { app_item.Start = startDate; app_item.AllDayEvent = true; element.StartDate = startDate; element.DueDate = startDate.AddDays(1); } else { if (startTime.IsAM == false) { startTime.Hour += 12; } string startDateTime = startDate.Month.ToString() + "/" + startDate.Day.ToString() + "/" + startDate.Year.ToString() + " " + startTime.Hour.ToString() + ":" + startTime.Minutes.ToString() + ":00"; if (dueTime.IsAM == false) { dueTime.Hour += 12; } string dueDateTime = dueDate.Month.ToString() + "/" + dueDate.Day.ToString() + "/" + dueDate.Year.ToString() + " " + dueTime.Hour.ToString() + ":" + dueTime.Minutes.ToString() + ":00"; app_item.Start = System.DateTime.Parse(startDateTime); app_item.End = System.DateTime.Parse(dueDateTime); app_item.AllDayEvent = false; element.StartDate = startDate; element.DueDate = dueDate; } if (addToReminder) { app_item.Body = "Start date for " + element.NoteText + @" <file:\\" + element.Path + ">"; app_item.Subject = element.NoteText; app_item.ReminderMinutesBeforeStart = 0; app_item.Save(); app_item = null; } } if (addToTask) { task_item = outlook_app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olTaskItem) as Microsoft.Office.Interop.Outlook.TaskItem; task_item.Subject = element.NoteText; task_item.Body = "Task for " + element.NoteText + " " + element.Path; if (hasStart) { task_item.StartDate = startDate; } if (hasDue) { task_item.DueDate = dueDate; } task_item.ReminderSet = false; task_item.Save(); task_item = null; } if (addToToday) { Element today = GetTodayElement(); if (today != null) { Element newElement = CreateNewElement(ElementType.Note, element.NoteText); InsertElement(newElement, today, 0); AddAssociation(newElement, element.Path, ElementAssociationType.FolderShortcut, null); Promote(newElement); Flag(newElement); /*if (hasStart) { if (isStartAllDay) { } else { newElement.NoteText += " Start: " + startDate.Month.ToString() + "/" + startDate.Day.ToString() + "/" + startDate.Year.ToString() + " " + startTime.Hour.ToString() + ":" + startTime.Minutes.ToString(); } } if (hasDue) { if (isDueAllDay) { } else { newElement.NoteText += " Due: " + dueDate.Month.ToString() + "/" + dueDate.Day.ToString() + "/" + dueDate.Year.ToString() + " " + dueTime.Hour.ToString() + ":" + dueTime.Minutes.ToString(); } }*/ } } Flag(element); }