private void drawMonthCalendar() { var startDay = PersianDate.Find1StDayOfMonth(CalendarData.Year, CalendarData.Month, CalendarAttributes.CalendarType); int noOfDays; if (CalendarAttributes.CalendarType == CalendarType.PersianCalendar) { noOfDays = CalendarData.Month <= 6 ? 31 : 30; } else { noOfDays = DateTime.DaysInMonth(CalendarData.Year, CalendarData.Month); } if (CalendarData.Month == 12 && CalendarAttributes.CalendarType == CalendarType.PersianCalendar) { noOfDays = CalendarData.Year.IsLeapYear(CalendarAttributes.CalendarType) ? 30 : 29; } var monthCells = createEmptyCells(); fillCells(startDay, noOfDays, monthCells); addCells(monthCells); }