コード例 #1
0
        public override int CalculateAppendedSlotsCount(BaseLayout layout, int startSlot, ref int totalLines)
        {
            if (layout == null || layout.ItemsSource == null)
            {
                return(startSlot);
            }

            int levels     = layout.GroupLevels;
            int slotsCount = startSlot;

            bool shouldIndexItem = false;

            foreach (var item in layout.ItemsSource)
            {
                int childrenCount = layout.CountAndPopulateTables(item, slotsCount, 0, levels, null, shouldIndexItem, null, ref totalLines);
                shouldIndexItem = shouldIndexItem || childrenCount > 1;
                slotsCount     += childrenCount;
            }

            if (layout.GroupLevels == 0)
            {
                slotsCount = layout.ItemsSource.Count;
                totalLines = layout.CalculateFlatRowCount();
            }

            return(slotsCount);
        }
コード例 #2
0
        public override int CalculateAppendedSlotsCount(BaseLayout layout, int startSlot)
        {
            var compactLayout = layout as CompactLayout;

            if (compactLayout == null)
            {
                this.slotsToBuild = new Range <bool>(startSlot, startSlot, true);
                return(startSlot);
            }

            int levels     = compactLayout.GroupLevels;
            int slotsCount = startSlot;

            bool shouldIndexItem = false;

            foreach (var item in compactLayout.ItemsSource)
            {
                int childrenCount = compactLayout.CountAndPopulateTables(item, slotsCount, 0, levels, null, shouldIndexItem, null);
                shouldIndexItem = shouldIndexItem || childrenCount > 1;
                slotsCount     += childrenCount;
            }

            if (compactLayout.GroupLevels == 0)
            {
                slotsCount = compactLayout.ItemsSource.Count;
            }

            this.slotsToBuild = new Range <bool>(startSlot, slotsCount, true);

            return(slotsCount);
        }
コード例 #3
0
        private IList <ItemInfo> GetPlaceholderSlot(BaseLayout layout, int visibleLine)
        {
            var itemInfo = new ItemInfo();

            itemInfo.IsDisplayed = true;

            itemInfo.Item  = this.Placeholder;
            itemInfo.Level = 0;
            itemInfo.Id    = 0;
            itemInfo.Slot  = itemInfo.Id;

            itemInfo.IsCollapsible    = false;
            itemInfo.IsCollapsed      = false;
            itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
            itemInfo.IsSummaryVisible = false;

            LayoutInfo info = new LayoutInfo();

            //  info.Indent = this.GetIndent(itemInfo, parentGroupInfo);
            info.Indent            = 0;
            info.Line              = visibleLine;
            info.ChildLine         = visibleLine;
            info.LineSpan          = 1;
            info.LevelSpan         = 1;
            info.SpansThroughCells = true;
            info.Level             = 0;

            itemInfo.LayoutInfo = info;

            return(new List <ItemInfo> {
                itemInfo
            });
        }
コード例 #4
0
        public override IList <ItemInfo> BuildItemInfos(BaseLayout layout, int visibleLine, int slot)
        {
            if (slot >= 0 && slot < layout.TotalSlotCount && visibleLine < layout.VisibleLineCount)
            {
                return(layout.GetItemInfosAtSlot(visibleLine, slot));
            }

            return(new List <ItemInfo>());
        }
コード例 #5
0
        public override IList <ItemInfo> BuildItemInfos(BaseLayout layout, int visibleLine, int slot)
        {
            if (visibleLine == 0 && layout != null)
            {
                return(this.GetPlaceholderSlot(layout, visibleLine));
            }

            return(new List <ItemInfo>());
        }
コード例 #6
0
        public override IList <ItemInfo> BuildItemInfos(BaseLayout layout, int visibleLine, int slot)
        {
            var compactLayout = layout as CompactLayout;

            if (visibleLine == layout.VisibleLineCount - 1 && compactLayout != null)
            {
                return(PlaceholderStrategy.GetPlaceholderSlot(compactLayout, visibleLine));
            }

            return(new List <ItemInfo>());
        }
コード例 #7
0
        public override int CalculateAppendedSlotsCount(BaseLayout layout, int startSlot, ref int totalLines)
        {
            int slot = startSlot;

            if (layout.ItemsSource != null)
            {
                slot = layout.ItemsSource.Count;
            }

            totalLines = slot;
            return(slot);
        }
コード例 #8
0
        public override IList <ItemInfo> BuildItemInfos(BaseLayout layout, int visibleLine, int slot)
        {
            var compactLayout = layout as CompactLayout;

            if (slot >= 0 && slot < layout.TotalLineCount && visibleLine < layout.VisibleLineCount && compactLayout != null &&
                slot < this.slotsToBuild.UpperBound && slot >= this.slotsToBuild.LowerBound)
            {
                return(compactLayout.GetItemInfosAtSlot(visibleLine, slot));
            }

            return(new List <ItemInfo>());
        }
コード例 #9
0
        internal override IList <ItemInfo> GetItemInfosAtSlot(int visibleLine, int rowSlot)
        {
            if (this.ItemsSource == null || visibleLine > this.VisibleLineCount - 1)
            {
                return(new List <ItemInfo>());
            }

            var paddingOffset = this.paddingRenderInfo != null && visibleLine > 0 ? Math.Max(0, this.paddingRenderInfo.OffsetFromIndex(visibleLine - 1)) : 0;
            var startOffset   = Math.Max(0, this.availableOppositeLength * visibleLine) - paddingOffset;
            var columnSlot    = startOffset > 0 ? this.ColumnSlotsRenderInfo.IndexFromOffset(startOffset) + 1 : 0;

            List <ItemInfo> items = new List <ItemInfo>();

            if (this.TryGetGroupedItemsAtColumnSlot(visibleLine, rowSlot, columnSlot, ref items))
            {
                return(items);
            }
            else
            {
                double   itemsWidth = 0;
                ItemInfo itemInfo   = new ItemInfo();
                itemInfo.IsDisplayed = true;

                // Add buffered items in case the projected items cannot fill the viewport.
                var avalaibleLength = 2 * this.availableOppositeLength;

                while (itemsWidth < avalaibleLength && columnSlot < this.ColumnSlotsRenderInfo.Count && visibleLine < this.VisibleLineCount)
                {
                    itemInfo.Item = this.ItemsSource[columnSlot];
                    itemInfo.Id   = columnSlot;
                    itemInfo.Slot = rowSlot;

                    itemInfo.IsCollapsible = false;
                    itemInfo.IsCollapsed   = false;
                    itemInfo.ItemType      = BaseLayout.GetItemType(itemInfo.Item);

                    itemsWidth += this.ColumnSlotsRenderInfo.ValueForIndex(columnSlot);
                    columnSlot++;

                    items.Add(itemInfo);
                }
                return(items);
            }
        }
コード例 #10
0
        protected virtual IList <ItemInfo> GetPlaceholderSlot(BaseLayout layout, int visibleLine, bool isDisplayed = true)
        {
            var itemInfo = new ItemInfo();

            itemInfo.IsDisplayed = isDisplayed;

            itemInfo.Item  = this.Placeholder;
            itemInfo.Level = 0;
            itemInfo.Id    = layout.TotalSlotCount - 1;
            itemInfo.Slot  = itemInfo.Id;

            itemInfo.IsCollapsible    = false;
            itemInfo.IsCollapsed      = false;
            itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
            itemInfo.IsSummaryVisible = false;

            return(new List <ItemInfo> {
                itemInfo
            });
        }
コード例 #11
0
        private static IList <ItemInfo> GetPlaceholderSlot(CompactLayout layout, int visibleLine)
        {
            var itemInfo = new ItemInfo();

            itemInfo.IsDisplayed = true;

            itemInfo.Item  = PlaceholderInfo.Empty;
            itemInfo.Level = 0;
            itemInfo.Id    = layout.TotalLineCount - 1;
            itemInfo.Slot  = itemInfo.Id;

            itemInfo.IsCollapsible    = false;
            itemInfo.IsCollapsed      = false;
            itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
            itemInfo.IsSummaryVisible = false;

            itemInfo.LayoutInfo = layout.GenerateLayoutInfo(itemInfo, null, visibleLine, visibleLine);

            return(new List <ItemInfo> {
                itemInfo
            });
        }
コード例 #12
0
 public abstract int CalculateAppendedSlotsCount(BaseLayout layout, int startSlot);
コード例 #13
0
 public abstract IList <ItemInfo> BuildItemInfos(BaseLayout layout, int visibleLine, int slot);
コード例 #14
0
 public abstract int CalculateAppendedSlotsCount(BaseLayout layout, int startSlot, ref int totalLines);
コード例 #15
0
        internal override IList <ItemInfo> GetItemInfosAtSlot(int visibleLine, int rowSlot)
        {
            List <ItemInfo> items = new List <ItemInfo>();

            GroupInfo groupInfo;
            int       lowerBound;

            int itemsCount = 0;

            foreach (var item in this.GroupHeadersTable)
            {
                itemsCount = Math.Max(item.Value.LastSubItemSlot, itemsCount);
            }

            int stackSlot = this.GetFirstStackSlotOnRow(rowSlot, itemsCount);

            if (this.GroupHeadersTable.TryGetValue(stackSlot, out groupInfo, out lowerBound) && stackSlot <= itemsCount)
            {
                if (lowerBound != stackSlot)
                {
                    // Children item inside the group
                    int childSlotIndex = stackSlot - lowerBound - 1;

                    // TODO find more effition
                    for (int i = 0; i < this.StackCount; i++)
                    {
                        var item = this.HierarchyAdapter.GetItemAt(groupInfo.Item, childSlotIndex + i);

                        if (item == null)
                        {
                            // End of child collection - the stack row/column is not full.
                            break;
                        }

                        ItemInfo itemInfo = new ItemInfo();
                        itemInfo.IsDisplayed = true;
                        itemInfo.Id          = groupInfo.Index + childSlotIndex + 1 + i;
                        itemInfo.Item        = item;
                        itemInfo.Level       = groupInfo.Level + 1;
                        itemInfo.Slot        = rowSlot; // groupInfo.Index + (int)Math.Ceiling(childSlotIndex/(double)this.StackCount) + 1;

                        itemInfo.IsCollapsible    = false;
                        itemInfo.IsCollapsed      = false;
                        itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
                        itemInfo.IsSummaryVisible = itemInfo.ItemType == GroupType.Subtotal && this.IsCollapsed(groupInfo.Item);

                        items.Add(itemInfo);
                    }

                    // Add parent (group) for lookup
                    var parentItemInfo = new ItemInfo();
                    parentItemInfo.IsDisplayed = false;
                    parentItemInfo.Id          = groupInfo.Index;
                    parentItemInfo.Item        = groupInfo.Item;
                    parentItemInfo.Level       = groupInfo.Level;
                    parentItemInfo.Slot        = rowSlot;

                    parentItemInfo.IsCollapsed      = !groupInfo.IsExpanded;
                    parentItemInfo.ItemType         = BaseLayout.GetItemType(groupInfo.Item);
                    parentItemInfo.IsSummaryVisible = parentItemInfo.ItemType == GroupType.Subtotal && groupInfo.Parent != null && this.IsCollapsed(groupInfo.Parent.Item);

                    items.Insert(0, parentItemInfo);
                }
                else
                {
                    // Group header
                    ItemInfo itemInfo = new ItemInfo();
                    itemInfo.IsDisplayed      = true;
                    itemInfo.Id               = groupInfo.Index;
                    itemInfo.Item             = groupInfo.Item;
                    itemInfo.Level            = groupInfo.Level;
                    itemInfo.Slot             = rowSlot;
                    itemInfo.IsCollapsed      = !groupInfo.IsExpanded;
                    itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
                    itemInfo.IsSummaryVisible = itemInfo.ItemType == GroupType.Subtotal && groupInfo.Parent != null && this.IsCollapsed(groupInfo.Parent.Item);

                    items.Add(itemInfo);
                }

                // Add parent path to root
                int line            = visibleLine - 1;
                var parentGroupInfo = groupInfo.Parent;
                while (parentGroupInfo != null)
                {
                    var parentItemInfo = new ItemInfo();
                    parentItemInfo.IsDisplayed      = false;
                    parentItemInfo.Id               = parentGroupInfo.Index;
                    parentItemInfo.Item             = parentGroupInfo.Item;
                    parentItemInfo.Level            = parentGroupInfo.Level;
                    parentItemInfo.Slot             = parentGroupInfo.Index;
                    parentItemInfo.IsCollapsed      = !parentGroupInfo.IsExpanded;
                    parentItemInfo.ItemType         = BaseLayout.GetItemType(parentGroupInfo.Item);
                    parentItemInfo.IsSummaryVisible = parentItemInfo.ItemType == GroupType.Subtotal && parentGroupInfo.Parent != null && this.IsCollapsed(parentGroupInfo.Parent.Item);

                    line--;

                    items.Insert(0, parentItemInfo);
                    parentGroupInfo = parentGroupInfo.Parent;
                }
            }
            else
            {
                for (int stackIndex = 0; stackIndex < this.StackCount; stackIndex++)
                {
                    var position = this.StackCount * visibleLine + stackIndex;

                    if (this.ItemsSource != null && position < this.ItemsSource.Count)
                    {
                        ItemInfo itemInfo = new ItemInfo();
                        itemInfo.IsDisplayed = true;

                        itemInfo.Item  = this.ItemsSource[position];
                        itemInfo.Level = 0;
                        itemInfo.Id    = position;
                        itemInfo.Slot  = rowSlot;

                        itemInfo.IsCollapsible    = false;
                        itemInfo.IsCollapsed      = false;
                        itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
                        itemInfo.IsSummaryVisible = false;

                        items.Add(itemInfo);
                    }
                }
            }

            return(items);
        }
コード例 #16
0
ファイル: CompactLayout.cs プロジェクト: zyhong/UI-For-UWP
        internal IList <ItemInfo> GetItemInfosAtSlot(int visibleLine, int slot)
        {
            List <ItemInfo> items = new List <ItemInfo>();

            ItemInfo itemInfo = new ItemInfo();

            itemInfo.IsDisplayed = true;

            GroupInfo groupInfo;
            int       lowerBound;

            if (this.groupHeadersTable.TryGetValue(slot, out groupInfo, out lowerBound))
            {
                if (lowerBound != slot)
                {
                    int childIndex = slot - lowerBound - 1;
                    itemInfo.Id    = groupInfo.Index + childIndex + 1;
                    itemInfo.Item  = this.hierarchyAdapter.GetItemAt(groupInfo.Item, childIndex);
                    itemInfo.Level = groupInfo.Level + 1;
                    itemInfo.Slot  = itemInfo.Id;

                    itemInfo.IsCollapsible    = false;
                    itemInfo.IsCollapsed      = false;
                    itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
                    itemInfo.IsSummaryVisible = itemInfo.ItemType == GroupType.Subtotal && this.IsCollapsed(groupInfo.Item);

                    itemInfo.LayoutInfo = this.GenerateLayoutInfo(itemInfo, groupInfo, visibleLine, childIndex);
                    items.Add(itemInfo);

                    var parentItemInfo = new ItemInfo();
                    parentItemInfo.IsDisplayed      = false;
                    parentItemInfo.Id               = groupInfo.Index;
                    parentItemInfo.Item             = groupInfo.Item;
                    parentItemInfo.Level            = groupInfo.Level;
                    parentItemInfo.Slot             = groupInfo.Index;
                    parentItemInfo.IsCollapsible    = this.IsCollapsible(groupInfo);
                    parentItemInfo.IsCollapsed      = !groupInfo.IsExpanded;
                    parentItemInfo.ItemType         = BaseLayout.GetItemType(groupInfo.Item);
                    parentItemInfo.IsSummaryVisible = parentItemInfo.ItemType == GroupType.Subtotal && groupInfo.Parent != null && this.IsCollapsed(groupInfo.Parent.Item);

                    parentItemInfo.LayoutInfo = this.GenerateLayoutInfo(parentItemInfo, groupInfo.Parent, itemInfo.LayoutInfo.Line - 1, itemInfo.LayoutInfo.Line - 1);

                    items.Insert(0, parentItemInfo);
                }
                else
                {
                    itemInfo.Id               = groupInfo.Index;
                    itemInfo.Item             = groupInfo.Item;
                    itemInfo.Level            = groupInfo.Level;
                    itemInfo.Slot             = itemInfo.Id;
                    itemInfo.IsCollapsible    = this.IsCollapsible(groupInfo);
                    itemInfo.IsCollapsed      = !groupInfo.IsExpanded;
                    itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
                    itemInfo.IsSummaryVisible = itemInfo.ItemType == GroupType.Subtotal && groupInfo.Parent != null && this.IsCollapsed(groupInfo.Parent.Item);

                    itemInfo.LayoutInfo = this.GenerateLayoutInfo(itemInfo, groupInfo.Parent, visibleLine, visibleLine);

                    items.Add(itemInfo);
                }

                int line            = itemInfo.LayoutInfo.Line - 1;
                var parentGroupInfo = groupInfo.Parent;
                while (parentGroupInfo != null)
                {
                    var parentItemInfo = new ItemInfo();
                    parentItemInfo.IsDisplayed      = false;
                    parentItemInfo.Id               = parentGroupInfo.Index;
                    parentItemInfo.Item             = parentGroupInfo.Item;
                    parentItemInfo.Level            = parentGroupInfo.Level;
                    parentItemInfo.Slot             = parentGroupInfo.Index;
                    parentItemInfo.IsCollapsible    = this.IsCollapsible(parentGroupInfo);
                    parentItemInfo.IsCollapsed      = !parentGroupInfo.IsExpanded;
                    parentItemInfo.ItemType         = BaseLayout.GetItemType(parentGroupInfo.Item);
                    parentItemInfo.IsSummaryVisible = parentItemInfo.ItemType == GroupType.Subtotal && parentGroupInfo.Parent != null && this.IsCollapsed(parentGroupInfo.Parent.Item);

                    parentItemInfo.LayoutInfo = this.GenerateLayoutInfo(parentItemInfo, parentGroupInfo.Parent, line, line);
                    line--;

                    items.Insert(0, parentItemInfo);
                    parentGroupInfo = parentGroupInfo.Parent;
                }
            }
            else if (this.ItemsSource != null && visibleLine < this.ItemsSource.Count)
            {
                itemInfo.Item  = this.ItemsSource[visibleLine];
                itemInfo.Level = 0;
                itemInfo.Id    = slot;
                itemInfo.Slot  = itemInfo.Id;

                itemInfo.IsCollapsible    = false;
                itemInfo.IsCollapsed      = false;
                itemInfo.ItemType         = BaseLayout.GetItemType(itemInfo.Item);
                itemInfo.IsSummaryVisible = false;

                itemInfo.LayoutInfo = this.GenerateLayoutInfo(itemInfo, null, visibleLine, visibleLine);
                items.Add(itemInfo);
            }

            return(items);
        }
コード例 #17
0
 public override int CalculateAppendedSlotsCount(BaseLayout layout, int startSlot, ref int totalLines)
 {
     return(1);
 }
コード例 #18
0
 public override IList <ItemInfo> BuildItemInfos(BaseLayout layout, int visibleLine, int slot)
 {
     return(new List <ItemInfo>());
 }
コード例 #19
0
        private bool TryGetGroupedItemsAtColumnSlot(int visibleLine, int slot, int columnSlot, ref List <ItemInfo> items)
        {
            ItemInfo itemInfo = new ItemInfo();

            itemInfo.IsDisplayed = true;

            GroupInfo groupInfo;
            int       lowerBound;

            if (this.groupHeadersTable.TryGetValue(columnSlot, out groupInfo, out lowerBound))
            {
                if (lowerBound != columnSlot)
                {
                    var    avalaibleLength = 2 * this.availableOppositeLength;
                    double itemsWidth      = 0;

                    while (itemsWidth < avalaibleLength && columnSlot < this.ColumnSlotsRenderInfo.Count)
                    {
                        if (visibleLine < this.VisibleLineCount)
                        {
                            int childIndex = columnSlot - lowerBound - 1;

                            if (groupInfo.LastSubItemSlot - groupInfo.Index <= childIndex)
                            {
                                break;
                            }

                            var childItem = this.hierarchyAdapter.GetItemAt(groupInfo.Item, childIndex);
                            itemInfo.Item = childItem;

                            itemInfo.Level = groupInfo.Level + 1;
                            itemInfo.Id    = groupInfo.Index + childIndex + 1;
                            itemInfo.Slot  = slot;

                            itemInfo.IsCollapsible = false;
                            itemInfo.IsCollapsed   = false;
                            itemInfo.ItemType      = BaseLayout.GetItemType(itemInfo.Item);

                            itemsWidth += this.ColumnSlotsRenderInfo.ValueForIndex(columnSlot);
                            columnSlot++;

                            items.Add(itemInfo);
                        }
                        else
                        {
                            break;
                        }
                    }

                    var parentItemInfo = new ItemInfo();
                    parentItemInfo.IsDisplayed      = false;
                    parentItemInfo.Id               = groupInfo.Index;
                    parentItemInfo.Item             = groupInfo.Item;
                    parentItemInfo.Level            = groupInfo.Level;
                    parentItemInfo.Slot             = this.CalculateNextRowPosition(groupInfo.Index);
                    parentItemInfo.IsCollapsed      = !groupInfo.IsExpanded;
                    parentItemInfo.ItemType         = BaseLayout.GetItemType(groupInfo.Item);
                    parentItemInfo.IsSummaryVisible = parentItemInfo.ItemType == GroupType.Subtotal && groupInfo.Parent != null && this.IsCollapsed(groupInfo.Parent.Item);
                    items.Insert(0, parentItemInfo);
                }
                else
                {
                    itemInfo.Id    = groupInfo.Index;
                    itemInfo.Item  = groupInfo.Item;
                    itemInfo.Level = groupInfo.Level;
                    itemInfo.Slot  = slot;

                    itemInfo.IsCollapsed = !groupInfo.IsExpanded;
                    itemInfo.ItemType    = BaseLayout.GetItemType(itemInfo.Item);

                    //// Denote the current slot as a group header as it will be stretched to  fill the entire opposite length
                    this.ColumnSlotsRenderInfo.Update(itemInfo.Id, this.AvailableOppositeLength);

                    itemInfo.IsSummaryVisible = itemInfo.ItemType == GroupType.Subtotal && groupInfo.Parent != null && this.IsCollapsed(groupInfo.Parent.Item);
                    items.Add(itemInfo);
                }

                var parentGroupInfo = groupInfo.Parent;
                while (parentGroupInfo != null)
                {
                    var parentItemInfo = new ItemInfo();
                    parentItemInfo.IsDisplayed      = false;
                    parentItemInfo.Id               = parentGroupInfo.Index;
                    parentItemInfo.Item             = parentGroupInfo.Item;
                    parentItemInfo.Level            = parentGroupInfo.Level;
                    parentItemInfo.Slot             = this.CalculateNextRowPosition(groupInfo.Index);
                    parentItemInfo.IsCollapsed      = !parentGroupInfo.IsExpanded;
                    parentItemInfo.ItemType         = BaseLayout.GetItemType(parentGroupInfo.Item);
                    parentItemInfo.IsSummaryVisible = parentItemInfo.ItemType == GroupType.Subtotal && parentGroupInfo.Parent != null && this.IsCollapsed(parentGroupInfo.Parent.Item);

                    items.Insert(0, parentItemInfo);
                    parentGroupInfo = parentGroupInfo.Parent;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #20
0
 public override int CalculateAppendedSlotsCount(BaseLayout layout, int startSlot)
 {
     return(1);
 }