/// <summary> /// Called when [element changed]. /// </summary> /// <param name="e">The e.</param> protected override void OnElementChanged(ElementChangedEventArgs <ECalendarView> e) { base.OnElementChanged(e); if (e.OldElement == null) { _view = e.NewElement; var inflatorservice = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService); _containerView = inflatorservice.Inflate(Resource.Layout.ecalendar_picker, null); _picker = _containerView.FindViewById <ECalendarPickerView>(Resource.Id.ecalendar_view); _picker.Init(Element.MinDate, Element.MaxDate, Element.HighlightedDaysOfWeek); _picker.OnDateSelected += (object sender, DateSelectedEventArgs evt) => { ProtectFromEventCycle(() => { Element.NotifyDateSelected(evt.SelectedDate); }); }; _picker.OnMonthChanged += (object sender, MonthChangedEventArgs mch) => { SetNavigationArrows(); ProtectFromEventCycle(() => { Element.NotifyDisplayedMonthChanged(mch.DisplayedMonth); }); }; SetDisplayedMonth(Element.DisplayedMonth); //SetNavigationArrows(); SetColors(); SetFonts(); //_picker.HighlightDates(Element.HighlightedDays); SetNativeControl((RelativeLayout)_containerView); } }
/// <summary> /// Withes the selected dates. /// </summary> /// <param name="selectedDates">The selected dates.</param> /// <returns>FluentInitializer.</returns> /// <exception cref="Java.Lang.IllegalArgumentException">SINGLE mode can't be used with multiple selectedDates</exception> public EFluentInitializer WithSelectedDates(ICollection <DateTime> selectedDates) { if (_calendar.Mode == ECalendarPickerView.SelectionMode.Single && _calendar.SelectedDates.Count > 1) { throw new IllegalArgumentException("SINGLE mode can't be used with multiple selectedDates"); } if (_calendar.SelectedDates != null) { foreach (var date in selectedDates) { _calendar.SelectDate(date); } } int selectedIndex = -1; int todayIndex = -1; for (int i = 0; i < _calendar.Months.Count; i++) { var month = _calendar.Months[i]; if (selectedIndex == -1) { if (_calendar.SelectedCals.Any( selectedCal => ECalendarPickerView.IsSameMonth(selectedCal, month))) { selectedIndex = i; } if (selectedIndex == -1 && todayIndex == -1 && ECalendarPickerView.IsSameMonth(DateTime.Now, month)) { todayIndex = i; } } } if (selectedIndex != -1) { _calendar.ScrollToSelectedMonth(selectedIndex); } else if (todayIndex != -1) { _calendar.ScrollToSelectedMonth(todayIndex); } _calendar.ValidateAndUpdate(); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="MonthAdapter"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="calendar">The calendar.</param> public EMonthAdapter(Context context, ECalendarPickerView calendar) { _calendar = calendar; _inflater = LayoutInflater.From(context); _activeMonthViews = new Dictionary <int, MonthView>(); }
/// <summary> /// Initializes a new instance of the <see cref="OnPageChangeListener"/> class. /// </summary> /// <param name="picker">The picker.</param> public OnPageChangeListener(ECalendarPickerView picker) { this._picker = picker; }
/// <summary> /// Initializes a new instance of the <see cref="EFluentInitializer"/> class. /// </summary> /// <param name="calendar">The calendar.</param> public EFluentInitializer(ECalendarPickerView calendar) { _calendar = calendar; }