Ejemplo n.º 1
0
        public CalendarMonth(DateTime selectedMonth,
                             DateTime selectedDate,
                             Action <DateTime> onSelectDate,
                             CalendarPaints paints,
                             CalendarRules calendarRules,
                             CalendarSettings calendarSettings)
        {
            _onSelectDate     = onSelectDate;
            _calendarSettings = calendarSettings;

            var firstDay            = selectedMonth.GetFirstDayOfMonth();
            var firstDayOfFirstWeek = firstDay.AddDays(-firstDay.GetDayPositionInWeek());
            var lastDay             = new DateTime(selectedMonth.Year, selectedMonth.Month, DateTime.DaysInMonth(selectedMonth.Year, selectedMonth.Month));
            var lastDayOfLastWeek   = lastDay.AddDays(CalendarDrawer.DAYS_PER_WEEK - 1 - lastDay.GetDayPositionInWeek());
            var totalDays           = (lastDayOfLastWeek - firstDayOfFirstWeek).Days + 1;
            var totalWeeks          = (totalDays) / CalendarDrawer.DAYS_PER_WEEK;

            for (var d = 0; d < totalDays; d++)
            {
                var day = firstDayOfFirstWeek.AddDays(d);
                Add(new CalendarDay(day, selectedMonth, CalendarDrawer.MAX_DISPLAYED_WEEKS, paints, calendarRules, SelectDate, selectedDate.Date == day.Date));
            }
            Add(new SkiaGrid(1, 1, CalendarDrawer.DAYS_PER_WEEK, paints.PaintLine, 0, CalendarDrawer.HeaderHeight));

            Add(new SkiaGrid(totalWeeks, CalendarDrawer.MAX_DISPLAYED_WEEKS, CalendarDrawer.DAYS_PER_WEEK, paints.PaintLine, CalendarDrawer.HeaderHeight));
            Add(new CalendarWeekDays(paints.PaintHeaderDay, _calendarSettings));
        }
Ejemplo n.º 2
0
 public CalendarDrawer(CalendarSettings calendarSettings,
                       Action invalidate,
                       Action <MonthSelectionState> onMonthChange,
                       UIColor cellColor,
                       float marginH = 0,
                       float marginV = 0)
     : base(invalidate, cellColor.ToSKColor(), marginH, marginV)
 {
     _calendarSettings = calendarSettings;
     _onMonthChange    = onMonthChange;
     _paints           = new CalendarPaints(calendarSettings);
     _selectedDate     = _currentMonth = calendarSettings.SelectedDate;
     ChangeMonth(0);
 }
Ejemplo n.º 3
0
 public CalendarDay(DateTime d,
                    DateTime selectedMonth,
                    int totalWeeksToDisplay,
                    CalendarPaints paints,
                    CalendarRules calendarRules,
                    Action <DateTime> onPress,
                    bool isSelected = false)
 {
     Date                 = d;
     _paints              = paints;
     _rules               = calendarRules;
     _selectedMonth       = selectedMonth;
     _totalWeeksToDisplay = totalWeeksToDisplay;
     OnPressAction        = bt => onPress?.Invoke(Date);
     IsSelected           = isSelected;
 }