public static async Task <List <Appointment> > GetNextAppointments() { var howManyDays = 2; if (IsolatedStorageSettings.ApplicationSettings.Contains("TileDaysInFuture")) { howManyDays = (int)IsolatedStorageSettings.ApplicationSettings["TileDaysInFuture"]; } var nextAppointments = new List <Appointment>(); var appts = (await CalendarAPI.GetAppointments(DateTime.Now.Date, howManyDays)).ToList <Appointment>(); // Options: Sortiere Termine aus, die von hidden Kalender sind. if (IsolatedStorageSettings.ApplicationSettings.Contains("HiddenCalendars")) { var hiddenCalendars = (List <string>)IsolatedStorageSettings.ApplicationSettings["HiddenCalendars"]; foreach (var id in hiddenCalendars) { appts.RemoveAll(x => x.CalendarId == id); } } // der nächste Termin, der nicht AllDay ist: foreach (var appt in appts) { if (appt.AllDay) { continue; } if (appt.StartTime >= DateTime.Now) { nextAppointments.Add(appt); break; } } foreach (var appt in appts) { if (nextAppointments.Count == 0 || appt != nextAppointments[0]) { if (appt.StartTime >= DateTime.Now) { nextAppointments.Add(appt); } else if (appt.AllDay) { nextAppointments.Add(appt); } } } return(nextAppointments); }
public async void SearchAndLoadCache() { DateTime startDate = App.ViewModel.LastCachedDate; ViewSwitcher.Mainpage.TheSearchControl.SearchLoadingIndicator.Text = "Loading . . ."; App.ViewModel.CachedAppointmentsForSearch = await CalendarAPI.GetAppointments(startDate, 30); DoSearch(); App.ViewModel.CachedAppointmentsForSearch = await CalendarAPI.GetAppointments(startDate, 365); DoSearch(); ViewSwitcher.Mainpage.TheSearchControl.SearchLoadingIndicator.Text = ("Loaded: " + startDate.ToShortDateString() + " - " + startDate.AddDays(365).ToShortDateString()); }
public async void LoadAppointmentLinesAsync() { var listOfAppointments = await CalendarAPI.GetAppointments(_gridDateTimes.FirstOrDefault(), _gridDateTimes.Count); foreach (var item in MonthViewGrid.Children) { var brd = item as Border; if (brd == null) { continue; } var dtOfBrd = (DateTime)brd.DataContext; var appointmentsOfThisDay = listOfAppointments.Where(x => TimeFrameChecker.IsInTimeFrameOfDay(x, dtOfBrd)); addAppointmentLines(appointmentsOfThisDay, brd); } }
private async Task getPocalAppointments(int howManyDays, DateTime startDay) { _appoinmentBuffer = await CalendarAPI.GetAppointments(startDay, howManyDays); await convertAppointmentBuffer(); }