Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();

            statistics = new Stats(errorwriter);
            statistics.ProgressUpdate += new Stats.progressEventHandler(statistics_ProgressUpdate);
        }
Esempio n. 2
0
        /// <summary>
        /// Responds when buttonParse is clicked
        /// </summary>
        /// <param name="sender">Object calling this function</param>
        /// <param name="e">Event arguments</param>
        private void buttonParse_Click(object sender, EventArgs e)
        {
            // Get HTML from Liquipedia
            toolStripStatusLabel.Text = "Retrieving Liquipedia page";
            WebFetch page = new WebFetch(textBoxURL.Text + "&action=edit", errorwriter);

            if (page.pageContent != string.Empty)
            {
                page.ReduceToWikiMarkup();
                if (page.pageContent.IndexOf("#REDIRECT") != -1)
                {
                    int start = page.pageContent.IndexOf("[[") + 2;
                    int end = page.pageContent.IndexOf("]]");
                    page = new WebFetch(WIKIBASE + page.pageContent.Substring(start, end - start) + "&action=edit", errorwriter);
                    page.ReduceToWikiMarkup();
                }

                Stats statistics = new Stats(errorwriter);

                // Limit the number of weeks we consider
                int maxWeeks;
                bool result = int.TryParse(textBoxWeeks.Text, out maxWeeks);
                if (!result)
                {
                    maxWeeks = 0;
                }

                // Read in data from the webpage
                toolStripStatusLabel.Text = "Parsing webpage";
                statistics.ParseMarkup(page.pageContent, maxWeeks);

                // Print all the data we've retrieved
                statistics.PrintPlayerStats();
                statistics.PrintTeamStats();

                // Calculate the best team
                toolStripStatusLabel.Text = "Calculating best main team";
                statistics.BestMainWithoutTrades();

                toolStripStatusLabel.Text = "Solution complete";
            }
            else
            {
                toolStripStatusLabel.Text = "Error retrieving Liquipedia page";
                MessageBox.Show("Could not retrieve page. Check your connection.");
            }
        }