コード例 #1
0
        private void ConfigCell(FSCalendarCell cell, NSDate date, FSCalendarMonthPosition monthPosition)
        {
            var rangeCell = cell as RangePickerCell;

            if (monthPosition != FSCalendarMonthPosition.Current)
            {
                rangeCell.MiddleLayer.Hidden    = true;
                rangeCell.SelectionLayer.Hidden = true;
                return;
            }
            if (Date1 != null && Date2 != null)
            {
                // The date is in the middle of the range
                var isMiddle = date.Compare(Date1) != date.Compare(Date2);
                rangeCell.MiddleLayer.Hidden = !isMiddle;
            }
            else
            {
                rangeCell.MiddleLayer.Hidden = true;
            }
            var isSelected = false;

            isSelected |= Date1 != null && Gregorian.IsInSameDay(date, Date1);
            isSelected |= Date2 != null && Gregorian.IsInSameDay(date, Date2);
            rangeCell.SelectionLayer.Hidden = !isSelected;
        }
コード例 #2
0
        private void ConfigCell(FSCalendarCell cell, NSDate date, FSCalendarMonthPosition monthPosition)
        {
            var diyCell = cell as DIYCalendarCell;

            // Custom today circle
            diyCell.CircleImageView.Hidden = !Gregorian.IsDateInToday(date);

            // Configure selection layer
            if (monthPosition == FSCalendarMonthPosition.Current)
            {
                var selectionType = SelectionType.None;
                if (Calendar.SelectedDates.Contains(date))
                {
                    var previousDate = Gregorian.DateByAddingUnit(NSCalendarUnit.Day, -1, date, NSCalendarOptions.None);
                    var nextDate     = Gregorian.DateByAddingUnit(NSCalendarUnit.Day, 1, date, NSCalendarOptions.None);
                    if (Calendar.SelectedDates.Contains(previousDate) && Calendar.SelectedDates.Contains(nextDate))
                    {
                        selectionType = SelectionType.Middle;
                    }
                    else if (Calendar.SelectedDates.Contains(previousDate))
                    {
                        selectionType = SelectionType.RightBorder;
                    }
                    else if (Calendar.SelectedDates.Contains(nextDate))
                    {
                        selectionType = SelectionType.LeftBorder;
                    }
                    else
                    {
                        selectionType = SelectionType.Single;
                    }
                }
                else
                {
                    selectionType = SelectionType.None;
                }

                diyCell.SelectionType         = selectionType;
                diyCell.SelectionLayer.Hidden = selectionType == SelectionType.None;
            }
            else
            {
                diyCell.CircleImageView.Hidden = true;
                diyCell.SelectionLayer.Hidden  = true;
            }
        }
コード例 #3
0
 void CalendarWillDisplayCell(FSCalendar calendar, FSCalendarCell cell, NSDate date, FSCalendarMonthPosition monthPosition)
 {
     ConfigCell(cell, date, monthPosition);
 }