ant-design-blazor/components/date-picker/internal/DatePickerDecadePanel.razor
笨木头 c3b0b114e6 feat: add form(basic features) (#168)
* feat: add form(not complete yet)

* feat: add form(basic)

* refactor: change namespace

* feat(module: form): add onFinish, onFinishFailed, reset

* feat(module: form): add layout demo

* feat(module: form): update doc

* refactor: basic form

Co-authored-by: ElderJames <shunjiey@hotmail.com>
2020-06-01 14:09:28 +08:00

42 lines
1.7 KiB
C#

@namespace AntDesign.Internal
@typeparam TValue
@inherits DatePickerPanelBase<TValue>
@using System.Globalization;
@{
var calendar = CultureInfo.InvariantCulture.Calendar;
int startYear = PickerValue.Year / 100 * 100 - 10;
DateTime startDate = new DateTime(startYear, 1, 1);
int yearIndex = 0;
const int MAX_ROW = 4;
const int MAX_COL = 3;
const int FIRST_YEAR_INDEX = 0;
const int LAST_YEAR_INDEX = MAX_ROW * MAX_COL;
}
<DatePickerTemplate TValue="TValue"
PickerIndex="@PickerIndex"
MaxRow="MAX_ROW"
MaxCol="MAX_COL"
ViewStartDate="startDate"
IsInView="date => yearIndex != FIRST_YEAR_INDEX && yearIndex != LAST_YEAR_INDEX"
IsToday="date => DateHelper.IsSameYear(date, DatePicker.CurrentDate)"
IsSelected="date => DateHelper.IsSameYear(date, Value)"
OnValueSelect="date => OnSelectYear(date)"
GetNextColValue="date => date.AddYears(10)">
<RenderPickerHeader>
<DatePickerHeader TValue="TValue"
SuperChangeDateInterval="100"
PickerIndex="@PickerIndex"
ShowPreChange="@false"
ShowNextChange="@false"
ShowSuperPreChange="@(!(DatePicker.IsRange && PickerIndex == 1))"
ShowSuperNextChange="@(!(DatePicker.IsRange && PickerIndex == 0))" />
</RenderPickerHeader>
<RenderColValue Context="currentColDate">
@{yearIndex++;}
@(currentColDate.Year)-@(currentColDate.Year + 9)
</RenderColValue>
</DatePickerTemplate>