コード例 #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);
     dayView.Highlighted = _calendarMonthView.HighlightedDaysOfWeek[(int)dayView.Date.DayOfWeek];
 }
コード例 #3
0
		public void BuildGrid ()
		{
			DateTime previousMonth = _currentMonth.AddMonths (-1);
			var daysInPreviousMonth = DateTime.DaysInMonth (previousMonth.Year, previousMonth.Month);
			var daysInMonth = DateTime.DaysInMonth (_currentMonth.Year, _currentMonth.Month);
			weekdayOfFirst = (int)_currentMonth.DayOfWeek;
			var lead = daysInPreviousMonth - (weekdayOfFirst - 1);

			int boxWidth = _calendarMonthView.BoxWidth;
			int boxHeight = _calendarMonthView.BoxHeight;
			
			// build last month's days
			for (int i = 1; i <= weekdayOfFirst; i++)
			{
				var viewDay = new DateTime (_currentMonth.Year, _currentMonth.Month, i);
				var dayView = new CalendarDayView (_calendarMonthView);
				dayView.Frame = new RectangleF ((i - 1) * boxWidth - 1, 0, boxWidth, boxHeight);
				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(_calendarMonthView)
				{
					Frame = new RectangleF((position - 1) * boxWidth - 1, line * boxHeight, boxWidth, boxHeight),
					Today = (CurrentDate.Date==viewDay.Date),
					Text = i.ToString(),
					
					Active = true,
					Tag = i,
					Selected = (viewDay.Date == _calendarMonthView.CurrentSelectedDate.Date)
				};

				dayView.Date = viewDay;
				updateDayView (dayView);
				
				if (dayView.Selected)
					SelectedDayView = dayView;
				
				AddSubview (dayView);
				_dayTiles.Add (dayView);
				
				position++;
				if (position > 7)
				{
					position = 1;
					line++;
				}
			}
			
			//next month
			int dayCounter = 1;
			if (position != 1)
			{
				for (int i = position; i < 8; i++)
				{
					var viewDay = new DateTime (_currentMonth.Year, _currentMonth.Month, i);
					var dayView = new CalendarDayView (_calendarMonthView)
					{
						Frame = new RectangleF((i - 1) * boxWidth -1, line * boxHeight, boxWidth, boxHeight),
						Text = dayCounter.ToString(),
					};
					dayView.Date = viewDay;
					updateDayView (dayView);
					
					AddSubview (dayView);
					_dayTiles.Add (dayView);
					dayCounter++;
				}
			}

			while (line < 6)
			{
				line++;
				for (int i = 1; i < 8; i++)
				{
					var viewDay = new DateTime (_currentMonth.Year, _currentMonth.Month, i);
					var dayView = new CalendarDayView (_calendarMonthView)
					{
						Frame = new RectangleF((i - 1) * boxWidth -1, line * boxHeight, boxWidth, boxHeight),
						Text = dayCounter.ToString(),
					};
					dayView.Date = viewDay;
					updateDayView (dayView);
					
					AddSubview (dayView);
					_dayTiles.Add (dayView);
					dayCounter++;
				}
			}

			Frame = new RectangleF(Frame.Location, new SizeF(Frame.Width, (line + 1) * boxHeight));
			
			Lines = (position == 1 ? line - 1 : line);
			
			if (SelectedDayView!=null)
				this.BringSubviewToFront(SelectedDayView);
		}
コード例 #4
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);
		}
コード例 #5
0
        private bool SelectDayView(UITouch touch)
        {
            var p = touch.LocationInView(this);

            int index = ((int)p.Y / 44) * 7 + ((int)p.X / 46);
            if(index<0 || index >= _dayTiles.Count) return false;

            var newSelectedDayView = _dayTiles[index];
            if (newSelectedDayView == SelectedDayView)
                return false;

            if (!newSelectedDayView.Active && touch.Phase!=UITouchPhase.Moved){
                var day = int.Parse(newSelectedDayView.Text);
                if (day > 15)
                    _calendarMonthView.MoveCalendarMonths(false, true);
                else
                    _calendarMonthView.MoveCalendarMonths(true, true);
                return false;
            } else if (!newSelectedDayView.Active){
                return false;
            }

            SelectedDayView.Selected = false;
            this.BringSubviewToFront(newSelectedDayView);
            newSelectedDayView.Selected = true;

            SelectedDayView = newSelectedDayView;
            SetNeedsDisplay();
            return true;
        }
コード例 #6
0
        public void BuildGrid()
        {
            DateTime previousMonth = _currentMonth.AddMonths(-1);
            var daysInPreviousMonth = DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month);
            var daysInMonth = DateTime.DaysInMonth(_currentMonth.Year, _currentMonth.Month);
            weekdayOfFirst = (int)_currentMonth.DayOfWeek;
            var lead = daysInPreviousMonth - (weekdayOfFirst - 1);

            // build last month's days
            for (int i = 1; i <= weekdayOfFirst; i++)
            {
                var viewDay = new DateTime(_currentMonth.Year, _currentMonth.Month, i);
                var dayView = new CalendarDayView
                {
                    Frame = new RectangleF((i - 1) * 46 - 1, 0, 47, 45),
                    Text = lead.ToString(),
                    Marked = _calendarMonthView.IsDayMarkedDelegate == null ?
                            false : _calendarMonthView.IsDayMarkedDelegate(viewDay),
                };
                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 RectangleF((position - 1) * 46 - 1, line * 44, 47, 45),
                      Today = (_currentDay.Date==viewDay.Date),
                      Text = i.ToString(),
                      Active = true,
                      Tag = i,
                      Marked = _calendarMonthView.IsDayMarkedDelegate == null ?
                            false : _calendarMonthView.IsDayMarkedDelegate(viewDay),
                      Selected = (i == _currentDay.AddDays(1).Day )
                  };

                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(_currentMonth.Year, _currentMonth.Month, i);
                    var dayView = new CalendarDayView
                      {
                          Frame = new RectangleF((i - 1) * 46 -1, line * 44, 47, 45),
                          Text = dayCounter.ToString(),
                          Marked = _calendarMonthView.IsDayMarkedDelegate == null ?
                            false : _calendarMonthView.IsDayMarkedDelegate(viewDay),
                      };
                    AddSubview(dayView);
                    _dayTiles.Add(dayView);
                    dayCounter++;
                }
            }

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

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

            if (SelectedDayView!=null)
                this.BringSubviewToFront(SelectedDayView);
        }
コード例 #7
0
        public void updateDayView(CalendarDayView dayView)
        {
            var dayValue = int.Parse(dayView.Text);

            if (_calendarMonthView.Events.Count (ev => ev.EventDate.Date == dayView.Date.Date && ev.EventDate.Day == dayValue) > 0) {
                dayView.Events = _calendarMonthView.Events.Where(ev => ev.EventDate.Date == dayView.Date).ToList();
                dayView.eventSelected += (evt, rect) => {eventSelected(evt, rect);};
            }
        }
コード例 #8
0
 public void DeselectDayView()
 {
     if (SelectedDayView==null) return;
     SelectedDayView.Selected= false;
     SelectedDayView = null;
     SetNeedsDisplay();
 }
コード例 #9
0
        public void BuildGrid()
        {
            DateTime previousMonth = _currentMonth.AddMonths(-1);
            var daysInPreviousMonth = DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month);
            var daysInMonth = DateTime.DaysInMonth(_currentMonth.Year, _currentMonth.Month);
            weekdayOfFirst = (int)_currentMonth.DayOfWeek;
            var lead = daysInPreviousMonth - (weekdayOfFirst - 1);

            float x, y;

            // build last month's days
            for (int i = 1; i <= weekdayOfFirst; i++)
            {
                var viewDay = new DateTime(_currentMonth.Year, _currentMonth.Month, i);
                var dayView = new CalendarDayView();
                x = (i - 1) * (_calendarMonthView.Container.Width/7) - 1;
                y = 0;
                dayView.Frame = new RectangleF(x, y, _calendarMonthView.Container.Width/7, _calendarMonthView.Container.Height/5);
                dayView.BackgroundColor = UIColor.White;
                dayView.Date = viewDay;
                dayView.Text = lead.ToString();
                dayView.MyLocation = new PointF(x, y);

                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);
                x = (position - 1) * (_calendarMonthView.Container.Width/7) - 1;
                y = line * (_calendarMonthView.Container.Height/5);
                var dayView = new CalendarDayView
                  {
                      Frame = new RectangleF(x, y, _calendarMonthView.Container.Width/7, _calendarMonthView.Container.Height/5),
                      Today = (CurrentDate.Date==viewDay.Date),
                      Text = i.ToString(),
                      BackgroundColor = UIColor.White,
                      Active = true,
                      Tag = i,
                      Selected = (i == CurrentDate.AddDays(1).Day ),
                      MyLocation = new PointF(x, y)
                  };

                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++)
                {
                    x = (i - 1) * ((_calendarMonthView.Container.Width/7) -1);
                    y = line * (_calendarMonthView.Container.Height/5);
                    var viewDay = new DateTime(_currentMonth.Year, _currentMonth.Month, i);
                    var dayView = new CalendarDayView
                      {
                          Frame = new RectangleF(x, y, _calendarMonthView.Container.Width/7, _calendarMonthView.Container.Height/5),
                          Text = dayCounter.ToString(),
                          BackgroundColor = UIColor.White,
                          MyLocation = new PointF(x, y)
                      };
                    dayView.Date = viewDay;
                    //updateDayView(dayView);

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

            Frame = new RectangleF(Frame.Location, new SizeF(Frame.Width, (line + 1) * (_calendarMonthView.Container.Height/5)));

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

            if (SelectedDayView!=null)
                this.BringSubviewToFront(SelectedDayView);
        }
コード例 #10
0
        public void BuildGrid()
        {
            //DateTime dt = DateTime.Now;
            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);
            var      firstDayOfWeek      = (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;

            weekdayOfFirst = (int)_currentMonth.DayOfWeek;
            //var lead = daysInPreviousMonth  - ((weekdayOfFirst+firstDayOfWeek) - 1);

            int boxWidth  = _calendarMonthView.BoxWidth;
            int boxHeight = _calendarMonthView.BoxHeight;

            var numberOfLastMonthDays = (weekdayOfFirst - firstDayOfWeek);

            if (numberOfLastMonthDays < 0)
            {
                numberOfLastMonthDays = 7 - (weekdayOfFirst + firstDayOfWeek);
            }
            var lead = daysInPreviousMonth - numberOfLastMonthDays + 1;

            // build last month's days
            for (int i = 1; i <= numberOfLastMonthDays; i++)
            {
                var viewDay = new DateTime(previousMonth.Year, previousMonth.Month, lead);
                var dayView = new CalendarDayView(_calendarMonthView);
                dayView.Frame = new RectangleF((i - 1) * boxWidth, 0, boxWidth, boxHeight);
                dayView.Date  = viewDay;
                dayView.Text  = lead.ToString();
                updateDayView(dayView);
                AddSubview(dayView);
                _dayTiles.Add(dayView);
                lead++;
            }

            var position = weekdayOfFirst - firstDayOfWeek + 1;

            if (position == 0)
            {
                position = 7;
            }
            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(_calendarMonthView)
                {
                    Frame = new RectangleF((position - 1) * boxWidth, line * boxHeight, boxWidth, boxHeight),
                    Today = (CurrentDate.Date == viewDay.Date),
                    Text  = i.ToString(),

                    Active   = true,
                    Tag      = i,
                    Selected = (viewDay.Date == _calendarMonthView.CurrentSelectedDate.Date)
                };

                dayView.Date = viewDay;
                updateDayView(dayView);

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

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

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

            //next month
            int dayCounter = 1;

            if (position != 1)
            {
                for (int i = position; i < 8; i++)
                {
                    var viewDay = new DateTime(nextMonth.Year, nextMonth.Month, dayCounter);
                    var dayView = new CalendarDayView(_calendarMonthView)
                    {
                        Frame = new RectangleF((i - 1) * boxWidth, line * boxHeight, boxWidth, boxHeight),
                        Text  = dayCounter.ToString(),
                    };
                    dayView.Date = viewDay;
                    updateDayView(dayView);

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

//Why to add unnecesarry unclickable dates of next month?
//			while (line < 5)
//			{
//				line++;
//				for (int i = 1; i < 8; i++)
//				{
//					var viewDay = new DateTime (_currentMonth.Year, _currentMonth.Month, i);
//					var dayView = new CalendarDayView (_calendarMonthView)
//					{
//						Frame = new RectangleF((i - 1) * boxWidth -1, line * boxHeight, boxWidth, boxHeight),
//						Text = dayCounter.ToString(),
//					};
//					dayView.Date = viewDay;
//					updateDayView (dayView);
//
//					AddSubview (dayView);
//					_dayTiles.Add (dayView);
//					dayCounter++;
//				}
//			}

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

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

            if (SelectedDayView != null)
            {
                this.BringSubviewToFront(SelectedDayView);
            }
            //Console.WriteLine("Building the grid took {0} msecs",(DateTime.Now-dt).TotalMilliseconds);
        }