コード例 #1
0
 public void UpdateDayView(CalendarDayView dayView)
 {
     dayView.Marked = _calendarMonthView.IsDayMarkedDelegate == null ?
                      false : _calendarMonthView.IsDayMarkedDelegate(dayView.Date);
     dayView.Available = _calendarMonthView.IsDateAvailable == null ?
                         true : _calendarMonthView.IsDateAvailable(dayView.Date);
 }
コード例 #2
0
		public void UpdateDayView(CalendarDayView dayView){
			dayView.Marked = _calendarMonthView.IsDayMarkedDelegate == null ? 
				false : _calendarMonthView.IsDayMarkedDelegate(dayView.Date);
			dayView.Available = _calendarMonthView.IsDateAvailable == null ? 
				true : _calendarMonthView.IsDateAvailable(dayView.Date);
		}
コード例 #3
0
		public void BuildGrid()
		{
			DateTime previousMonth = _currentMonth.AddMonths(-1);
			DateTime nextMonth = _currentMonth.AddMonths(1);
			var daysInPreviousMonth = DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month);
			var daysInMonth = DateTime.DaysInMonth(_currentMonth.Year, _currentMonth.Month);
			weekdayOfFirst = WeekDayIndex(_currentMonth.DayOfWeek);
			var lead = daysInPreviousMonth - (weekdayOfFirst - 1);

			// build last month's days
			for (int i = 1; i <= weekdayOfFirst; i++)
			{
				var viewDay = new DateTime(previousMonth.Year, previousMonth.Month, i);
				var dayView = new CalendarDayView { SelectionColor = _calendarMonthView.SelectionColor, TodayCircleColor = _calendarMonthView.TodayCircleColor, BackgroundColor = _calendarMonthView.MonthBackgroundColor };

				#if __UNIFIED__

				dayView.Frame = new CoreGraphics.CGRect((i - 1) * WeekDayWidth, 0, WeekDayWidth, WeekDayHeigth);

				#else

				dayView.Frame = new RectangleF((i - 1) * WeekDayWidth, 0, WeekDayWidth, WeekDayHeigth);

				#endif

				dayView.Date = viewDay;
				dayView.Text = lead.ToString();

				AddSubview(dayView);
				_dayTiles.Add(dayView);
				lead++;
			}

			var position = weekdayOfFirst+1;
			var line = 0;

			// current month
			for (int i = 1; i <= daysInMonth; i++)
			{
				var viewDay = new DateTime(_currentMonth.Year, _currentMonth.Month, i);
				var dayView = new CalendarDayView
				{
					#if __UNIFIED__

					Frame = new CoreGraphics.CGRect((position - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),

					#else

					Frame = new RectangleF((position - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),

					#endif

					Today = (CurrentDate.Date==viewDay.Date),
					Text = i.ToString(),

					Active = true,
					Tag = i,
					Selected = viewDay.Date == SelectedDate.Date,
					SelectionColor = _calendarMonthView.SelectionColor,
					TodayCircleColor = _calendarMonthView.TodayCircleColor,
					BackgroundColor = _calendarMonthView.MonthBackgroundColor,
				};
				dayView.Date = viewDay;
				UpdateDayView(dayView);

				if (dayView.Selected)
					SelectedDayView = dayView;

				AddSubview(dayView);
				_dayTiles.Add(dayView);

				position++;
				if (position > 7)
				{
					position = 1;
					line++;
				}
			}

			//next month
			if (position != 1)
			{
				int dayCounter = 1;
				for (int i = position; i < 8; i++)
				{
					var viewDay = new DateTime(nextMonth.Year, nextMonth.Month, i);
					var dayView = new CalendarDayView
					{
						#if __UNIFIED__

						Frame = new CoreGraphics.CGRect((i - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),

						#else

						Frame = new RectangleF((i - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),

						#endif

						Text = dayCounter.ToString(),
						SelectionColor = _calendarMonthView.SelectionColor,
						TodayCircleColor = _calendarMonthView.TodayCircleColor,
						BackgroundColor = _calendarMonthView.MonthBackgroundColor,
					};
					dayView.Date = viewDay;
					UpdateDayView(dayView);

					AddSubview(dayView);
					_dayTiles.Add(dayView);
					dayCounter++;
				}
			}

			#if __UNIFIED__

			Frame = new CoreGraphics.CGRect(Frame.Location, new CoreGraphics.CGSize(Frame.Width, (line + 1) * WeekDayHeigth));

			#else

			Frame = new RectangleF(Frame.Location, new SizeF(Frame.Width, (line + 1) * WeekDayHeigth));

			#endif

			//Lines = (position == 1 ? line - 1 : line);

			if (SelectedDayView!=null)
				this.BringSubviewToFront(SelectedDayView);
		}
コード例 #4
0
        public void BuildGrid()
        {
            DateTime previousMonth       = _currentMonth.AddMonths(-1);
            DateTime nextMonth           = _currentMonth.AddMonths(1);
            var      daysInPreviousMonth = DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month);
            var      daysInMonth         = DateTime.DaysInMonth(_currentMonth.Year, _currentMonth.Month);

            weekdayOfFirst = WeekDayIndex(_currentMonth.DayOfWeek);
            var lead = daysInPreviousMonth - (weekdayOfFirst - 1);

            // build last month's days
            for (int i = 1; i <= weekdayOfFirst; i++)
            {
                var viewDay = new DateTime(previousMonth.Year, previousMonth.Month, i);
                var dayView = new CalendarDayView {
                    SelectionColor = _calendarMonthView.SelectionColor, TodayCircleColor = _calendarMonthView.TodayCircleColor, BackgroundColor = _calendarMonthView.MonthBackgroundColor
                };

                                #if __UNIFIED__
                dayView.Frame = new CoreGraphics.CGRect((i - 1) * WeekDayWidth, 0, WeekDayWidth, WeekDayHeigth);
                                #else
                dayView.Frame = new RectangleF((i - 1) * WeekDayWidth, 0, WeekDayWidth, WeekDayHeigth);
                                #endif

                dayView.Date = viewDay;
                dayView.Text = lead.ToString();

                AddSubview(dayView);
                _dayTiles.Add(dayView);
                lead++;
            }

            var position = weekdayOfFirst + 1;
            var line     = 0;

            // current month
            for (int i = 1; i <= daysInMonth; i++)
            {
                var viewDay = new DateTime(_currentMonth.Year, _currentMonth.Month, i);
                var dayView = new CalendarDayView
                {
                                        #if __UNIFIED__
                    Frame = new CoreGraphics.CGRect((position - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),
                                        #else
                    Frame = new RectangleF((position - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),
                                        #endif

                    //Today = (CurrentDate.Date==viewDay.Date),
                    Text = i.ToString(),

                    Active           = true,
                    Tag              = i,
                    Selected         = viewDay.Date == SelectedDate.Date,
                    SelectionColor   = _calendarMonthView.SelectionColor,
                    TodayCircleColor = _calendarMonthView.TodayCircleColor,
                    BackgroundColor  = _calendarMonthView.MonthBackgroundColor,
                };
                dayView.Date = viewDay;
                UpdateDayView(dayView);

                if (dayView.Selected)
                {
                    SelectedDayView = dayView;
                }

                AddSubview(dayView);
                _dayTiles.Add(dayView);

                position++;
                if (position > 7)
                {
                    position = 1;
                    line++;
                }
            }

            //next month
            if (position != 1)
            {
                int dayCounter = 1;
                for (int i = position; i < 8; i++)
                {
                    var viewDay = new DateTime(nextMonth.Year, nextMonth.Month, i);
                    var dayView = new CalendarDayView
                    {
                                                #if __UNIFIED__
                        Frame = new CoreGraphics.CGRect((i - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),
                                                #else
                        Frame = new RectangleF((i - 1) * WeekDayWidth, line * WeekDayHeigth, WeekDayWidth, WeekDayHeigth),
                                                #endif

                        Text             = dayCounter.ToString(),
                        SelectionColor   = _calendarMonthView.SelectionColor,
                        TodayCircleColor = _calendarMonthView.TodayCircleColor,
                        BackgroundColor  = _calendarMonthView.MonthBackgroundColor,
                    };
                    dayView.Date = viewDay;
                    UpdateDayView(dayView);

                    AddSubview(dayView);
                    _dayTiles.Add(dayView);
                    dayCounter++;
                }
            }

                        #if __UNIFIED__
            Frame = new CoreGraphics.CGRect(Frame.Location, new CoreGraphics.CGSize(Frame.Width, (line + 1) * WeekDayHeigth));
                        #else
            Frame = new RectangleF(Frame.Location, new SizeF(Frame.Width, (line + 1) * WeekDayHeigth));
                        #endif

            //Lines = (position == 1 ? line - 1 : line);

            if (SelectedDayView != null)
            {
                this.BringSubviewToFront(SelectedDayView);
            }
        }
コード例 #5
0
		public void BuildGrid()
		{
            //BackgroundColor = UIColor.Red;

            nfloat parentFrameWidth = _calendarMonthView.Frame.Width;
            int numDaysWide = (int)(parentFrameWidth/ 45.0f);
		    nfloat daysWidth = numDaysWide*45.0f;

			DateTime previousMonth = _currentMonth.AddMonths(-1);
			DateTime nextMonth = _currentMonth.AddMonths(1);
			var daysInPreviousMonth = DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month);
			var daysInMonth = DateTime.DaysInMonth(_currentMonth.Year, _currentMonth.Month);
			weekdayOfFirst = WeekDayIndex(_currentMonth.DayOfWeek);
			var lead = daysInPreviousMonth - (weekdayOfFirst - 1);

			// build last month's days
			for (int i = 1; i <= weekdayOfFirst; i++)
			{
                var viewDay = new DateTime(previousMonth.Year, previousMonth.Month, lead);
				var dayView = new CalendarDayView() { SelectionColor = _calendarMonthView.SelectionColor };
				dayView.Frame = new CGRect((i - 1) * 45, 0, 45, 40);
				dayView.Date = viewDay;
				dayView.Text = lead.ToString();
                dayView.Tag = viewDay.Day;

				AddSubview(dayView);
				DayTiles.Add(dayView);
				lead++;
			}

			var position = weekdayOfFirst+1;
			var line = 0;

			// current month
			for (int i = 1; i <= daysInMonth; i++)
			{
				var viewDay = new DateTime(_currentMonth.Year, _currentMonth.Month, i);
				var dayView = new CalendarDayView
				{
					Frame = new CGRect((position - 1) * 45, line * 40, 45, 40),
					Today = (CurrentDate.Date==viewDay.Date),
					Text = i.ToString(),

					Active = true,
					Tag = i,
					SelectionColor = _calendarMonthView.SelectionColor,
				};
				dayView.Date = viewDay;
				updateDayView(dayView);

				if (dayView.Selected)
					SelectedDayView = dayView;

				AddSubview(dayView);
				DayTiles.Add(dayView);

				position++;
                if (position > numDaysWide)
				{
					position = 1;
					line++;
				}
			}

			//next month
		    if (position != 1)
		    {
		        int dayCounter = 1;
		        for (int i = position; i < numDaysWide; i++)
		        {
                    var viewDay = new DateTime(nextMonth.Year, nextMonth.Month, dayCounter);
		            var dayView = new CalendarDayView
		            {
		                Frame = new CGRect((i - 1)*45, line*40, 45, 40),
		                Text = dayCounter.ToString(),
                        Tag = viewDay.Day,
		                SelectionColor = _calendarMonthView.SelectionColor,
		            };
		            dayView.Date = viewDay;
		            updateDayView(dayView);

		            AddSubview(dayView);
		            DayTiles.Add(dayView);
		            dayCounter++;
		        }
		    }
		    else
		    {
		        line--;
		    }

		    nfloat xPos = Math.Max(0, (float)(parentFrameWidth - daysWidth)/2.0f);
            Frame = new CGRect(new CGPoint(xPos, 0), new CGSize(daysWidth, (line + 1) * 40));

		    Lines = line + 1;
		    Columns = numDaysWide;

			if (SelectedDayView!=null)
				BringSubviewToFront(SelectedDayView);
		}
コード例 #6
0
		public void updateDayView(CalendarDayView dayView)
        {
			dayView.Marked = _calendarMonthView.IsDayMarkedDelegate != null && _calendarMonthView.IsDayMarkedDelegate(dayView.Date);
			dayView.Available = _calendarMonthView.IsDateAvailable == null || _calendarMonthView.IsDateAvailable(dayView.Date);
		}