/// <summary> /// Layouts the calendar. /// </summary> private void LayoutCalendar() { var cellWidth = this.Bounds.Size.Width / (float)mColumns; float headerHeight = (DSCalendarTheme.CurrentTheme.DayStyle == CalendarDayStyle.Header) ? DSCalendarTheme.CurrentTheme.HeaderHeight : 0; float left = 0.0f; int loop = 0; if (DSCalendarTheme.CurrentTheme.DayStyle == CalendarDayStyle.Header) { while (loop < mColumns) { var cell = mHeaderCells[loop]; cell.Frame = new RectangleF(left, 0, cellWidth, headerHeight).Integral(); var intDay = 0; if (DSCalendarTheme.CurrentTheme.WeekStart == CalendarWeekStart.Sunday) { intDay = (int)EnumHelper.ConvertSundayDayToDay((WeekDayFromSunday)loop); } else { intDay = loop; } switch (DSCalendarTheme.CurrentTheme.HeaderDayDisplayMode) { case CalendarDayDisplayMode.Full: { cell.Text = DSCalendarEnglish.CurrentLanguage.DayStrings[intDay]; } break; case CalendarDayDisplayMode.Short: { cell.Text = DSCalendarEnglish.CurrentLanguage.ShortStringForDay(intDay); } break; default: { cell.Text = String.Empty; } break; } left += cellWidth; loop++; } } float cellHeight = (this.Bounds.Size.Height - headerHeight) / (float)NumberOfRows; var today = DateTime.Now; var cleanedToday = new DateTime(today.Year, today.Month, today.Day); var datePos = 0; foreach (List <DSCalendarCell> row in RowCells) { left = 0.0f; loop = 0; while (loop < mColumns) { var aDate = Dates[datePos]; var aCellInfo = new DSCalendarCellInfo() { Date = aDate }; aCellInfo.IsFirstRow = (RowCells.IndexOf(row) == 0); aCellInfo.IsFocus = (aCellInfo.Date == cleanedToday); if ((aDate >= FirstDay) && (aDate <= LastDay)) { aCellInfo.IsCurrent = true; } switch (DSCalendarTheme.CurrentTheme.MonthDisplayMode) { case CalendarMonthDisplayMode.FirstOnly: { if (aDate.Equals(FirstDay)) { aCellInfo.ShowMonth = true; } } break; case CalendarMonthDisplayMode.OnChange: { if ((datePos == 0 && loop == 0) || aDate.Equals(FirstDay) || (aDate > LastDay && aDate.Day == 1)) { aCellInfo.ShowMonth = true; } } break; } var cell = row[loop]; cell.Events = Data[aDate]; cell.Frame = new RectangleF(left, headerHeight, cellWidth, cellHeight).Integral(); cell.CellInfo = aCellInfo; if (aCellInfo.Date == mSelectedDate) { cell.IsSelected = true; } left += cellWidth; loop++; datePos++; } headerHeight += cellHeight; } }