public void TimerFired(ICalendarView calendar) { CalendarData data; if (calendar.Mode == CalendarMode.Month && _DateMonth.Month == _InitialDate.Month) data = new CalendarData( _InitialDate.AddMonths(1), CalendarMode.Month); else if (calendar.Mode == CalendarMode.Month) data = new CalendarData( _InitialDate, CalendarMode.Day); else if (calendar.Mode == CalendarMode.Day && _DateMonth == _InitialDate) data = new CalendarData( _InitialDate.AddDays(1), CalendarMode.Day); else data = new CalendarData( _InitialDate, CalendarMode.Month); Refresh(calendar, data); }
private void Refresh(ICalendarView cal, CalendarData data) { _DateMonth = data.date; cal.Mode = data.mode; var firstDay = new DateTime(_DateMonth.Year, _DateMonth.Month, 1); cal.Clear(); if (data.mode == CalendarMode.Month) { var firstDayOfWeek = LastSunday(firstDay); for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { cal.SetDate(i, j, new DayInfo { date = firstDayOfWeek.AddDays(i * 7 + j) }); } } cal.SetTitle(firstDay.ToString("MMMM yyyy")); } else if (_DateMonth == _InitialDate) { cal.SetTitle("Today's Agenda"); } else { cal.SetTitle("Tomorrow's Agenda"); } RefreshFeed(cal, data); }
public void RefreshFeed(ICalendarView calendar, CalendarData data) { EventFeed calFeed; if (data.mode == CalendarMode.Month) calFeed = _Service.QueryData( _DateMonth.AddDays(-28), _DateMonth.AddMonths(1)); else calFeed = _Service.QueryData(data.date, data.date.AddDays(1)); if (calFeed == null || calFeed.Entries.Count == 0) calendar.AddAgendaItem(_DateMonth, "No agenda items", true); // now populate the calendar while (calFeed != null && calFeed.Entries.Count > 0) { var items = calFeed.Entries.Cast<EventEntry>() .SelectMany(entry => entry.Times, (e, t) => new { e.Title.Text, t.StartTime, t.AllDay }) .OrderBy(w => w.StartTime); foreach (var item in items) { if (data.mode == CalendarMode.Month) calendar.AddEvent(item.StartTime, item.Text, item.AllDay); else calendar.AddAgendaItem(item.StartTime, item.Text, item.AllDay); } calFeed = _Service.Next(calFeed); } calendar.StartTimer(); }