Exemplo n.º 1
0
        private void MeasureForward(ref MeasureContext context)
        {
            var firstContainerDesiredSize = new RadSize();
            var lastContainerDesiredSize  = new RadSize();

            using (var itemInfos = this.layout.GetLines(context.FirstVisibleIndex, true).GetEnumerator())
            {
                if (itemInfos.MoveNext())
                {
                    firstContainerDesiredSize       = this.GenerateContainer(itemInfos.Current);
                    context.ForwardGeneratedLength += context.GetLength(firstContainerDesiredSize);
                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(firstContainerDesiredSize));

                    // Take the length portion of the indexed element that is not currently in viewport.
                    this.HiddenPixels = GridModel.DoubleArithmetics.Floor(context.GetLength(firstContainerDesiredSize) * (context.Index % 1));
                    context.ForwardGeneratedLength -= this.HiddenPixels;

                    context.ForwardGeneratedLength = GridModel.DoubleArithmetics.Ceiling(context.ForwardGeneratedLength);
                    lastContainerDesiredSize       = firstContainerDesiredSize;

                    this.ViewportItemCount++;
                }

                while (GridModel.DoubleArithmetics.IsLessThan(context.ForwardGeneratedLength, context.AvailableLength) && itemInfos.MoveNext())
                {
                    context.LastVisibleIndex++;
                    lastContainerDesiredSize        = this.GenerateContainer(itemInfos.Current);
                    context.ForwardGeneratedLength += context.GetLength(lastContainerDesiredSize);
                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(lastContainerDesiredSize));

                    this.ViewportItemCount++;
                }
            }
        }
Exemplo n.º 2
0
        private MeasureContext MeasureHorizontalFrozenElements(RadSize availableSize, int frozenContainersCount)
        {
            var context = new MeasureContext();

            context.InitializeForHorizontalMeasure(this, availableSize);

            if (frozenContainersCount == 0)
            {
                return(context);
            }

            var firstContainerDesiredSize = new RadSize();
            var lastContainerDesiredSize  = new RadSize();

            using (var itemInfos = this.layout.GetLines(context.FirstVisibleIndex, true).GetEnumerator())
            {
                if (itemInfos.MoveNext())
                {
                    firstContainerDesiredSize      = this.GenerateContainer(itemInfos.Current);
                    context.ForwardGeneratedLength = context.GetLength(firstContainerDesiredSize);
                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(firstContainerDesiredSize));

                    // Take the length portion of the indexed element that is not currently in viewport.
                    this.HiddenPixels = GridModel.DoubleArithmetics.Floor(context.ForwardGeneratedLength * (context.Index % 1));
                    context.ForwardGeneratedLength -= this.HiddenPixels;

                    context.ForwardGeneratedLength = GridModel.DoubleArithmetics.Ceiling(context.ForwardGeneratedLength);
                    lastContainerDesiredSize       = firstContainerDesiredSize;

                    this.ViewportItemCount++;
                }

                while (frozenContainersCount - 1 > context.LastVisibleIndex && GridModel.DoubleArithmetics.IsLessThan(context.ForwardGeneratedLength, context.AvailableLength) && itemInfos.MoveNext())
                {
                    context.LastVisibleIndex++;
                    lastContainerDesiredSize        = this.GenerateContainer(itemInfos.Current);
                    context.ForwardGeneratedLength += context.GetLength(lastContainerDesiredSize);
                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(lastContainerDesiredSize));

                    this.ViewportItemCount++;
                }
            }

            return(context);
        }
Exemplo n.º 3
0
        private void MeasureBackwards(ref MeasureContext context)
        {
            if (context.AvailableLength - context.ForwardGeneratedLength > GridModel.DoubleArithmetics.Ceiling(1d / IndexStorage.PrecisionMultiplier))
            {
                if (context.FirstVisibleIndex + this.ViewportItemCount < this.layout.VisibleLineCount)
                {
                    var firstContainerDesiredSize = new RadSize();
                    using (var itemInfos = this.layout.GetLines(context.FirstVisibleIndex - 1, false).GetEnumerator())
                    {
                        while (GridModel.DoubleArithmetics.IsLessThan(context.GeneratedLength, context.AvailableLength) && itemInfos.MoveNext())
                        {
                            context.FirstVisibleIndex--;
                            firstContainerDesiredSize        = this.GenerateContainer(itemInfos.Current);
                            context.BackwardGeneratedLength += context.GetLength(firstContainerDesiredSize);
                            context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(firstContainerDesiredSize));

                            this.ViewportItemCount++;
                        }
                    }
                }
            }
        }