コード例 #1
0
        private void changeStartTime(CGPoint point)
        {
            if (!isActive || itemIndexPath == null)
            {
                return;
            }

            if (point.Y < 0 || point.Y >= Layout.ContentViewHeight)
            {
                return;
            }

            LastPoint = point;
            var now = timeService.CurrentDateTime;

            var newStartTime = NewStartTimeWithDynamicDuration(point, allItemsStartAndEndTime);

            var newDuration = calendarItem.Duration.HasValue ? calendarItem.EndTime(now) - newStartTime : null as TimeSpan?;

            if (newDuration != null && newDuration <= TimeSpan.Zero ||
                newDuration == null && newStartTime > now)
            {
                return;
            }

            calendarItem = calendarItem
                           .WithStartTime(newStartTime)
                           .WithDuration(newDuration);

            itemIndexPath = dataSource.UpdateItemView(itemIndexPath, calendarItem.StartTime, calendarItem.Duration(now));

            if (previousStartTime != newStartTime)
            {
                selectionFeedback.SelectionChanged();
                previousStartTime = newStartTime;
            }

            if (point.Y < TopAutoScrollLine && !CollectionView.IsAtTop())
            {
                StartAutoScrollUp(changeStartTime);
            }
            else if (point.Y > BottomAutoScrollLine && calendarItem.Duration > defaultDuration)
            {
                StartAutoScrolDown(changeStartTime);
            }
            else
            {
                StopAutoScroll();
            }
        }
コード例 #2
0
        private void changeOffset(CGPoint point)
        {
            if (!isActive || itemIndexPath == null)
            {
                return;
            }

            var currentPointWithOffest = new CGPoint(point.X, point.Y - verticalOffset);

            var newStartTime = NewStartTimeWithStaticDuration(currentPointWithOffest, allItemsStartAndEndTime, calendarItem.Duration);

            LastPoint = point;
            var now = timeService.CurrentDateTime;

            if (newStartTime + calendarItem.Duration > newStartTime.Date.AddDays(1))
            {
                return;
            }

            calendarItem = calendarItem
                           .WithStartTime(newStartTime);

            itemIndexPath = dataSource.UpdateItemView(itemIndexPath, calendarItem.StartTime, calendarItem.Duration(now));

            if (previousStartTime != newStartTime)
            {
                selectionFeedback.SelectionChanged();
                previousStartTime = newStartTime;
            }

            var topY    = Layout.PointAtDate(calendarItem.StartTime).Y;
            var bottomY = Layout.PointAtDate(calendarItem.EndTime(now)).Y;

            if (topY < TopAutoScrollLine && !CollectionView.IsAtTop() && didDragUp)
            {
                StartAutoScrollUp(changeOffset);
            }
            else if (bottomY > BottomAutoScrollLine && !CollectionView.IsAtBottom() && didDragDown)
            {
                StartAutoScrolDown(changeOffset);
            }
            else
            {
                StopAutoScroll();
            }
        }