Пример #1
0
        public void GroupSecondLevel(int level, string groupProperty)
        {
            ArrayList groups = GetForLevel(level + "");

            foreach (GroupItem group in groups)
            {
                Hashtable newGroups = new Hashtable();
                SortById  comById   = new SortById();
                group.Children.Sort(comById);
                int pozition = 0;
                foreach (GroupItem child in group.Children)
                {
                    object val = GetValue(child.InnerObject, groupProperty);
                    if (newGroups[val] == null)
                    {
                        GroupItem newGroup = new GroupItem(random.Next(), val.ToString());
                        newGroup.Parent   = group;
                        newGroup.Position = pozition;
                        //newGroup.InnerObject = child.InnerObject;
                        newGroup.Picture = (string)GetValue(child.InnerObject, picture);
                        newGroup.Image   = (byte[])GetValue(child.InnerObject, "Image");
                        newGroups[val]   = newGroup;
                        //this.Add(newGroup);
                    }
                    GroupItem parent = (GroupItem)newGroups[val];
                    parent.Children.Add(child);
                    pozition++;
                }
                group.Children.Clear();
                ArrayList      tmpArray       = new ArrayList();
                SortByPozition sortByPozition = new SortByPozition();
                tmpArray.AddRange(newGroups.Values);
                tmpArray.Sort(sortByPozition);
                foreach (GroupItem entry in tmpArray)
                {
                    group.Children.Add(entry);
                    //                    Console.WriteLine("Group: {0}, entry:{1}", group.Path, entry.Path);
                    this.Add(entry);
                }
                //                Console.WriteLine("Group: {0}, total:{1}", group.Path,  group.Children.Count);
            }
        }
Пример #2
0
 public void GroupSecondLevel(int level, string groupProperty)
 {
     ArrayList groups = GetForLevel(level + "");
     foreach (GroupItem group in groups)
     {
         Hashtable newGroups = new Hashtable();
         SortById comById = new SortById();
         group.Children.Sort(comById);
         int pozition = 0;
         foreach (GroupItem child in group.Children)
         {
             object val = GetValue(child.InnerObject, groupProperty);
             if (newGroups[val] == null)
             {
                 GroupItem newGroup = new GroupItem(random.Next(), val.ToString());
                 newGroup.Parent = group;
                 newGroup.Position = pozition;
                 //newGroup.InnerObject = child.InnerObject;
                 newGroup.Picture = (string)GetValue(child.InnerObject, picture);
                 newGroup.Image = (byte[])GetValue(child.InnerObject, "Image");
                 newGroups[val] = newGroup;
                 //this.Add(newGroup);
             }
             GroupItem parent = (GroupItem)newGroups[val];
             parent.Children.Add(child);
             pozition++;
         }
         group.Children.Clear();
         ArrayList tmpArray = new ArrayList();
         SortByPozition sortByPozition = new SortByPozition();
         tmpArray.AddRange(newGroups.Values);
         tmpArray.Sort(sortByPozition);
         foreach (GroupItem entry in tmpArray)
         {
             group.Children.Add(entry);
             //                    Console.WriteLine("Group: {0}, entry:{1}", group.Path, entry.Path);
             this.Add(entry);
         }
         //                Console.WriteLine("Group: {0}, total:{1}", group.Path,  group.Children.Count);
     }
 }