public CalendarMonthView(DateTime selectedDate, bool showHeader, bool showNavArrows, float width = 320) { _showHeader = showHeader; _showNavArrows = showNavArrows; if (_showNavArrows) { _showHeader = true; } _styleDescriptor = new StyleDescriptor(); HighlightDaysOfWeeks(new DayOfWeek[] {}); if (_showHeader && headerHeight == 0) { if (showNavArrows) { headerHeight = 40; } else { headerHeight = 20; } } if (_showHeader) { this.Frame = new RectangleF(0, 0, width, 198 + headerHeight); } else { this.Frame = new RectangleF(0, 0, width, 198); } BoxWidth = Convert.ToInt32(Math.Ceiling(width / 7)); BackgroundColor = UIColor.White; ClipsToBounds = true; CurrentDate = DateTime.Now.Date; CurrentMonthYear = new DateTime(CurrentDate.Year, CurrentDate.Month, 1); CurrentSelectedDate = selectedDate; var swipeLeft = new UISwipeGestureRecognizer(p_monthViewSwipedLeft); swipeLeft.Direction = UISwipeGestureRecognizerDirection.Left; this.AddGestureRecognizer(swipeLeft); var swipeRight = new UISwipeGestureRecognizer(p_monthViewSwipedRight); swipeRight.Direction = UISwipeGestureRecognizerDirection.Right; this.AddGestureRecognizer(swipeRight); var swipeUp = new UISwipeGestureRecognizer(p_monthViewSwipedUp); swipeUp.Direction = UISwipeGestureRecognizerDirection.Up; this.AddGestureRecognizer(swipeUp); }
/// <summary> /// Initializes a new instance of the <see cref="ECalendarPickerView"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="attrs">The attrs.</param> public ECalendarPickerView(Context context, IAttributeSet attrs) : base(context, attrs) { ResourceIdManager.UpdateIdValues(); _context = context; _styleDescriptor = new StyleDescriptor(); MyAdapter = new EMonthAdapter(context, this); base.Adapter = MyAdapter; //base.Divider = null; //base.DividerHeight = 0; this.PageMargin = 5; 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); } }