示例#1
0
        private void HandleResults(HtmlNodeCollection resultBoxNodes)
        {
            Etc.InitMatchFilters();
            this.resultURLs  = new List <string>();
            this.lastResults = new List <HtmlNode>();

            Console.Write("Results");

            for (int i = 0; i < resultBoxNodes.Count; i++)
            {
                HtmlNode resultBox = resultBoxNodes[i];
                HtmlNode result    = resultBox.SelectSingleNode(".//a[contains(@class, \"teambox\")]");
                if ((bool)this.filterOn)
                {
                    //goes to next match if it doesn't meet filter conditions
                    if (!Etc.CheckMatchFilter(result))
                    {
                        break;
                    }
                }

                string resultURL = result.GetAttributeValue("href", "");
                this.resultURLs.Add(resultURL);

                Console.Write("\n" + (i + 1) + ". ");
                PrintResult(result);
                this.lastResults.Add(result);
            }

            string hint = "(1-" + resultBoxNodes.Count +
                          ", Q to quit, B to return): ";

            GetResultEntry(hint);
        }
示例#2
0
        private void HandleMatches(HtmlNodeCollection matchBoxNodes, List <string> printout, bool rush = false)
        {
            Etc.InitMatchFilters();

            //          { ["12345", "Team1 vs Team2"], []... }
            liveMatchIDs = new ArrayList();
            matchURLs    = new List <string>();

            for (int i = 0; i < matchBoxNodes.Count; i++)
            {
                HtmlNode match     = matchBoxNodes[i].SelectSingleNode(".//div[contains(@class, \"teambox\")]");
                string   matchLine = (i + 1) + ".\t";

                //checks if the match is currently live
                bool isLive = bool.Parse(match.GetAttributeValue("filteraslive", "false")) &&
                              !match.HasClass("matchover");

                if ((bool)this.filterOn)
                {
                    //goes to next match if it doesn't meet filter conditions
                    if (!Etc.CheckMatchFilter(match))
                    {
                        break;
                    }
                }

                string matchURL = matchBoxNodes[i].GetAttributeValue("href", "");
                string matchID  = matchURL.Split("/")[2];
                matchURLs.Add(matchURL);

                HtmlNodeCollection teamNodes = match.SelectNodes(".//div[@class=\"teamrow\"]");
                //for cases where teams haven't been finalised
                if (teamNodes == null)
                {
                    printout.Add(HandlePlaceHolder(match, matchLine));
                    continue;
                }
                string time       = "",
                       matchTitle = teamNodes[0].InnerText.Trim() + " vs " + teamNodes[1].InnerText.Trim();
                if (isLive)
                {
                    liveMatchIDs.Add(new string[] { matchID, matchTitle });
                    time = "LIVE NOW!";
                }
                else
                {
                    time = GetMatchTime(match);
                }
                matchLine += String.Format(MATCH_TEMP, matchTitle, time) + "\n";
                printout.Add(matchLine);
            }
            if (!rush)
            {
                foreach (string matchLine in printout)
                {
                    Console.Write(matchLine);
                }
            }
            string hint = "(1-" + (printout.Count - 1) +
                          ", Q to quit, B to return, L to list matches, LIVE to view live matches): ";

            GetMatchEntry(printout, hint);
        }