Пример #1
0
        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));
        }
Пример #2
0
        // 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;
        }