Esempio n. 1
0
        private static void LoadList(List<List<object>> datalist)
        {
            SortedDictionary<int, List<ProblemInfo>> catData
                = new SortedDictionary<int, List<ProblemInfo>>();

            //Load problem from list
            foreach (List<object> lst in datalist)
            {
                ProblemInfo plist = new ProblemInfo(lst);
                problemList.Add(plist);

                //set the file size
                string file = LocalDirectory.GetProblemHtml(plist.pnum);
                if (File.Exists(file))
                    plist.fileSize = (new System.IO.FileInfo(file)).Length;

                SetProblem(plist.pnum, plist);
                SetNumber(plist.pid, plist.pnum);

                //Categorize
                if (!catData.ContainsKey(plist.volume))
                {
                    catData.Add(plist.volume, new List<ProblemInfo>());
                }
                catData[plist.volume].Add(plist);
            }

            //add volume category
            var volCat = new CategoryNode("Volumes", "Problem list by volumes");
            categoryRoot.branches.Add(volCat);
            foreach (var data in catData.Values)
            {
                string vol = string.Format("Volume {0:000}", data[0].volume);
                var nod = new CategoryNode(vol, "", volCat);
                volCat.branches.Add(nod);
                foreach (var p in data)
                {
                    nod.problems.Add(new CategoryProblem(p.pnum));
                }
            }
            volCat.ProcessData();
        }