internal override RadSize GenerateContainer(IList <ItemInfo> itemInfos, BaseLayoutStrategy.MeasureContext context) { int slot = itemInfos.Last().Slot; List <GeneratedItemModel> decorators; if (!this.generatedContainers.TryGetValue(slot, out decorators)) { decorators = new List <GeneratedItemModel>(); this.generatedContainers[slot] = decorators; } else { return(RadSize.Empty); } for (int i = 0; i < itemInfos.Count; i++) { var itemInfo = itemInfos[i]; if (itemInfo.IsDisplayed || itemInfo.IsSummaryVisible) { GeneratedItemModel decorator = this.GetPreviouslyVisibleDecorator(itemInfo.Item); // Recycle cells on this slot if container is Collasped/Expanded. if (decorator != null && (decorator.ItemInfo.IsCollapsed != itemInfo.IsCollapsed)) { this.Generator.RecycleDecorator(decorator); decorator = null; } if (decorator == null) { decorator = this.GenerateAndPrepareContainer(ref itemInfo); } decorator.ItemInfo = itemInfo; decorators.Add(decorator); } } double largestLength = 0; double cumulativeStackLength = 0; foreach (var decorator in decorators) { var desiredSize = this.Owner.Measure(decorator, this.GetContainerAvailableSize(decorator.ItemInfo)); double scrollLength; if (this.IsHorizontal) { cumulativeStackLength += desiredSize.Height; scrollLength = desiredSize.Width; } else { cumulativeStackLength += desiredSize.Width; scrollLength = desiredSize.Height; } largestLength = Math.Max(largestLength, scrollLength); this.Layout.UpdateSlotLength(decorator.ItemInfo.Slot, largestLength); this.layout.ColumnRenderInfo.Update(decorator.ItemInfo.Id, largestLength); } this.UpdateAverageContainerLength(largestLength); if (this.IsHorizontal) { return(new RadSize(largestLength, cumulativeStackLength)); } else { return(new RadSize(cumulativeStackLength, largestLength)); } }
private void Recycle(GeneratedItemModel decorator) { this.Generator.RecycleDecorator(decorator); }
internal override RadSize GenerateContainer(IList <ItemInfo> itemInfos, MeasureContext context) { int startColumnId = -1; int slot = itemInfos.Last().Slot; int lastProjectedId = this.layout.GetLastProjectedId(slot); List <GeneratedItemModel> decorators; if (!this.generatedContainers.TryGetValue(slot, out decorators)) { decorators = new List <GeneratedItemModel>(); this.generatedContainers[slot] = decorators; } double oppositeAvalilableLength = this.IsHorizontal ? this.AvailableSize.Height : this.AvailableSize.Width; double largestLength = 0; double cumulativeOppositeScrollLength = 0; int lastRealizedId = -1; for (int i = 0; i < itemInfos.Count; i++) { var itemInfo = itemInfos[i]; // Check if item is realized from previous row. if (this.generatedContainerItems.Contains(itemInfo.Item)) { continue; } if (itemInfo.IsDisplayed || itemInfo.IsSummaryVisible) { if (cumulativeOppositeScrollLength + this.ItemWidth > context.OppositeAvailableLength) { break; } if (startColumnId == -1) { startColumnId = itemInfo.Id; } GeneratedItemModel decorator = this.GetPreviouslyVisibleDecorator(itemInfo.Item); // Recycle cells on this slot if container is Collasped/Expanded. if (decorator != null && (decorator.ItemInfo.IsCollapsed != itemInfo.IsCollapsed)) { this.Generator.RecycleDecorator(decorator); decorator = null; } if (decorator == null) { decorator = this.GenerateAndPrepareContainer(ref itemInfo); } decorator.ItemInfo = itemInfo; decorators.Add(decorator); this.generatedContainerItems.Add(itemInfo.Item); var desiredSize = this.Owner.Measure(decorator, this.GetContainerAvailableSize(decorator.ItemInfo)); decorator.DesiredSize = desiredSize; double length; double oppositeLength = 0; if (this.IsHorizontal) { var actualItemlength = this.ItemWidth > 0 ? this.ItemWidth : desiredSize.Height; oppositeLength = decorator.ItemInfo.Item is Telerik.Data.Core.IGroup ? oppositeAvalilableLength : actualItemlength; // TODO replace this with desired size. cumulativeOppositeScrollLength += oppositeLength; length = desiredSize.Width; } else { var actualItemlength = this.ItemWidth > 0 ? this.ItemWidth : desiredSize.Width; oppositeLength = decorator.ItemInfo.Item is Telerik.Data.Core.IGroup ? oppositeAvalilableLength : actualItemlength; cumulativeOppositeScrollLength += oppositeLength; length = desiredSize.Height; } largestLength = Math.Max(largestLength, length); this.layout.UpdateSlotLength(decorator.ItemInfo.Slot, largestLength); this.layout.ColumnSlotsRenderInfo.Update(decorator.ItemInfo.Id, oppositeLength); if (cumulativeOppositeScrollLength > context.OppositeAvailableLength && Math.Abs(cumulativeOppositeScrollLength - context.OppositeAvailableLength) > 1) { this.RecycleLocallyContainer(decorator); this.generatedContainerItems.Remove(decorator.ItemInfo.Item); break; } lastRealizedId = decorator.ItemInfo.Id; } } if (lastRealizedId >= 0) { this.layout.EndSlotMeasure(slot, startColumnId, lastProjectedId, lastRealizedId); } for (int i = 0; i < itemInfos.Count; i++) { this.UpdateFrozenContainerInfos(itemInfos[i]); } if (this.IsHorizontal) { return(new RadSize(largestLength, cumulativeOppositeScrollLength)); } else { return(new RadSize(cumulativeOppositeScrollLength, largestLength)); } }
internal virtual void RecycleAnimatedDecorator(GeneratedItemModel decorator) { this.Generator.RecycleAnimatedDecorator(decorator); }