private List <Calendar.Appointment> GetMatchingAppointments(DateTime start, DateTime end, bool sorted = false) { // Future items are always populated on demand m_FutureItems = new Dictionary <uint, CalendarFutureItem>(); var appts = new List <Calendar.Appointment>(); UInt32 nextFutureId = (((m_MaxTaskID / 1000) + 1) * 1000); foreach (System.Collections.Generic.KeyValuePair <UInt32, CalendarItem> pair in m_Items) { CalendarItem item = pair.Value; if (!IsItemDisplayable(item)) { continue; } if (IsItemWithinRange(item, start, end)) { appts.Add(item); } if (m_ShowFutureOcurrences && item.IsRecurring) { // Add this task's future items for the current date range // Note: we deliberately double the range else we lose // future items which overlap the the current item var futureItems = m_TaskRecurrences.Get(item.Id, StartDate, EndDate.AddDays(DaysShowing)); if (futureItems != null) { foreach (var futureItem in futureItems) { var futureAppt = new CalendarFutureItem(item, nextFutureId, futureItem); if (IsItemWithinRange(futureAppt, start, end)) { m_FutureItems[nextFutureId++] = futureAppt; appts.Add(futureAppt); } } } } } if (sorted) { appts.Sort((a, b) => (int)(b.StartDate.Ticks - a.StartDate.Ticks)); } return(appts); }
private List <Calendar.Appointment> GetMatchingAppointments(DateTime start, DateTime end, bool sorted = false) { // Future items are always populated on demand m_FutureItems = new Dictionary <uint, CalendarFutureItem>(); var appts = new List <Calendar.Appointment>(); UInt32 nextFutureId = (((m_MaxTaskID / 1000) + 1) * 1000); foreach (System.Collections.Generic.KeyValuePair <UInt32, CalendarItem> pair in m_Items) { CalendarItem item = pair.Value; if (IsItemWithinRange(item, start, end)) { appts.Add(item); } if (item.IsRecurring) { // Add this task's future items for the current date range var futureItems = m_TaskRecurrences.Get(item.Id, StartDate, EndDate); if (futureItems != null) { foreach (var futureItem in futureItems) { var futureAppt = new CalendarFutureItem(item, nextFutureId, futureItem); m_FutureItems[nextFutureId] = futureAppt; appts.Add(futureAppt); nextFutureId++; } } } } if (sorted) { appts.Sort((a, b) => (int)(a.StartDate.Ticks - b.StartDate.Ticks)); } return(appts); }