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; }
/// <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(); }
/// <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(); }
private MonthGridView CreateNewGrid(DateTime date){ var grid = new MonthGridView(this, date); grid.CurrentDate = CurrentDate; grid.BuildGrid(); grid.Frame = MainViewSize; return grid; }
/// <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 (); }
/// <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 (); }
private MonthGridView CreateNewGrid(DateTime date){ var grid = new MonthGridView(this, date); grid.CurrentDate = CurrentDate; return grid; }
public void MoveCalendarMonths(bool upwards, bool animated) { var oldMonthYear = CurrentMonthYear; CurrentMonthYear = CurrentMonthYear.AddMonths(upwards? 1 : -1); // Dispatch event if (MonthChanged != null) MonthChanged(oldMonthYear, CurrentMonthYear); nfloat yOffset = (upwards ? _monthGridView.Frame.Height : -_monthGridView.Frame.Height); var gridToMove = CreateNewGrid(CurrentMonthYear); gridToMove.BuildGrid(); gridToMove.Frame = new CGRect(gridToMove.Frame.X, gridToMove.Frame.Y + yOffset, gridToMove.Frame.Width, gridToMove.Frame.Height); ScrollView.AddSubview(gridToMove); Animate(0.4f, 0.0f, UIViewAnimationOptions.CurveEaseInOut, () => { _monthGridView.Center = new CGPoint(_monthGridView.Center.X, _monthGridView.Center.Y - yOffset); _monthGridView.Alpha = 0; gridToMove.Center = new CGPoint(gridToMove.Center.X, gridToMove.Center.Y - yOffset); }, () => { _monthGridView.RemoveFromSuperview(); _monthGridView = gridToMove; SetNeedsDisplay(); }); }
public override void LayoutSubviews () { base.LayoutSubviews(); if (!_calendarIsLoaded) { ScrollView = new UIScrollView(new CGRect(0, 44, Frame.Width, Frame.Height - 44)) { ContentSize = new CGSize(Frame.Width, Frame.Height - 44), //ScrollEnabled = false, //Frame = new RectangleF(0, 44, Frame.Width, Frame.Height - 44), BackgroundColor = UIColor.White, }; LoadButtons(); _monthGridView = CreateNewGrid(CurrentMonthYear); AddSubview(ScrollView); ScrollView.AddSubview(_monthGridView); _calendarIsLoaded = true; } _leftButton.Frame = new CGRect(10, 0, 32, 32); _rightButton.Frame = new CGRect(Frame.Right - 56, 0, 32, 32); _monthGridView.RebuildGrid(); ScrollView.Frame = new CGRect(0, 44, Frame.Width, _monthGridView.Frame.Height); ScrollView.ContentSize = _monthGridView.Frame.Size; InvalidateIntrinsicContentSize(); SetNeedsDisplay(); }