private void ProcessSelection(bool shift, DateTime? lastSelectedDate, int? index)
{
if (SelectionMode == CalendarSelectionMode.None && lastSelectedDate != null)
{
OnDayClick(lastSelectedDate.Value);
return;
}
if (lastSelectedDate != null && IsValidKeyboardSelection(this, lastSelectedDate.Value))
{
if (SelectionMode == CalendarSelectionMode.SingleRange || SelectionMode == CalendarSelectionMode.MultipleRange)
{
foreach (DateTime item in SelectedDates)
{
RemovedItems.Add(item);
}
SelectedDates.ClearInternal();
if (shift)
{
CalendarDayButton b;
_isShiftPressed = true;
if (HoverStart == null)
{
if (LastSelectedDate != null)
{
HoverStart = LastSelectedDate;
}
else
{
if (DateTimeHelper.CompareYearMonth(DisplayDateInternal, DateTime.Today) == 0)
{
HoverStart = DateTime.Today;
}
else
{
HoverStart = DisplayDateInternal;
}
}
b = FindDayButtonFromDay(HoverStart.Value);
if (b != null)
{
HoverStartIndex = b.Index;
}
}
// the index of the SelectedDate is always the last
// selectedDate's index
UnHighlightDays();
// If we hit a BlackOutDay with keyboard we do not
// update the HoverEnd
CalendarDateRange range;
if (DateTime.Compare(HoverStart.Value, lastSelectedDate.Value) < 0)
{
range = new CalendarDateRange(HoverStart.Value, lastSelectedDate.Value);
}
else
{
range = new CalendarDateRange(lastSelectedDate.Value, HoverStart.Value);
}
if (!BlackoutDates.ContainsAny(range))
{
HoverEnd = lastSelectedDate;
if (index.HasValue)
{
HoverEndIndex += index;
}
else
{
// For Home, End, PageUp and PageDown Keys there
// is no easy way to predict the index value
b = FindDayButtonFromDay(HoverEndInternal.Value);
if (b != null)
{
HoverEndIndex = b.Index;
}
}
}
OnDayClick(HoverEnd.Value);
HighlightDays();
}
else
{
HoverStart = lastSelectedDate;
HoverEnd = lastSelectedDate;
AddSelection();
OnDayClick(lastSelectedDate.Value);
}
}
else
{
// ON CLEAR
LastSelectedDate = lastSelectedDate.Value;
if (SelectedDates.Count > 0)
{
SelectedDates[0] = lastSelectedDate.Value;
}
else
{
SelectedDates.Add(lastSelectedDate.Value);
}
OnDayClick(lastSelectedDate.Value);
}
}
}