MoveCalendarMonths() public method

public MoveCalendarMonths ( bool right, bool animated ) : void
right bool
animated bool
return void
Example #1
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 && !newSelectedDayView.Available)
            {
                return(false);
            }

            if (SelectedDayView != null)
            {
                SelectedDayView.Selected = false;
            }

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

            SelectedDayView = newSelectedDayView;
            SetNeedsDisplay();
            return(true);
        }
        /*public override void TouchesBegan (NSSet touches, UIEvent evt)
         * {
         *      base.TouchesBegan (touches, evt);
         *      if (SelectDayView((UITouch)touches.AnyObject)&& _calendarMonthView.OnDateSelected!=null)
         *              _calendarMonthView.OnDateSelected(new DateTime(_currentMonth.Year, _currentMonth.Month, SelectedDayView.Tag));
         * }
         *
         * public override void TouchesMoved (NSSet touches, UIEvent evt)
         * {
         *      base.TouchesMoved (touches, evt);
         *      if (SelectDayView((UITouch)touches.AnyObject)&& _calendarMonthView.OnDateSelected!=null)
         *              _calendarMonthView.OnDateSelected(new DateTime(_currentMonth.Year, _currentMonth.Month, SelectedDayView.Tag));
         * }
         *
         * public override void TouchesEnded (NSSet touches, UIEvent evt)
         * {
         *      base.TouchesEnded (touches, evt);
         *      if (_calendarMonthView.OnFinishedDateSelection==null) return;
         *      var date = new DateTime(_currentMonth.Year, _currentMonth.Month, SelectedDayView.Tag);
         *      if (_calendarMonthView.IsDateAvailable == null || _calendarMonthView.IsDateAvailable(date))
         *              _calendarMonthView.OnFinishedDateSelection(date);
         * }*/

        private bool SelectDayView(PointF p)
        {
            int index = ((int)p.Y / _calendarMonthView.BoxHeight) * 7 + ((int)p.X / _calendarMonthView.BoxWidth);

            if (index < 0 || index >= _dayTiles.Count)
            {
                return(false);
            }

            var newSelectedDayView = _dayTiles[index];

            if (newSelectedDayView == SelectedDayView)
            {
                return(false);
            }

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

            if (SelectedDayView != null)
            {
                SelectedDayView.Selected = false;
            }

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

            SelectedDayView = newSelectedDayView;
            _calendarMonthView.CurrentSelectedDate = SelectedDayView.Date;
            SetNeedsDisplay();
            return(true);
        }