예제 #1
0
        private void LoadInitialGrids()
        {
            _monthGridView = CreateNewGrid(CurrentMonthYear);

            var rect = _scrollView.Frame;

                        #if __UNIFIED__
            rect.Size = new CoreGraphics.CGSize {
                Height = MainViewSize.Height - HeaderViewSize.Height, Width = MainViewSize.Width
            };
                        #else
            rect.Size = new SizeF {
                Height = MainViewSize.Height - HeaderViewSize.Height, Width = MainViewSize.Width
            };
                        #endif

            _scrollView.Frame = rect;
        }
예제 #2
0
        /// <summary>
        /// Gos to the specified date date.
        /// </summary>
        /// <param name="targetDate">Target date.</param>
        public void GoToDate(DateTime targetDate)
        {
            if (_monthGridView == null)
            {
                return;
            }

            bool upwards = targetDate >= CurrentMonthYear;

            SelectedDate     = targetDate.Date;
            CurrentMonthYear = new DateTime(targetDate.Year, targetDate.Month, 1);

            UserInteractionEnabled = false;

            // Dispatch event
            if (MonthChanged != null)
            {
                MonthChanged(CurrentMonthYear);
            }

            var gridToMove   = CreateNewGrid(CurrentMonthYear);
            var pointsToMove = (upwards? 0 + _monthGridView.Lines : 0 - _monthGridView.Lines) * DayCellHeight;

            if (upwards && gridToMove.weekdayOfFirst == 0)
            {
                pointsToMove += DayCellHeight;
            }
            if (!upwards && _monthGridView.weekdayOfFirst == 0)
            {
                pointsToMove -= DayCellHeight;
            }

                        #if __UNIFIED__
            gridToMove.Frame = new CoreGraphics.CGRect(new CoreGraphics.CGPoint(0, pointsToMove), gridToMove.Frame.Size);
                        #else
            gridToMove.Frame = new RectangleF(new PointF(0, pointsToMove), gridToMove.Frame.Size);
                        #endif

            _scrollView.AddSubview(gridToMove);

                        #if __UNIFIED__
            _monthGridView.Center = new CoreGraphics.CGPoint(_monthGridView.Center.X, _monthGridView.Center.Y - pointsToMove);
            gridToMove.Center     = new CoreGraphics.CGPoint(gridToMove.Center.X, gridToMove.Center.Y - pointsToMove);

            _scrollView.Frame = new CoreGraphics.CGRect(
                _scrollView.Frame.Location,
                new CoreGraphics.CGSize(_scrollView.Frame.Width, (gridToMove.Lines) * DayCellHeight));
                        #else
            _monthGridView.Center = new PointF(_monthGridView.Center.X, _monthGridView.Center.Y - pointsToMove);
            gridToMove.Center     = new PointF(gridToMove.Center.X, gridToMove.Center.Y - pointsToMove);

            _scrollView.Frame = new RectangleF(
                _scrollView.Frame.Location,
                new SizeF(_scrollView.Frame.Width, (gridToMove.Lines) * DayCellHeight));
                        #endif

            _monthGridView.Alpha = 0;

            _scrollView.ContentSize = _scrollView.Frame.Size;
            SetNeedsDisplay();

            _monthGridView = gridToMove;

            UserInteractionEnabled = true;

            AdjustBackgroundColor();
        }
예제 #3
0
        /// <summary>
        /// Moves the calendar months.
        /// </summary>
        /// <param name="upwards">If set to <c>true</c> moves the month upwards.</param>
        /// <param name="animated">If set to <c>true</c> the transition will be animated.</param>
        public void MoveCalendarMonths(bool upwards, bool animated)
        {
            if (_monthGridView == null)
            {
                return;
            }

            CurrentMonthYear       = CurrentMonthYear.AddMonths(upwards? 1 : -1);
            UserInteractionEnabled = false;

            // Dispatch event
            if (MonthChanged != null)
            {
                MonthChanged(CurrentMonthYear);
            }

            var gridToMove   = CreateNewGrid(CurrentMonthYear);
            var pointsToMove = (upwards? 0 + _monthGridView.Lines : 0 - _monthGridView.Lines) * DayCellHeight;

            if (upwards && gridToMove.weekdayOfFirst == 0)
            {
                pointsToMove += DayCellHeight;
            }
            if (!upwards && _monthGridView.weekdayOfFirst == 0)
            {
                pointsToMove -= DayCellHeight;
            }

                        #if __UNIFIED__
            gridToMove.Frame = new CoreGraphics.CGRect(new CoreGraphics.CGPoint(0, pointsToMove), gridToMove.Frame.Size);
                        #else
            gridToMove.Frame = new RectangleF(new PointF(0, pointsToMove), gridToMove.Frame.Size);
                        #endif

            _scrollView.AddSubview(gridToMove);

            if (animated)
            {
                UIView.BeginAnimations("changeMonth");
                UIView.SetAnimationDuration(0.4);
                UIView.SetAnimationDelay(0.1);
                UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut);
            }

            _monthGridView.Alpha = 0;

                        #if __UNIFIED__
            _monthGridView.Center = new CoreGraphics.CGPoint(_monthGridView.Center.X, _monthGridView.Center.Y - pointsToMove);
            gridToMove.Center     = new CoreGraphics.CGPoint(gridToMove.Center.X, gridToMove.Center.Y - pointsToMove);

            _scrollView.Frame = new CoreGraphics.CGRect(
                _scrollView.Frame.Location,
                new CoreGraphics.CGSize(_scrollView.Frame.Width, (gridToMove.Lines) * DayCellHeight));
                        #else
            _monthGridView.Center = new PointF(_monthGridView.Center.X, _monthGridView.Center.Y - pointsToMove);
            gridToMove.Center     = new PointF(gridToMove.Center.X, gridToMove.Center.Y - pointsToMove);

            _scrollView.Frame = new RectangleF(
                _scrollView.Frame.Location,
                new SizeF(_scrollView.Frame.Width, (gridToMove.Lines) * DayCellHeight));
                        #endif

            _scrollView.ContentSize = _scrollView.Frame.Size;
            SetNeedsDisplay();

            if (animated)
            {
                UIView.CommitAnimations();
            }

            _monthGridView = gridToMove;

            UserInteractionEnabled = true;

            AdjustBackgroundColor();
        }