WinRTXamlToolkit.Controls.Calendar.UnHighlightDays C# (CSharp) Method

UnHighlightDays() private method

This method un-highlights the days that were hovered over but not added to the SelectedDates collection or un-highlighted the previously selected days in SingleRange Mode.
private UnHighlightDays ( ) : void
return void
        internal void UnHighlightDays()
        {
            if (HoverEnd != null && HoverStart != null)
            {
                CalendarItem monthControl = MonthControl;
                CalendarDayButton b;
                DateTime? d;

                if (HoverEndIndex != null && HoverStartIndex != null)
                {
                    int startIndex, endIndex, i;
                    SortHoverIndexes(out startIndex, out endIndex);

                    if (SelectionMode == CalendarSelectionMode.MultipleRange)
                    {
                        for (i = startIndex; i <= endIndex; i++)
                        {
                            b = monthControl.MonthView.Children[i] as CalendarDayButton;
                            d = b.DataContext as DateTime?;

                            if (d.HasValue)
                            {
                                if (!SelectedDates.Contains(d.Value))
                                {
                                    b.IsSelected = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        // It is SingleRange
                        for (i = startIndex; i <= endIndex; i++)
                        {
                            (monthControl.MonthView.Children[i] as CalendarDayButton).IsSelected = false;
                        }
                    }
                }
            }
        }