private void ButtonNext_Click(object sender, EventArgs e) { // get the view mode from the current ViewXML, this will tell us what calendar view we're in var mode = GetCurrentCalendarViewMode(); SetCurrentViewControlAsActiveIfNecessary(mode, ButtonNext, ref Startup.LastNextButtonClicked); var offset = GetNextPreviousOffsetBasedOnCalendarViewMode(mode); OutlookViewControl.GoToDate(OutlookViewControl.SelectedDate.AddDays(offset).ToString(CultureInfo.InvariantCulture)); }
private void UpdateTimer_Tick(object sender, EventArgs e) { // increment day in outlook's calendar if we've crossed over into a new day if (DateTime.Now.Day != _previousDate.Day) { try { OutlookViewControl.GoToToday(); } catch (Exception ex) { // no big deal if we can't set the day, just ignore and go on. Logger.Warn(ex, "Unable to go to today on calendar."); } } _previousDate = DateTime.Now; }
// Terrible hack to get around a bug in the Outlook View Control where if you have more than one // calendar view active, GoToDate will not work on the instance it's called on, instead it will // work on the last "active" view of the calendar, which may or may not be the current one. // So to get around that, if the last clicked next button was not this one, we reset the // calendar view to make it active, before using GoToDate. private void SetCurrentViewControlAsActiveIfNecessary(CurrentCalendarView mode, Button button, ref Guid lastButtonGuidClicked) { // we don't need to do this if we only have one instance, so bail right away. if (InstanceManager.InstanceCount == 1) { return; } // we can bail if we know the last button clicked was the one on this form. if ((Guid)button.Tag == lastButtonGuidClicked) { return; } var currentDate = OutlookViewControl.SelectedDate; switch (mode) { case CurrentCalendarView.Day: SetViewXml(Resources.DayXML); break; case CurrentCalendarView.Week: SetViewXml(Resources.WeekXML); break; case CurrentCalendarView.WorkWeek: SetViewXml(Resources.WorkWeekXML); break; case CurrentCalendarView.Month: SetViewXml(Resources.MonthXML); break; default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } OutlookViewControl.GoToDate(currentDate.ToString(CultureInfo.InvariantCulture)); lastButtonGuidClicked = (Guid)button.Tag; }
private void NewEmailButton_Click(object sender, EventArgs e) { OutlookViewControl.NewMessage(); }
private void TodayButton_Click(object sender, EventArgs e) { OutlookViewControl.GoToToday(); }