public void InitWithDate(DateTime dateTime) { StopAnimations(); _DateToInitWith = null; UnregisterAutoCorrection(); int doneNum = 0; int targetDone = 2; Func <float, bool> onProgress = p01 => { if (p01 == 1f) { if (++doneNum == targetDone) { _Initialized = true; RegisterAutoCorrection(); } } return(true); }; YearAdapter.ResetItems(3000); YearAdapter.SmoothScrollTo(dateTime.Year - 1, SCROLL_DURATION1, .5f, .5f); MonthAdapter.ResetItems(12); MonthAdapter.SmoothScrollTo(dateTime.Month - 1, SCROLL_DURATION2, .5f, .5f); DayAdapter.ResetItems(DateTime.DaysInMonth(dateTime.Year, dateTime.Month)); DayAdapter.SmoothScrollTo(dateTime.Day - 1, SCROLL_DURATION3, .5f, .5f, onProgress, true); SecondAdapter.ResetItems(60); SecondAdapter.SmoothScrollTo(dateTime.Second, SCROLL_DURATION1, .5f, .5f); MinuteAdapter.ResetItems(60); MinuteAdapter.SmoothScrollTo(dateTime.Minute, SCROLL_DURATION2, .5f, .5f); HourAdapter.ResetItems(24); HourAdapter.SmoothScrollTo(dateTime.Hour, SCROLL_DURATION3, .5f, .5f, onProgress, true); }
void OnMonthChanged(int month) { var selectedDay = DayAdapter.SelectedValue; int newDaysInMonth = DateTime.DaysInMonth(YearAdapter.SelectedValue, month); if (newDaysInMonth == DayAdapter.GetItemsCount()) { return; } DayAdapter.ResetItems(newDaysInMonth); DayAdapter.ScrollTo(Math.Min(newDaysInMonth, selectedDay) - 1, .5f, .5f); }