public DayFromPoint ( Point pt, bool exact ) : DateTime? | ||
pt | Point | Point to lookup. |
exact | bool | Exact requires that the day must be with the month range. |
Результат | DateTime? |
public DateTime? DayFromPoint(Point pt, bool exact)
{
// Search the list of days for the one containing the requested point
for (int i = 0; i < DAYS; i++)
if ((_dayMementos[i] != null) && (_dayRects[i].Contains(pt)))
{
DateTime day = _firstDay.AddDays(i);
if (!exact || ((day >= _month) && (day <= _lastDay)))
return day;
}
return null;
}
/// <summary> /// Gets the button for the day that is under the provided point. /// </summary> /// <param name="pt">Point to lookup.</param> /// <param name="exact">Exact requires that the day must be with the month range.</param> /// <returns>DateTime for matching day; otherwise null.</returns> public DateTime?DayFromPoint(Point pt, bool exact) { // Get the bottom most view element matching the point ViewBase view = ViewFromPoint(pt); // Climb view hierarchy looking for the days view while (view != null) { ViewDrawMonthDays month = view as ViewDrawMonthDays; if ((month != null) && month.ClientRectangle.Contains(pt)) { return(month.DayFromPoint(pt, exact)); } view = view.Parent; } return(null); }