コード例 #1
0
ファイル: ProblemViewer.cs プロジェクト: avijit1258/UVA-Arena
 public void ClearAll()
 {
     current = null;
     titleBox1.Text = "No problem selected";
     problemMessage.Text = (string)problemMessage.Tag;
     problemWebBrowser.GoHome();
 }
コード例 #2
0
ファイル: CategoryNode.cs プロジェクト: maestrofx/UVA-Arena
        /// <summary>
        /// Add a problem to current category
        /// </summary>
        /// <param name="problem"></param>
        /// <param name="savepath">True to add current path to problem's category</param>
        public void AddProblem(ProblemInfo problem, bool savepath = true)
        {
            //add to current and parents
            int index = IndexOfProblem(problem.pnum);

            if (index < Problems.Count && Problems[index] == problem)
            {
                return;
            }
            this.Problems.Insert(index, problem);
            if (this.Parent != null)
            {
                this.Parent.AddProblem(problem, false);
            }

            //add category to list
            if (savepath)
            {
                string _path = this.Path;
                if (!problem.categories.Contains(_path))
                {
                    problem.categories.Add(_path);
                }
            }
        }
コード例 #3
0
 public void AddProblem(ProblemInfo p, bool force = false)
 {
     if (allProbs.ContainsKey(p.pnum))
     {
         if (force)
         {
             allProbs[p.pnum] = p;
         }
     }
     else
     {
         allProbs.Add(p.pnum, p);
     }
 }
コード例 #4
0
        void loadData(ProblemInfo pinfo)
        {
            titleLabel.Text = string.Format(title, pinfo.pnum, pinfo.ptitle);

            int num = 1;
            string data = head;
            foreach (var node in pinfo.categories)
            {
                string path = getPath(node).Replace(Environment.NewLine, @"\par\n\pard ");
                data += string.Format(catpath, path, num++);
                data += string.Format(probnote, node.GetCategoryNote(pinfo.pnum));
            }
            data += tail;
            richTextBox1.Rtf = data;
        }
コード例 #5
0
        //
        // Functions
        //
        public void ProcessData()
        {
            foreach (CategoryNode b in branches)
            {
                try
                {
                    b.Parent = this;
                    b.ProcessData();
                    AddProblemsFrom(b);
                }
                catch { }
            }
            foreach (CategoryProblem p in problems)
            {
                try
                {
                    ProblemInfo pinfo = LocalDatabase.GetProblem(p.pnum);
                    if (pinfo == null)
                    {
                        continue;
                    }

                    if (!pinfo.categories.Contains(this))
                    {
                        pinfo.categories.Add(this);
                    }
                    AddProblem(pinfo, true);

                    if (p.star)
                    {
                        pinfo.Starred = true;
                    }
                    if (problemToNote.ContainsKey(p.pnum))
                    {
                        problemToNote[p.pnum] = p.note;
                    }
                    else
                    {
                        problemToNote.Add(p.pnum, p.note);
                    }
                }
                catch { }
            }
            problems.Clear();
        }
コード例 #6
0
ファイル: ContextBook.cs プロジェクト: maestrofx/UVA-Arena
        public void Process()
        {
            if (arr == null)
            {
                return;
            }
            string root = LocalDatabase.CatRoot + CategoryNode.SEPARATOR + title;

            foreach (SubGroup sub in arr)
            {
                if (sub.arr == null)
                {
                    continue;
                }
                string child1 = root + CategoryNode.SEPARATOR + sub.title;

                foreach (List <object> list in sub.arr)
                {
                    if (list == null)
                    {
                        continue;
                    }
                    string child2 = child1 + CategoryNode.SEPARATOR + (string)list[0];

                    for (int i = 1; i < list.Count; ++i)
                    {
                        long pnum = Math.Abs((long)list[i]);
                        if (!LocalDatabase.HasProblem(pnum))
                        {
                            continue;
                        }

                        ProblemInfo problem = LocalDatabase.GetProblem(pnum);
                        problem.stared = ((long)list[i]) < 0;
                        LocalDatabase.category_root[child2].AddProblem(problem);
                    }
                }
            }
        }
コード例 #7
0
ファイル: ProblemViewer.cs プロジェクト: avijit1258/UVA-Arena
        public void LoadProblem(ProblemInfo plist)
        {
            if (plist == null)
            {
                ClearAll();
                return;
            }

            //cleanup history
            if (next.Count > 0)
            {
                next.Clear();
                nextButton.Enabled = false;
            }
            if (current != null)
            {
                previous.Push(current);
                backButton.Enabled = true;
            }

            current = plist;
            ShowCurrent();
            reloadButton.Enabled = true;
        }
コード例 #8
0
ファイル: CategoryNode.cs プロジェクト: maestrofx/UVA-Arena
        /// <summary>
        /// Removes a problem from current node and its parent nodes
        /// </summary>
        /// <param name="problem">Problem Info to remove</param>
        /// <returns>True if successfully removed from current node; otherwise false</returns>
        public bool RemoveProblem(ProblemInfo problem)
        {
            bool success = this.Problems.Remove(problem);

            if (success && Parent != null)
            {
                bool contains = false;
                foreach (CategoryNode cat in this.Parent.Nodes)
                {
                    if (cat.HasProblem(problem))
                    {
                        contains = true;
                        break;
                    }
                }
                //if none of parents child node contains this problem remove it
                if (!contains)
                {
                    this.Parent.RemoveProblem(problem);
                }
            }

            return(success);
        }
コード例 #9
0
ファイル: ProblemViewer.cs プロジェクト: avijit1258/UVA-Arena
        private void nextButton_Click(object sender, EventArgs e)
        {
            if (current != null)
            {
                previous.Push(current);
                backButton.Enabled = true;
            }
            current = next.Pop();
            nextButton.Enabled = (next.Count > 0);

            ShowCurrent();
        }
コード例 #10
0
ファイル: UserInfo.cs プロジェクト: oneshadab/UVA-Arena
        private void ProcessListData(List <List <long> > allsub, bool addToDef = false)
        {
            if (subs == null)
            {
                subs = new List <List <long> >();
            }

            bool needToSort = false;
            bool isdef      = (this.uname == RegistryAccess.DefaultUsername);

            foreach (List <long> lst in allsub)
            {
                try
                {
                    UserSubmission usub = new UserSubmission(lst);

                    //remove usub if already existed
                    if (sidToSub.ContainsKey(usub.sid))
                    {
                        if (usub.IsInQueue())
                        {
                            continue;
                        }
                        submissions.Remove(sidToSub[usub.sid]);
                        sidToSub.Remove(usub.sid);
                    }

                    //set the properties to usub add add to list
                    usub.name  = name;
                    usub.uname = uname;
                    submissions.Add(usub);
                    sidToSub.Add(usub.sid, usub);
                    needToSort = true;

                    //if usub is not in the queue add it
                    if (!usub.IsInQueue())
                    {
                        if (addToDef)
                        {
                            subs.Add(lst);
                        }
                        if (this.LastSID < usub.sid)
                        {
                            this.LastSID = usub.sid;
                        }
                    }

                    SetTried(usub);
                    if (isdef && IsSolved(usub.pnum))
                    {
                        ProblemInfo prob = LocalDatabase.GetProblem(usub.pnum);
                        if (prob != null)
                        {
                            prob.Solved = true;
                        }
                    }
                }
                catch { }
            }

            //sort by sid
            if (needToSort)
            {
                submissions.Sort((Comparison <UserSubmission>)
                                 delegate(UserSubmission a, UserSubmission b)
                {
                    return((int)(a.sid - b.sid));
                });
            }
        }
コード例 #11
0
ファイル: LocalDatabase.cs プロジェクト: avijit1258/UVA-Arena
        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();
        }
コード例 #12
0
ファイル: LocalDatabase.cs プロジェクト: avijit1258/UVA-Arena
 /// <summary> Save problem info for given problem number </summary>
 public static void SetProblem(long pnum, ProblemInfo plist)
 {
     if (problemNum == null) return;
     if (HasProblem(pnum)) problemNum[pnum] = plist;
     else problemNum.Add(pnum, plist);
 }
コード例 #13
0
ファイル: CategoryNode.cs プロジェクト: nocmnt/UVA-Arena
 public void AddProblem(ProblemInfo p, bool force = false)
 {
     if (allProbs.ContainsKey(p.pnum))
     {
         if (force) allProbs[p.pnum] = p;
     }
     else
     {
         allProbs.Add(p.pnum, p);
     }
 }
コード例 #14
0
 public ProblemCategoryViewer(ProblemInfo pinfo)
 {
     InitializeComponent();
     loadData(pinfo);
 }
コード例 #15
0
ファイル: CategoryNode.cs プロジェクト: maestrofx/UVA-Arena
        /// <summary>
        /// Determines if the given problem is in the problem list
        /// </summary>
        /// <param name="prob">ProblemInfo to search for</param>
        /// <returns>True if given ProblemInfo Contains in the list of Problems</returns>
        public bool HasProblem(ProblemInfo prob)
        {
            int index = IndexOfProblem(prob.pnum);

            return(index < Problems.Count && Problems[index] == prob);
        }