/// <summary> /// Initializes a new instance of the <see cref="CalendarPickerView"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="attrs">The attrs.</param> public CalendarPickerView(Context context, IAttributeSet attrs) : base(context, attrs) { ResourceIdManager.UpdateIdValues(); _context = context; _styleDescriptor = new StyleDescriptor(); MyAdapter = new MonthAdapter(context, this); base.Adapter = MyAdapter; //SetPadding(0, 0, 0, 0); var bgColor = base.Resources.GetColor(Resource.Color.calendar_bg); base.SetBackgroundColor(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; SetOnPageChangeListener(new OnPageChangeListener(this)); if (base.IsInEditMode) { Init(DateTime.Now, DateTime.Now.AddYears(1), new DayOfWeek[] { }).WithSelectedDate(DateTime.Now); } }
/// <summary> /// Initializes a new instance of the <see cref="MonthDescriptor"/> class. /// </summary> /// <param name="month">The month.</param> /// <param name="year">The year.</param> /// <param name="date">The date.</param> /// <param name="label">The label.</param> /// <param name="style">The style.</param> public MonthDescriptor(int month, int year, DateTime date, string label, StyleDescriptor style) { Month = month; Year = year; Date = date; Label = label; Style = style; }
/// <summary> /// Initializes a new instance of the <see cref="MonthCellDescriptor"/> class. /// </summary> /// <param name="date">The date.</param> /// <param name="isCurrentMonth">if set to <c>true</c> [is current month].</param> /// <param name="isSelectable">if set to <c>true</c> [is selectable].</param> /// <param name="isSelected">if set to <c>true</c> [is selected].</param> /// <param name="isToday">if set to <c>true</c> [is today].</param> /// <param name="isHighlighted">if set to <c>true</c> [is highlighted].</param> /// <param name="value">The value.</param> /// <param name="rangeState">State of the range.</param> /// <param name="style">The style.</param> public MonthCellDescriptor(DateTime date, bool isCurrentMonth, bool isSelectable, bool isSelected, bool isToday, bool isHighlighted, int value, RangeState rangeState, StyleDescriptor style) { DateTime = date; Value = value; IsCurrentMonth = isCurrentMonth; IsSelected = isSelected; IsHighlighted = isHighlighted; IsToday = isToday; IsSelectable = isSelectable; RangeState = rangeState; Style = style; }
/// <summary> /// Sets the style. /// </summary> /// <param name="style">The style.</param> public void SetStyle(StyleDescriptor style) { if (style.DateLabelFont != null) { this.Typeface = (style.DateLabelFont); } if (this.Selected && !_isSelectableDatesMarked) { SetBackgroundColor(style.SelectedDateBackgroundColor); SetTextColor(style.SelectedDateForegroundColor); } else if (this.Selected && _isSelectableDatesMarked) { SetBackgroundColor(style.SelectedDatesBackgroundColor); SetTextColor(style.SelectedDatesForegroundColor); } else if (_isToday) { SetBackgroundColor(style.TodayBackgroundColor); SetTextColor(style.TodayForegroundColor); } else if (_isHighlighted) { SetBackgroundColor(style.HighlightedDateBackgroundColor); if (_isCurrentMonth) { SetTextColor(style.HighlightedDateForegroundColor); } else { SetTextColor(style.InactiveDateForegroundColor); } } else if (!_isCurrentMonth) { SetBackgroundColor(style.InactiveDateBackgroundColor); SetTextColor(style.InactiveDateForegroundColor); } else { SetBackgroundColor(style.DateBackgroundColor); SetTextColor(style.DateForegroundColor); } }
/// <summary> /// Initializes a new instance of the <see cref="CalendarPickerView"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="attrs">The attrs.</param> public CalendarPickerView(Context context, IAttributeSet attrs) : base(context, attrs) { ResourceIdManager.UpdateIdValues(); _context = context; _styleDescriptor = new StyleDescriptor(); MyAdapter = new MonthAdapter(context, this); base.Adapter = MyAdapter; //base.Divider = null; //base.DividerHeight = 0; this.PageMargin = 32; SetPadding(0, 0, 0, 0); //Sometimes dates could not be selected after the transform. I had to disable it. :( //SetPageTransformer(true, new CalendarMonthPageTransformer()); 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; this.SetOnPageChangeListener(new OnPageChangeListener(this)); if (base.IsInEditMode) { Init(DateTime.Now, DateTime.Now.AddYears(1), new DayOfWeek[] { }).WithSelectedDate(DateTime.Now); } }
/// <summary> /// Initializes a new instance of the <see cref="CalendarPickerView"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="attrs">The attrs.</param> public CalendarPickerView(Context context, IAttributeSet attrs) : base(context, attrs) { ResourceIdManager.UpdateIdValues(); _context = context; _styleDescriptor = new StyleDescriptor(); MyAdapter = new MonthAdapter(context, this); base.Adapter = MyAdapter; //base.Divider = null; //base.DividerHeight = 0; this.PageMargin = 32; SetPadding(0, 0, 0, 0); //Sometimes dates could not be selected after the transform. I had to disable it. :( //SetPageTransformer(true, new CalendarMonthPageTransformer()); 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; this.SetOnPageChangeListener(new OnPageChangeListener(this)); if(base.IsInEditMode) { Init(DateTime.Now, DateTime.Now.AddYears(1), new DayOfWeek[]{ }).WithSelectedDate(DateTime.Now); } }
/// <summary> /// Sets the style. /// </summary> /// <param name="style">The style.</param> public void SetStyle(StyleDescriptor style) { if(style.DateLabelFont != null) { this.Typeface = (style.DateLabelFont); } if(this.Selected) { SetBackgroundColor(style.SelectedDateBackgroundColor); SetTextColor(style.SelectedDateForegroundColor); } else if(_isToday) { SetBackgroundColor(style.TodayBackgroundColor); SetTextColor(style.TodayForegroundColor); } else if(_isHighlighted) { SetBackgroundColor(style.HighlightedDateBackgroundColor); if(_isCurrentMonth) { SetTextColor(style.HighlightedDateForegroundColor); } else { SetTextColor(style.InactiveDateForegroundColor); } } else if(!_isCurrentMonth) { SetBackgroundColor(style.InactiveDateBackgroundColor); SetTextColor(style.InactiveDateForegroundColor); } else { SetBackgroundColor(style.DateBackgroundColor); SetTextColor(style.DateForegroundColor); } }