@namespace Connected.Components @inherits Picker @Render @code { protected override RenderFragment PickerContent => @
@{ int dayId = 0; @if (_picker_month.HasValue && _picker_month.Value.Year == 1 && _picker_month.Value.Month == 1) { dayId = -1; } } @for (int displayMonth = 0; displayMonth < DisplayMonths; ++displayMonth) { int tempMonth = displayMonth; //without local variable month names are wrong
@if (tempMonth == 0 && CurrentView == OpenTo.Year) {
@for (int i = GetMinYear(); i <= GetMaxYear(); i++) { var year = i;
@GetCalendarYear(year)
}
} else if (tempMonth == 0 && CurrentView == OpenTo.Month) { var calendarYear = GetCalendarYear(PickerMonth?.Year ?? DateTime.Today.Year); var prevLabel = $"Go to previous year {calendarYear - 1}"; var nextLabel = $"Go to next year {calendarYear + 1}";
@if (!FixYear.HasValue) { } else { @calendarYear }
@foreach (var month in GetAllMonths()) { }
} else if (CurrentView == OpenTo.Date || tempMonth > 0) { var prevLabel = $"Go to previous month {GetMonthName((tempMonth - 1) % 12)}"; var nextLabel = $"Go to next month {GetMonthName((tempMonth + 1) % 12)}";
@if (!FixMonth.HasValue) { } else { @GetMonthName(tempMonth) }
@if (ShowWeekNumbers) {
} @foreach (var dayname in GetAbbreviatedDayNames()) { @dayname }
@for (int week = 0; week < 6; week++) { int tempWeek = week; var firstMonthFirstYear = _picker_month.HasValue && _picker_month.Value.Year == 1 && _picker_month.Value.Month == 1; @if (ShowWeekNumbers) {
@GetWeekNumber(tempMonth, tempWeek)
} @foreach (var day in GetWeek(tempMonth, tempWeek)) { var tempId = ++dayId; @if (tempId != 0 || !firstMonthFirstYear) { var selectedDay = !firstMonthFirstYear ? day : day.AddDays(-1); } else { } } }
}
}
; }