protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Labs.Controls.CalendarView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                _view = e.NewElement;

                LayoutInflater inflatorservice =
                    (LayoutInflater)Context.GetSystemService(Android.Content.Context.LayoutInflaterService);
                var containerView =
                    (LinearLayout)inflatorservice.Inflate(Resource.Layout.calendar_picker, null, false);

                _pickerView = containerView.FindViewById <CalendarPickerView>(Resource.Id.calendar_view);
                _pickerView.Init(new DateTime(2014, 6, 1), new DateTime(2014, 6, 30))
                .InMode(CalendarPickerView.SelectionMode.Single);

                _pickerView.OnDateSelected += (s, ef) =>
                {
                    _view.NotifyDateSelected(ef.SelectedDate);
                };

                SetNativeControl(containerView);
            }
        }
Ejemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Labs.Controls.CalendarView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                _view = e.NewElement;
                LayoutInflater inflatorservice =
                    (LayoutInflater)Context.GetSystemService(Android.Content.Context.LayoutInflaterService);
                _containerView = inflatorservice.Inflate(Resource.Layout.calendar_picker, null);
                _picker        = _containerView.FindViewById <CalendarPickerView>(Resource.Id.calendar_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);
                    });
                };
                this.SetDisplayedMonth(Element.DisplayedMonth);
                SetNavigationArrows();
                SetColors();
                SetFonts();
                SetNativeControl((Android.Widget.RelativeLayout)_containerView);
            }
        }
Ejemplo n.º 3
0
        public FluentInitializer WithSelectedDates(ICollection <DateTime> selectedDates)
        {
            if (_calendar.Mode == CalendarPickerView.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 => CalendarPickerView.IsSameMonth(selectedCal, month)))
                    {
                        selectedIndex = i;
                    }
                    if (selectedIndex == -1 && todayIndex == -1 &&
                        CalendarPickerView.IsSameMonth(DateTime.Now, month))
                    {
                        todayIndex = i;
                    }
                }
            }
            if (selectedIndex != -1)
            {
                _calendar.ScrollToSelectedMonth(selectedIndex);
            }
            else if (todayIndex != -1)
            {
                _calendar.ScrollToSelectedMonth(todayIndex);
            }

            _calendar.ValidateAndUpdate();
            return(this);
        }
 public FluentInitializer InMode(CalendarPickerView.SelectionMode mode)
 {
     _calendar.Mode = mode;
     _calendar.ValidateAndUpdate();
     return this;
 }
 public FluentInitializer(CalendarPickerView calendar)
 {
     _calendar = calendar;
 }
Ejemplo n.º 6
0
 public FluentInitializer(CalendarPickerView calendar)
 {
     _calendar = calendar;
 }
Ejemplo n.º 7
0
 public OnPageChangeListener(CalendarPickerView picker)
 {
     this._picker = picker;
 }
Ejemplo n.º 8
0
 public MonthAdapter(Context context, CalendarPickerView calendar)
 {
     _calendar         = calendar;
     _inflater         = LayoutInflater.From(context);
     _activeMonthViews = new Dictionary <int, MonthView>();
 }
Ejemplo n.º 9
0
 public MonthAdapter(Context context, CalendarPickerView calendar)
 {
     _calendar = calendar;
     _inflater = LayoutInflater.From(context);
 }