Exemplo n.º 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);
     }
 }
Exemplo n.º 2
0
        private void GroupTopLevel(List<ListItem> list)
        {
            Hashtable groups = new Hashtable();
            foreach (ListItem l in list)
            {
                object val = GetValue(l, group1);
                if (groups[val] == null)
                {
                    GroupItem pg = new GroupItem(random.Next(), val.ToString());
                    pg.Picture = (string)GetValue(l, picture);
                    pg.Image = (byte[])GetValue(l, "Image");
                    groups[val] = pg;
                    this.Add(pg);
                }
                GroupItem parent = (GroupItem)groups[val];
                GroupItem child = new GroupItem();
                child.InnerObject = l;
                parent.Children.Add(child);


                //Console.WriteLine("{0}, {1}/{2} and pic:{3} ",l.Group,parent.Path,child.InnerObject.Group,parent.Picture);
            }
        }
Exemplo n.º 3
0
 private void Add(GroupItem item)
 {
     if (levels[item.Level + ""] == null)
     {
         levels[item.Level + ""] = new ArrayList();
     }
     ArrayList levelList = (ArrayList)levels[item.Level + ""];
     levelList.Add(item);
     allElements[item.Id] = item;
 }