/// <summary> /// Determines if the specified <paramref name="year"/> is a valid year value. /// </summary> /// <param name="year">The year value.</param> /// <param name="cal">The calendar to use.</param> /// <param name="era">The era the year belongs to.</param> /// <returns>true if it's a valid year value; false otherwise.</returns> private static bool IsValidYear(int year, Calendar cal, int era) { int minYear = cal.GetYear(cal.MinSupportedDateTime.Date); int maxYear = cal.GetYear(cal.MaxSupportedDateTime.Date); if (cal.Eras.Length > 1) { DateTime? minDate = null, maxDate = null; DateTime date = cal.MinSupportedDateTime; while (date < cal.MaxSupportedDateTime.Date) { int e = cal.GetEra(date); if (e == era) { if (minDate == null) { minDate = date; } maxDate = date; } date = cal.AddDays(date, 1); } minYear = cal.GetYear(minDate.GetValueOrDefault(cal.MinSupportedDateTime.Date)); maxYear = cal.GetYear(maxDate.GetValueOrDefault(cal.MaxSupportedDateTime.Date)); } year = cal.ToFourDigitYear(year); return year >= minYear && year <= maxYear; }
private void DayListEventHandler(Object source, ListCommandEventArgs e) { _threadCalendar = DateTimeFormatInfo.CurrentInfo.Calendar; // VisibleDate should have been set with the first day of the week // so the selected index can be used to adjust to the selected day. Control.VisibleDate = _threadCalendar.AddDays(Control.VisibleDate, e.ListItem.Index); SelectRange(Control.VisibleDate, Control.VisibleDate); HandlePostBackEvent(Done.ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// Builds an array of <see cref="MonthCalendarEraRange"/> to store the min and max date of the eras of the specified /// <see cref="System.Globalization.Calendar"/>. /// </summary> /// <param name="cal"> /// The <see cref="System.Globalization.Calendar"/> to retrieve the era ranges for. /// </param> /// <returns> /// An array of type <see cref="MonthCalendarEraRange"/>. /// </returns> private static MonthCalendarEraRange[] GetEraRanges(Calendar cal) { if (cal.Eras.Length == 1) { return new[] { new MonthCalendarEraRange(cal.Eras[0], cal.MinSupportedDateTime.Date, cal.MaxSupportedDateTime.Date) }; } List<MonthCalendarEraRange> ranges = new List<MonthCalendarEraRange>(); DateTime date = cal.MinSupportedDateTime.Date; int currentEra = -1; while (date < cal.MaxSupportedDateTime.Date) { int era = cal.GetEra(date); if (era != currentEra) { ranges.Add(new MonthCalendarEraRange(era, date)); if (currentEra != -1) { ranges[ranges.Count - 2].MaxDate = cal.AddDays(date, -1); } currentEra = era; } date = cal.AddDays(date, 1); } ranges[ranges.Count - 1].MaxDate = date; return ranges.ToArray(); }
private void MonthListEventHandler(Object source, ListCommandEventArgs e) { _threadCalendar = DateTimeFormatInfo.CurrentInfo.Calendar; if (e.ListItem.Index == _monthsToDisplay) { // Next was selected Control.VisibleDate = _threadCalendar.AddMonths( Control.VisibleDate, _monthsToDisplay); SecondaryUIMode = ChooseMonth; } else if (e.ListItem.Index == _monthsToDisplay + 1) { // Prev was selected Control.VisibleDate = _threadCalendar.AddMonths( Control.VisibleDate, -_monthsToDisplay); SecondaryUIMode = ChooseMonth; } else { // A month was selected Control.VisibleDate = _threadCalendar.AddMonths( Control.VisibleDate, e.ListItem.Index); if (_chooseOption == MonthOption) { // Add the whole month to the date list DateTime beginDate = EffectiveVisibleDate(Control.VisibleDate); Control.VisibleDate = beginDate; DateTime endDate = _threadCalendar.AddMonths(beginDate, 1); endDate = _threadCalendar.AddDays(endDate, -1); SelectRange(beginDate, endDate); HandlePostBackEvent(Done.ToString(CultureInfo.InvariantCulture)); } else { SecondaryUIMode = ChooseWeek; } } }
private void WeekListEventHandler(Object source, ListCommandEventArgs e) { // Get the first calendar day and adjust it to the week the user // selected (to be consistent with the index setting in Render()) _threadCalendar = DateTimeFormatInfo.CurrentInfo.Calendar; DateTime tempDate = FirstCalendarDay(Control.VisibleDate); Control.VisibleDate = _threadCalendar.AddDays(tempDate, e.ListItem.Index * 7); if (_chooseOption == WeekOption) { // Add the whole week to the date list DateTime endDate = _threadCalendar.AddDays(Control.VisibleDate, 6); SelectRange(Control.VisibleDate, endDate); HandlePostBackEvent(Done.ToString(CultureInfo.InvariantCulture)); } else { SecondaryUIMode = ChooseDay; } }
private void SetCalendarDayButtons(DateTime firstDayOfMonth) { int lastMonthToDisplay = PreviousMonthDays(firstDayOfMonth); DateTime dateToAdd; if (DateTimeHelper.CompareYearMonth(firstDayOfMonth, DateTime.MinValue) > 0) { // DisplayDate is not equal to DateTime.MinValue we can subtract // days from the DisplayDate dateToAdd = _calendar.AddDays(firstDayOfMonth, -lastMonthToDisplay); } else { dateToAdd = firstDayOfMonth; } if (Owner != null && Owner.HoverEnd != null && Owner.HoverStart != null) { Owner.HoverEndIndex = null; Owner.HoverStartIndex = null; } int count = Calendar.RowsPerMonth * Calendar.ColumnsPerMonth; for (int childIndex = Calendar.ColumnsPerMonth; childIndex < count; childIndex++) { CalendarDayButton childButton = (CalendarDayButton)MonthView !.Children[childIndex]; childButton.Index = childIndex; SetButtonState(childButton, dateToAdd); // Update the indexes of hoverStart and hoverEnd if (Owner != null && Owner.HoverEnd != null && Owner.HoverStart != null) { if (DateTimeHelper.CompareDays(dateToAdd, Owner.HoverEnd.Value) == 0) { Owner.HoverEndIndex = childIndex; } if (DateTimeHelper.CompareDays(dateToAdd, Owner.HoverStart.Value) == 0) { Owner.HoverStartIndex = childIndex; } } //childButton.Focusable = false; childButton.Content = dateToAdd.Day.ToString(DateTimeHelper.GetCurrentDateFormat()); childButton.DataContext = dateToAdd; if (DateTime.Compare((DateTime)DateTimeHelper.DiscardTime(DateTime.MaxValue), dateToAdd) > 0) { // Since we are sure DisplayDate is not equal to // DateTime.MaxValue, it is safe to use AddDays dateToAdd = _calendar.AddDays(dateToAdd, 1); } else { // DisplayDate is equal to the DateTime.MaxValue, so there // are no trailing days childIndex++; for (int i = childIndex; i < count; i++) { childButton = (CalendarDayButton)MonthView.Children[i]; // button needs a content to occupy the necessary space // for the content presenter childButton.Content = i.ToString(DateTimeHelper.GetCurrentDateFormat()); childButton.IsEnabled = false; childButton.Opacity = 0; } return; } } // If the HoverStart or HoverEndInternal could not be found on the // DisplayMonth set the values of the HoverStartIndex or // HoverEndIndex to be the first or last day indexes on the current // month if (Owner != null && Owner.HoverStart.HasValue && Owner.HoverEndInternal.HasValue) { if (!Owner.HoverEndIndex.HasValue) { if (DateTimeHelper.CompareDays(Owner.HoverEndInternal.Value, Owner.HoverStart.Value) > 0) { Owner.HoverEndIndex = Calendar.ColumnsPerMonth * Calendar.RowsPerMonth - 1; } else { Owner.HoverEndIndex = Calendar.ColumnsPerMonth; } } if (!Owner.HoverStartIndex.HasValue) { if (DateTimeHelper.CompareDays(Owner.HoverEndInternal.Value, Owner.HoverStart.Value) > 0) { Owner.HoverStartIndex = Calendar.ColumnsPerMonth; } else { Owner.HoverStartIndex = Calendar.ColumnsPerMonth * Calendar.RowsPerMonth - 1; } } } }
/// <include file='doc\ChtmlCalendarAdapter.uex' path='docs/doc[@for="ChtmlCalendarAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { ArrayList arr; DateTime tempDate; DateTimeFormatInfo currentDateTimeInfo = DateTimeFormatInfo.CurrentInfo; String abbreviatedMonthDayPattern = AbbreviateMonthPattern(currentDateTimeInfo.MonthDayPattern); _threadCalendar = currentDateTimeInfo.Calendar; bool breakAfter = false; writer.EnterStyle(Style); Debug.Assert(NotSecondaryUI == NotSecondaryUIInit); switch (SecondaryUIMode) { case FirstPrompt: String promptText = Control.CalendarEntryText; if (String.IsNullOrEmpty(promptText)) { promptText = SR.GetString(SR.CalendarAdapterFirstPrompt); } // Link to input option selection screen RenderPostBackEventAsAnchor(writer, OptionPrompt.ToString(CultureInfo.InvariantCulture), promptText); // We should honor BreakAfter property here as the first // UI is shown with other controls on the same form. // For other secondary UI, it is not necessary. if (Control.BreakAfter) { breakAfter = true; } break; // Render the first secondary page that provides differnt // options to select a date. case OptionPrompt: writer.Write(SR.GetString(SR.CalendarAdapterOptionPrompt)); writer.WriteBreak(); arr = new ArrayList(); // Option to select the default date arr.Add(Control.VisibleDate.ToString( currentDateTimeInfo.ShortDatePattern, CultureInfo.CurrentCulture)); // Option to another page that can enter a date by typing arr.Add(SR.GetString(SR.CalendarAdapterOptionType)); // Options to a set of pages for selecting a date, a week // or a month by picking month/year, week and day // accordingly. Available options are determined by // SelectionMode. arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseDate)); if (Control.SelectionMode == CalendarSelectionMode.DayWeek || Control.SelectionMode == CalendarSelectionMode.DayWeekMonth) { arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseWeek)); if (Control.SelectionMode == CalendarSelectionMode.DayWeekMonth) { arr.Add(SR.GetString(SR.CalendarAdapterOptionChooseMonth)); } } DataBindAndRender(writer, _optionList, arr); break; // Render a title and textbox to capture a date entered by user case TypeDate: if (_textBoxErrorMessage != null) { writer.Write(_textBoxErrorMessage); writer.WriteBreak(); } if (_selectList.Visible) { writer.Write(SR.GetString(SR.CalendarAdapterOptionEra)); writer.WriteBreak(); _selectList.RenderControl(writer); } String numericDateFormat = GetNumericDateFormat(); writer.Write(SR.GetString(SR.CalendarAdapterOptionType)); writer.Write(":"); writer.WriteBreak(); writer.Write("("); writer.Write(numericDateFormat.ToUpper(CultureInfo.InvariantCulture)); writer.Write(")"); if (!_selectList.Visible) { writer.Write(GetEra(Control.VisibleDate)); } writer.WriteBreak(); _textBox.Numeric = true; _textBox.Size = numericDateFormat.Length; _textBox.MaxLength = numericDateFormat.Length; _textBox.Text = Control.VisibleDate.ToString(numericDateFormat, CultureInfo.InvariantCulture); _textBox.Visible = true; _textBox.RenderControl(writer); // Command button for sending the textbox value back to the server _command.Text = GetDefaultLabel(OKLabel); _command.Visible = true; _command.RenderControl(writer); break; // Render a paged list for choosing a month case ChooseMonth: writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseMonth)); writer.Write(":"); writer.WriteBreak(); tempDate = Control.VisibleDate; String abbreviatedYearMonthPattern = AbbreviateMonthPattern(currentDateTimeInfo.YearMonthPattern); // This is to be consistent with ASP.NET Calendar control // on handling YearMonthPattern: // Some cultures have a comma in their YearMonthPattern, // which does not look right in a calendar. Here we // strip the comma off. int indexComma = abbreviatedYearMonthPattern.IndexOf(','); if (indexComma >= 0) { abbreviatedYearMonthPattern = abbreviatedYearMonthPattern.Remove(indexComma, 1); } arr = new ArrayList(); for (int i = 0; i < _monthsToDisplay; i++) { arr.Add(tempDate.ToString(abbreviatedYearMonthPattern, CultureInfo.CurrentCulture)); tempDate = _threadCalendar.AddMonths(tempDate, 1); } arr.Add(GetDefaultLabel(NextLabel)); arr.Add(GetDefaultLabel(PreviousLabel)); DataBindAndRender(writer, _monthList, arr); break; // Based on the month selected in case ChooseMonth above, render a list of // availabe weeks of the month. case ChooseWeek: String monthFormat = (GetNumericDateFormat()[0] == 'y') ? "yyyy/M" : "M/yyyy"; writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseWeek)); writer.Write(" ("); writer.Write(Control.VisibleDate.ToString(monthFormat, CultureInfo.CurrentCulture)); writer.Write("):"); writer.WriteBreak(); // List weeks of days of the selected month. May include // days from the previous and the next month to fill out // all six week choices. This is consistent with the // ASP.NET Calendar control. // Note that the event handling code of this list control // should be implemented according to the index content // generated here. tempDate = FirstCalendarDay(Control.VisibleDate); arr = new ArrayList(); String weekDisplay; for (int i = 0; i < 6; i++) { weekDisplay = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); weekDisplay += DaySeparator; tempDate = _threadCalendar.AddDays(tempDate, 6); weekDisplay += tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); arr.Add(weekDisplay); tempDate = _threadCalendar.AddDays(tempDate, 1); } DataBindAndRender(writer, _weekList, arr); break; // Based on the month and week selected in case ChooseMonth and ChooseWeek above, // render a list of the dates in the week. case ChooseDay: writer.Write(SR.GetString(SR.CalendarAdapterOptionChooseDate)); writer.Write(":"); writer.WriteBreak(); tempDate = Control.VisibleDate; arr = new ArrayList(); String date; String dayName; StringBuilder dayDisplay = new StringBuilder(); bool dayNameFirst = (GetNumericDateFormat()[0] != 'y'); for (int i = 0; i < 7; i++) { date = tempDate.ToString(abbreviatedMonthDayPattern, CultureInfo.CurrentCulture); if (Control.ShowDayHeader) { // Use the short format for displaying day name dayName = GetAbbreviatedDayName(tempDate); dayDisplay.Length = 0; if (dayNameFirst) { dayDisplay.Append(dayName); dayDisplay.Append(Space); dayDisplay.Append(date); } else { dayDisplay.Append(date); dayDisplay.Append(Space); dayDisplay.Append(dayName); } arr.Add(dayDisplay.ToString()); } else { arr.Add(date); } tempDate = _threadCalendar.AddDays(tempDate, 1); } DataBindAndRender(writer, _dayList, arr); break; default: Debug.Assert(false, "Unexpected Secondary UI Mode"); break; } writer.ExitStyle(Style, breakAfter); }
///////////////////////////////////////////////////////////////////// // Helper functions ///////////////////////////////////////////////////////////////////// // Return the first date of the input year and month private DateTime EffectiveVisibleDate(DateTime visibleDate) { return(_threadCalendar.AddDays( visibleDate, -(_threadCalendar.GetDayOfMonth(visibleDate) - 1))); }
private static DateTime DeferOccurrenceFallingOnWeekend(Calendar calendar, DateTime occurrence, bool skipWeekends = true) { if(skipWeekends) { if (occurrence.DayOfWeek == DayOfWeek.Saturday) { occurrence = calendar.AddDays(occurrence, 2); } if (occurrence.DayOfWeek == DayOfWeek.Sunday) { occurrence = calendar.AddDays(occurrence, 1); } } return occurrence.ToUniversalTime(); }
private static IEnumerable<DateTime> GetOccurrences(DateInterval interval, DatePeriod period, Calendar calendar, DateTime start, DateTime end, bool skipWeekends = true) { var difference = DateSpan.GetDifference(interval, start, end)/period.Quantifier; if (start.Kind == DateTimeKind.Utc) { start = start.ToLocalTime(); } for (var i = 0; i < difference; i++) { switch (period.Frequency) { case DatePeriodFrequency.Seconds: var seconds = calendar.AddSeconds(start, period.Quantifier * i); yield return DeferOccurrenceFallingOnWeekend(calendar, seconds, skipWeekends); break; case DatePeriodFrequency.Minutes: var minutes = calendar.AddMinutes(start, period.Quantifier * i); yield return DeferOccurrenceFallingOnWeekend(calendar, minutes, skipWeekends); break; case DatePeriodFrequency.Hours: var hours = calendar.AddHours(start, period.Quantifier * i); yield return DeferOccurrenceFallingOnWeekend(calendar, hours, skipWeekends); break; case DatePeriodFrequency.Days: var days = calendar.AddDays(start, period.Quantifier*i); yield return DeferOccurrenceFallingOnWeekend(calendar, days, skipWeekends); break; case DatePeriodFrequency.Weeks: var weeks = calendar.AddWeeks(start, period.Quantifier*i); yield return DeferOccurrenceFallingOnWeekend(calendar, weeks, skipWeekends); break; case DatePeriodFrequency.Months: var months = calendar.AddMonths(start, period.Quantifier*i); yield return DeferOccurrenceFallingOnWeekend(calendar, months, skipWeekends); break; case DatePeriodFrequency.Years: var years = calendar.AddYears(start, period.Quantifier*i); yield return DeferOccurrenceFallingOnWeekend(calendar, years, skipWeekends); break; default: throw new ArgumentException("Frequency"); } } }
public void UpdateMonthMode() { Debug.Assert(this._owner.DisplayDate != null); _currentMonth = (DateTime)this._owner.DisplayDate; _firstDayOfWeek = this._owner.FirstDayOfWeek; if (_currentMonth != null) { int year = _calendar.GetYear(_currentMonth); int month = _calendar.GetMonth(_currentMonth); DateTime firstDayOfMonth = new DateTime(year, month, 1); if (this._headerButton != null) { this._headerButton.Content = string.Format(CultureInfo.CurrentCulture, Resource.Calendar_MonthViewHeaderText, CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[month - 1], year.ToString(CultureInfo.CurrentCulture)); this._headerButton.IsEnabled = true; } int lastMonthToDisplay = PreviousMonthDays(firstDayOfMonth); DateTime dateToAdd = _calendar.AddDays(firstDayOfMonth, -lastMonthToDisplay); DateTime firstDayOfNextMonth = _calendar.AddMonths(firstDayOfMonth, 1); // check to see if Prev/Next Buttons will be displayed if (_previousButton != null) { if (DateTime.Compare(_owner.DisplayDateStart.GetValueOrDefault(DateTime.MinValue), firstDayOfMonth) > -1) { _previousButton.IsEnabled = false; } else { _previousButton.IsEnabled = true; } } if (_nextButton != null) { if (DateTime.Compare(_owner.DisplayDateEnd.GetValueOrDefault(DateTime.MaxValue), firstDayOfNextMonth) < 0) { _nextButton.IsEnabled = false; } else { _nextButton.IsEnabled = true; } } int count = 0; if (_monthGrid != null) { Debug.Assert(_monthGrid.Children.Count == COLS * ROWS); //Set the day titles foreach (object child in _monthGrid.Children) { if (count < (COLS)) { //this assumes that the day titles are always text blocks TextBlock daytitle = child as TextBlock; Debug.Assert(daytitle != null); daytitle.Text = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedDayNames[(count + (int)_firstDayOfWeek) % NUMBER_OF_DAYS_IN_WEEK]; } else { DayButton mybutton = child as DayButton; Debug.Assert(mybutton != null); SetButtonState(mybutton, dateToAdd); mybutton.IsTabStop = false; if (_currentButton == null) { if (_owner.SelectedDate == null && mybutton.IsToday) { mybutton.IsTabStop = true; _currentButton = mybutton; mybutton.IsCurrent = true; } else { if (mybutton.IsSelected) { mybutton.IsTabStop = true; _currentButton = mybutton; mybutton.IsCurrent = true; } } } mybutton.Content = String.Format(CultureInfo.CurrentCulture, "{0,2}", dateToAdd.Day); mybutton.DataContext = dateToAdd; dateToAdd = _calendar.AddDays(dateToAdd, 1); } count++; } } } }
/// <summary> /// Gets the first day of a week. /// </summary> /// <param name="year">The year.</param> /// <param name="week">The week.</param> /// <param name="calendar">The calendar.</param> /// <param name="calendarWeekRule">The calendar week rule.</param> /// <param name="firstDayOfWeek">The first day of week.</param> /// <returns>The date of the first day in the week.</returns> public static DateTime GetFirstDayOfWeek( int year, int week, Calendar calendar = null, CalendarWeekRule calendarWeekRule = CalendarWeekRule.FirstFourDayWeek, DayOfWeek firstDayOfWeek = DayOfWeek.Sunday) { if (calendar == null) calendar = CultureInfo.CurrentCulture.Calendar; DateTime firstDay = new DateTime(year, 1, 7, calendar); while (calendar.GetDayOfWeek(firstDay) != firstDayOfWeek || WeekNumber(firstDay, calendar, calendarWeekRule, firstDayOfWeek) % 52 > 1) { firstDay = calendar.AddDays(firstDay, -1); } // Add the week return (week != 1) ? calendar.AddWeeks(firstDay, week - 1) : firstDay; }
private void SetCalendarDayButtons(DateTime firstDayOfMonth) { int lastMonthToDisplay = PreviousMonthDays(firstDayOfMonth); DateTime dateToAdd; if (DateTimeHelper.CompareYearMonth(firstDayOfMonth, DateTime.MinValue) > 0) { //DisplayDate is not equal to DateTime.MinValue //we can subtract days from the DisplayDate dateToAdd = _calendar.AddDays(firstDayOfMonth, -lastMonthToDisplay); } else { dateToAdd = firstDayOfMonth; } if (this.Owner != null && this.Owner.HoverEnd != null && this.Owner._hoverStart != null) { this.Owner._hoverEndIndex = null; this.Owner._hoverStartIndex = null; } int count = ROWS * COLS; for (int childIndex = COLS; childIndex < count; childIndex++) { CalendarDayButton childButton = _monthView.Children[childIndex] as CalendarDayButton; Debug.Assert(childButton != null); childButton.Index = childIndex; SetButtonState(childButton, dateToAdd); //Update the indexes of hoverStart and hoverEnd if (this.Owner != null && this.Owner.HoverEnd != null && this.Owner._hoverStart != null) { if (DateTimeHelper.CompareDays(dateToAdd, this.Owner.HoverEnd.Value) == 0) { this.Owner._hoverEndIndex = childIndex; } if (DateTimeHelper.CompareDays(dateToAdd, this.Owner._hoverStart.Value) == 0) { this.Owner._hoverStartIndex = childIndex; } } childButton.IsTabStop = false; childButton.Content = dateToAdd.Day.ToString(DateTimeHelper.GetCurrentDateFormat()); childButton.DataContext = dateToAdd; if (DateTime.Compare((DateTime)DateTimeHelper.DiscardTime(DateTime.MaxValue), dateToAdd) > 0) { //Since we are sure DisplayDate is not equal to DateTime.MaxValue, //it is safe to use AddDays dateToAdd = _calendar.AddDays(dateToAdd, 1); } else { //DisplayDate is equal to the DateTime.MaxValue, so there are no trailing days childIndex++; for (int i = childIndex; i < count; i++) { childButton = _monthView.Children[i] as CalendarDayButton; Debug.Assert(childButton != null); //button needs a content to occupy the necessary space for the content presenter childButton.Content = i.ToString(DateTimeHelper.GetCurrentDateFormat()); childButton.IsEnabled = false; childButton.Opacity = 0; } return; } } //If the _hoverStart or _hoverEnd could not be found on the DisplayMonth set the values of the _hoverStartIndex or _hoverEndIndex to be the // first or last day indexes on the current month if (this.Owner != null && this.Owner._hoverStart.HasValue && this.Owner._hoverEnd.HasValue) { if (!this.Owner._hoverEndIndex.HasValue) { if (DateTimeHelper.CompareDays(this.Owner._hoverEnd.Value, this.Owner._hoverStart.Value) > 0) { this.Owner._hoverEndIndex = COLS * ROWS - 1; } else { this.Owner._hoverEndIndex = COLS; } } if (!this.Owner._hoverStartIndex.HasValue) { if (DateTimeHelper.CompareDays(this.Owner._hoverEnd.Value, this.Owner._hoverStart.Value) > 0) { this.Owner._hoverStartIndex = COLS; } else { this.Owner._hoverStartIndex = COLS * ROWS - 1; } } } }