public CalendarPickerView(Context context, IAttributeSet attrs) : base(context, attrs) { ResourceIdManager.UpdateIdValues(); _context = context; MyAdapter = new MonthAdapter(context, this); base.Adapter = MyAdapter; base.Divider = null; base.DividerHeight = 0; var bgColor = base.Resources.GetColor(Resource.Color.calendar_bg); base.SetBackgroundColor(bgColor); base.CacheColorHint = bgColor; MonthNameFormat = base.Resources.GetString(Resource.String.month_name_format); WeekdayNameFormat = base.Resources.GetString(Resource.String.day_name_format); FullDateFormat = CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern; ClickHandler += OnCellClicked; OnInvalidDateSelected += OnInvalidateDateClicked; if (base.IsInEditMode) { Init(DateTime.Now, DateTime.Now.AddYears(1)).WithSelectedDate(DateTime.Now); } }
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); }
public void UpdateAdapter() { // get display metrics DisplayMetrics metrics = new DisplayMetrics(); IWindowManager windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); windowManager.DefaultDisplay.GetMetrics(metrics); // set adapter Adapter = new MonthAdapter(Context, _calendar.Get(CalendarField.Month), _calendar.Get(CalendarField.Year), metrics, _containerHeight, this, SelectedDatePosition, _monthDelta, (_monthDelta == 0 ? true : false)); ((MonthAdapter)Adapter).CompleteRefresh = false; }
public CalendarPickerView(Context context, IAttributeSet attrs) : base(context, attrs) { ResourceIdManager.UpdateIdValues(); var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.CalendarPickerView); var bg = a.GetColor(Resource.Styleable.CalendarPickerView_android_background, Resource.Color.calendar_bg); DividerColor = a.GetColor(Resource.Styleable.CalendarPickerView_dividerColor, Resource.Color.calendar_divider); DayBackgroundResID = a.GetResourceId(Resource.Styleable.CalendarPickerView_dayBackground, Resource.Drawable.calendar_bg_selector); DayTextColorResID = a.GetResourceId(Resource.Styleable.CalendarPickerView_dayTextColor, Resource.Color.calendar_text_selector); TitleTextColor = a.GetColor(Resource.Styleable.CalendarPickerView_titleTextColor, Resource.Color.calendar_text_active); HeaderTextColor = a.GetColor(Resource.Styleable.CalendarPickerView_headerTextColor, Resource.Color.calendar_text_active); a.Recycle(); _context = context; MyAdapter = new MonthAdapter(context, this); base.Adapter = MyAdapter; base.Divider = null; base.DividerHeight = 0; base.SetBackgroundColor(bg); base.CacheColorHint = bg; MonthNameFormat = base.Resources.GetString(Resource.String.month_name_format); WeekdayNameFormat = base.Resources.GetString(Resource.String.day_name_format); FullDateFormat = CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern; ClickHandler += OnCellClicked; OnInvalidDateSelected += OnInvalidateDateClicked; if (base.IsInEditMode) { Init(DateTime.Now, DateTime.Now.AddYears(1)).WithSelectedDate(DateTime.Now); } }