private void snooze(string snoozeTime, bool record = true) { SnoozeTime st; DateTime wakeup; try { st = SnoozeTime.Parse(snoozeTime); wakeup = st.GetNextReminderTime(meeting.StartTime); if (wakeup < DateTime.Now) { throw new Exception("Reminder time is in the past"); } } catch (Exception e) { MessageBox.Show(this, "Cannot follow snooze instruction '" + snoozeTime + "': " + e.Message, "Invalid Snooze", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } logger.Info("Snooze time " + st + " -> reminder time is: " + wakeup); // record the snoozeTime MRU var list = SnoozeTime.ParseList(Properties.Settings.Default.mruSnoozeTimes); list.Remove(st); list.Insert(0, st); while (list.Count > 5) { list.RemoveAt(list.Count - 1); } Properties.Settings.Default.mruSnoozeTimes = SnoozeTime.ListToString(list); Properties.Settings.Default.Save(); meeting.NextReminderTime = wakeup; Close(); }
public ReminderForm(UpcomingMeeting meeting) { this.meeting = meeting; this.joinUrl = meeting.GetMeetingUrl(); InitializeComponent(); // populate the combo with a hardcoded list of items whose primary purpose is to illustrate the // syntax of all possible values timeCombo.Items.Add(new SnoozeTime(20, false)); timeCombo.Items.Add(new SnoozeTime(-20, false)); timeCombo.Items.Add(new SnoozeTime(30, true)); timeCombo.Items.Add(new SnoozeTime(60, true)); // set labels for this meeting nameLabel.Text = meeting.Subject; extraInfoLabel.Text = ""; if (meeting.Location.Length > 0) { extraInfoLabel.Text = "Location: " + meeting.Location + "; "; } extraInfoLabel.Text += "Duration " + meeting.OutlookItem.Duration + " mins"; if (meeting.getOrganizer() != null) { extraInfoLabel.Text += "; organizer: " + meeting.getOrganizer(); } IEnumerable <string> attendees = meeting.GetAttendees(); if (attendees.Count() == 1) { extraInfoLabel.Text += "; with: " + string.Join(", ", attendees); } else { extraInfoLabel.Text += "; " + attendees.Count() + " attendees"; } extraInfoLabel.Text += ""; toolTip.SetToolTip(nameLabel, nameLabel.Text); // in case it's too long toolTip.SetToolTip(extraInfoLabel, meeting.Body); joinButton.Visible = joinUrl.Length > 0; // start time timer timer.Enabled = true; updateStartTime(); // reminder times list. stored in MRU order but sorted in time order timeList.Items.Clear(); var list = SnoozeTime.ParseList(Properties.Settings.Default.mruSnoozeTimes); if (list.Count == 0) { // initialize default list of snooze times list.Add(new SnoozeTime(-2 * 60, false)); list.Add(new SnoozeTime(-30, false)); list.Add(new SnoozeTime(30, true)); list.Add(new SnoozeTime(60, true)); list.Add(new SnoozeTime(60 * 5, true)); Properties.Settings.Default.mruSnoozeTimes = SnoozeTime.ListToString(list); Properties.Settings.Default.Save(); } list.Sort(); list.ForEach(st => timeList.Items.Add(st)); // by default, dismiss when dialog is closed. unless snooze is selected meeting.Dismiss(); reactivateTime = DateTime.Now + reactivateTimeSpan; }