public virtual void MouseMove(Control c, Point pt)
{
if (_mouseOver)
{
if (_captured)
{
if (_selectionStart != DateTime.MinValue)
{
// Find the button (day entry) closest (date wise) to the point provided.
// So if over a blank area or over a disabled day it gives the date that
// would be appropriate to use as the end selection date.
DateTime selectEnd = _months.DayNearPoint(pt);
// Enforce the maximum number of days
DateTime selectStart = _selectionStart;
TimeSpan span = new TimeSpan(_months.Calendar.MaxSelectionCount - 1, 0, 0, 0);
if (selectEnd > selectStart)
{
if ((selectEnd - selectStart) > span)
selectEnd = selectStart + span;
_months.FocusDay = selectEnd;
}
else if (selectEnd < selectStart)
{
if ((selectStart - selectEnd) > span)
selectEnd = selectStart - span;
// Switch around so the begin is before the end
DateTime temp = selectEnd;
selectEnd = selectStart;
selectStart = temp;
_months.FocusDay = selectStart;
}
// Use the new seletion range
_months.Calendar.SetSelectionRange(selectStart, selectEnd);
_needPaint(_months, new NeedLayoutEventArgs(false));
}
}
else
{
// Find the button (day entry) under the new mouse position
_months.TrackingDay = _months.DayFromPoint(pt, true);
}
}
}