Пример #1
0
        private void AddToSubgroups(object item, CollectionViewGroupInternal group, int level, bool loading)
        {
            object groupName = this.GetGroupName(item, group.GroupBy, level);

            if (groupName == CollectionViewGroupRoot.UseAsItemDirectly)
            {
                if (loading)
                {
                    group.Add(item);
                }
                else
                {
                    int index1 = group.Insert(item, item, this.ActiveComparer);
                    int index2 = group.LeafIndexFromItem(item, index1);
                    this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index2));
                }
            }
            else
            {
                ICollection collection;
                if ((collection = groupName as ICollection) == null)
                {
                    this.AddToSubgroup(item, group, level, groupName, loading);
                }
                else
                {
                    foreach (object name in (IEnumerable)collection)
                    {
                        this.AddToSubgroup(item, group, level, name, loading);
                    }
                }
            }
        }
Пример #2
0
        private void AddToSubgroup(object item, CollectionViewGroupInternal group, int level, object name, bool loading)
        {
            int index = 0;

            for (int count = group.Items.Count; index < count; ++index)
            {
                CollectionViewGroupInternal group1 = group.Items[index] as CollectionViewGroupInternal;
                if (group1 != null && group.GroupBy.NamesMatch(group1.Name, name))
                {
                    group.LastIndex = index;
                    this.AddToSubgroups(item, group1, level + 1, loading);
                    return;
                }
            }
            CollectionViewGroupInternal group2 = new CollectionViewGroupInternal(name, group);

            this.InitializeGroup(group2, level + 1);
            if (loading)
            {
                group.Add((object)group2);
                group.LastIndex = index;
            }
            else
            {
                group.Insert((object)group2, item, this.ActiveComparer);
            }
            this.AddToSubgroups(item, group2, level + 1, loading);
        }
Пример #3
0
        private void InitializeGroup(CollectionViewGroupInternal group, int level)
        {
            GroupDescription groupDescription = level < this.GroupDescriptions.Count ? this.GroupDescriptions[level] : (GroupDescription)null;

            group.GroupBy = groupDescription;
            ObservableCollection <object> observableCollection = groupDescription != null ? groupDescription.GroupNames : (ObservableCollection <object>)null;

            if (observableCollection != null)
            {
                int index = 0;
                for (int count = observableCollection.Count; index < count; ++index)
                {
                    CollectionViewGroupInternal group1 = new CollectionViewGroupInternal(observableCollection[index], group);
                    this.InitializeGroup(group1, level + 1);
                    group.Add((object)group1);
                }
            }
            group.LastIndex = 0;
        }