Exemplo n.º 1
0
        /// <summary>
        /// Higlights the days.
        /// </summary>
        private void HiglightDays()
        {
            this.NormalizeDisplayDate();
            this._nextOccurences = ScheduleUtility.GetNextOccurrences(this.Schedule, this.DayCalendar.DisplayDate.AddMinutes(-1), this.DayCalendar.DisplayDate.LastDayOfMonth().AddDays(1)).ToList();

            DateTime?selectedDate = this.DayCalendar.SelectedDate ?? DateTime.Today;

            this.DayCalendar.SelectedDates.Clear();
            this.DayCalendar.BlackoutDates.Clear();
            int firstDay      = this.DayCalendar.DisplayDate.Day;
            var allDays       = Enumerable.Range(firstDay, this.DayCalendar.DisplayDate.LastDayOfMonth().Day - firstDay + 1);
            var occurenceDays = this._nextOccurences.Select(o => o.Day).Distinct();
            var blockedDays   = allDays.Except(occurenceDays);

            foreach (int day in blockedDays)
            {
                CalendarDateRange blockedRange = new CalendarDateRange(this.DayCalendar.DisplayDate.AddDays(day - firstDay));
                this.DayCalendar.BlackoutDates.Add(blockedRange);
            }

            // reselect date if we can (will kick of date selection)
            if (selectedDate.HasValue && !this.DayCalendar.BlackoutDates.Contains(selectedDate.Value))
            {
                this.DayCalendar.SelectedDate = selectedDate;
            }
        }