private void RestoreSelection(int scrollChange)
{
if (SelectionChange.IsActive || SelectedDates.Count == 0)
{
return;
}
SelectionChange.Begin();
bool succeeded = false;
try
{
//Restore the selected dates that are within Max/MinDate, First/LastVisibleDate
//And unselect the dates that exceeds the range
foreach (DateTime dt in SelectedDates)
{
if (MonthCalendarHelper.IsWithinRange(dt, FirstVisibleDate, LastVisibleDate)
&& MonthCalendarHelper.IsWithinRange(dt, MinDate, MaxDate))
{
SelectionChange.RestoreSelect(dt);
}
else
{
SelectionChange.Unselect(dt);
}
}
SelectionChange.End(true, true);
succeeded = true;
}
finally
{
if (!succeeded)
{
SelectionChange.Cancel();
}
}
}