public void LoadCards(IEnumerable<Appointment> appointments) { // for each event returned, if the title contains VisualCalendar, then foreach (Appointment item in appointments) { //BUG: not sure why we're getting these null items? if (item.Subject == null) continue; Card newCard = new Card(item.Subject); if (item.EndTime < DateTime.Now) { this.prevCard = newCard; //this can't be current but it might be the most recent } else if (item.StartTime < DateTime.Now && item.EndTime > DateTime.Now && this.currentCard == null) { this.currentCard = newCard; // if there are multiple now, we took the first one } else if (item.StartTime > DateTime.Now && this.nextCard == null) { this.nextCard = newCard; // this is the first 'not yet' event we've seen if (this.currentCard == null) //nothing was scheduled now { this.currentCard = new Card("free time"); //show 'free time' if there is no event right now' this.Add(this.currentCard); } } } }
// on load, we searched the calendar for all of today's events. Now we got them as an enumerator void appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e) { if ((e.Results == null) || (e.Results.Count() == 0)) { // error, OR no events for the day // display a single question mark tile this.currentCard = new Card("free time"); } else { this.LoadCards(e.Results); } //fill in prev/current/next as unscheduled if there is nothing available for any of them if (prevCard == null) prevCard = new Card("free time"); currentCards.Add(prevCard); if (currentCard == null) currentCard = new Card("free time"); currentCard.height = 280; currentCard.width = 280; currentCards.Add(currentCard); if (nextCard == null) nextCard = new Card("free time"); currentCards.Add(nextCard); IsDataLoaded = true; }
public void Add(Card card) { cards.Add(card); }