示例#1
0
        void AddInSubtree(StandardCollectionViewGroup group, object item, CultureInfo culture, IList <GroupDescription> descriptions, bool allowSorting)
        {
            int depth = group.Depth;

            if (group.IsBottomLevel)
            {
                group.AddItem(item, allowSorting, WrappedList);
                CollectionChanged.Raise(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, IndexOfSubtree(item)));
            }
            else
            {
                var desc       = descriptions [group.Depth];
                var groupNames = desc.GroupNameFromItem(item, group.Depth, culture);
                if (groupNames is IList)
                {
                    foreach (var name in (IList)groupNames)
                    {
                        AddInSubtree(group, item, culture, descriptions, allowSorting, name);
                    }
                }
                else
                {
                    AddInSubtree(group, item, culture, descriptions, allowSorting, groupNames);
                }
            }
        }
示例#2
0
        void AddInSubtree(StandardCollectionViewGroup group, object item, CultureInfo culture, IList <GroupDescription> descriptions, bool allowSorting, object name)
        {
            bool added = false;

            foreach (StandardCollectionViewGroup g in group.Items)
            {
                var desc = descriptions [group.Depth];
                if (desc.NamesMatch(g.Name, name))
                {
                    AddInSubtree(g, item, culture, descriptions, allowSorting);
                    added = true;
                }
            }

            if (!added)
            {
                int depth = group.Depth + 1;
                var g     = new StandardCollectionViewGroup(group, name, depth, depth == descriptions.Count, group.Sorters);
                group.AddItem(g, allowSorting, WrappedList);
                AddInSubtree(g, item, culture, descriptions, allowSorting);
            }
        }