Esempio n. 1
0
        void RecalculatePositionsAndScroll()
        {
            _updateScrollPosition = new Point((int)_scrollingService.ScrollPositionX, (int)_scrollingService.ScrollPositionY);
            Point position = new Point(-_updateScrollPosition.X, -_updateScrollPosition.Y);

            for (int idx = 0; idx < _itemViews.Count; ++idx)
            {
                UiView view = _itemViews[idx];

                bool      shouldRecalc = view.ShouldRecalc(false, false);
                Rectangle bounds       = shouldRecalc ? CalculateItemBounds(view) : view.Bounds;

                Point size = bounds.Size;

                if (_vertical)
                {
                    bounds.Height = size.Y;
                    bounds.Y      = position.Y + view.PositionParameters.Margin.Top;

                    position.Y = bounds.Bottom + view.PositionParameters.Margin.Bottom;
                }
                else
                {
                    bounds.Width = size.X;
                    bounds.X     = position.X + view.PositionParameters.Margin.Left;

                    position.X = bounds.Right + view.PositionParameters.Margin.Right;
                }

                if (shouldRecalc)
                {
                    view.Bounds = bounds;
                    view.ViewUpdate(0);
                }
                else
                {
                    Point offset = bounds.Location - view.Bounds.Location;
                    view.Move(offset);
                }

                _maxScroll = new Point(_updateScrollPosition.X + position.X, _updateScrollPosition.Y + position.Y);
            }
        }