Esempio n. 1
0
        /// <summary>
        /// Add an item to the desired subgroup(s) of the given group
        /// </summary>
        /// <param name="item">Item to add</param>
        /// <param name="group">Group to add item to</param>
        /// <param name="level">The level of grouping</param>
        /// <param name="loading">Whether we are currently loading</param>
        private void AddToSubgroups(object item, CollectionViewGroupInternal group, int level, bool loading)
        {
            object      name = this.GetGroupName(item, group.GroupBy, level);
            ICollection nameList;

            if (name == UseAsItemDirectly)
            {
                // the item belongs to the group itself (not to any subgroups)
                if (loading)
                {
                    group.Add(item);
                }
                else
                {
                    int localIndex = group.Insert(item, item, this.ActiveComparer);
                    int index      = group.LeafIndexFromItem(item, localIndex);
                    this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
                }
            }
            else if ((nameList = name as ICollection) == null)
            {
                // the item belongs to one subgroup
                this.AddToSubgroup(item, group, level, name, loading);
            }
            else
            {
                // the item belongs to multiple subgroups
                foreach (object o in nameList)
                {
                    this.AddToSubgroup(item, group, level, o, loading);
                }
            }
        }
        private void AddToSubgroups(object item, LiveShapingItem lsi, CollectionViewGroupInternal group, int level, bool loading)
        {
            object groupName = this.GetGroupName(item, group.GroupBy, level);

            if (groupName == CollectionViewGroupRoot.UseAsItemDirectly)
            {
                if (lsi != null)
                {
                    lsi.AddParentGroup(group);
                }
                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, lsi, group, level, groupName, loading);
                }
                else
                {
                    foreach (object name in (IEnumerable)collection)
                    {
                        this.AddToSubgroup(item, lsi, group, level, name, loading);
                    }
                }
            }
        }
        /// <summary>
        /// Add an item to the desired subgroup(s) of the given group
        /// </summary>
        /// <param name="item">Item to add</param>
        /// <param name="group">Group to add item to</param>
        /// <param name="level">The level of grouping</param>
        /// <param name="loading">Whether we are currently loading</param>
        /// <param name="insertedBefore">The item to insert this item before,
        /// or <c>null</c> if the item should be added at the end.</param>
        private void AddToSubgroups(object item, CollectionViewGroupInternal group, int level, bool loading, object insertedBefore)
        {
            object name = this.GetGroupName(item, group.GroupBy, level);
            ICollection nameList;

            if (name == UseAsItemDirectly)
            {
                // the item belongs to the group itself (not to any subgroups)
                if (loading)
                {
                    group.Add(item);
                }
                else
                {
                    int localIndex = -1;

                    // If we were given an item to insert before, find its index
                    // within the target group.  If it's not in the group, we'll
                    // get -1 back, which we'll translate into putting the item
                    // at the end of the list.
                    if (insertedBefore != null)
                    {
                        localIndex = group.LeafIndexOf(insertedBefore);
                    }

                    if (localIndex == -1)
                    {
                        localIndex = group.ItemCount;
                    }

                    group.Insert(item, localIndex);
                    int index = group.LeafIndexFromItem(item, localIndex);
                    this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
                }
            }
            else if ((nameList = name as ICollection) == null)
            {
                // the item belongs to one subgroup
                this.AddToSubgroup(item, group, level, name, loading, insertedBefore);
            }
            else
            {
                // the item belongs to multiple subgroups
                foreach (object o in nameList)
                {
                    this.AddToSubgroup(item, group, level, o, loading, insertedBefore);
                }
            }
        }
 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);
             }
         }
     }
 }
 private void AddToSubgroups(object item, CollectionViewGroupInternal group, int level, bool loading)
 {
     object name = this.GetGroupName(item, group.GroupBy, level);
     if (name == UseAsItemDirectly)
     {
         if (loading)
         {
             group.Add(item);
         }
         else
         {
             int index = group.Insert(item, item, this.ActiveComparer);
             int num2 = group.LeafIndexFromItem(item, index);
             this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(0, item, num2));
         }
     }
     else
     {
         ICollection is2 = name as ICollection;
         if (is2 == null)
         {
             this.AddToSubgroup(item, group, level, name, loading);
         }
         else
         {
             foreach (object obj3 in is2)
             {
                 this.AddToSubgroup(item, group, level, obj3, loading);
             }
         }
     }
 }
        // add an item to the desired subgroup(s) of the given group
        void AddToSubgroups(object item, LiveShapingItem lsi, CollectionViewGroupInternal group, int level, bool loading)
        {
            object name = GetGroupName(item, group.GroupBy, level);
            ICollection nameList;

            if (name == UseAsItemDirectly)
            {
                // the item belongs to the group itself (not to any subgroups)
                if (lsi != null)
                {
                    lsi.AddParentGroup(group);
                }

                if (loading)
                {
                    group.Add(item);
                }
                else
                {
                    int localIndex = group.Insert(item, item, ActiveComparer);
                    int index = group.LeafIndexFromItem(item, localIndex);
                    OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
                }
            }
            else if ((nameList = name as ICollection) == null)
            {
                // the item belongs to one subgroup
                AddToSubgroup(item, lsi, group, level, name, loading);
            }
            else
            {
                // the item belongs to multiple subgroups
                foreach (object o in nameList)
                {
                    AddToSubgroup(item, lsi, group, level, o, loading);
                }
            }
        }