コード例 #1
0
ファイル: Form1.cs プロジェクト: spazer/FPL_Calculator
        public Form1()
        {
            InitializeComponent();

            statistics = new Stats(errorwriter, Convert.ToDouble(textBoxPointMod.Text));
            statistics.ProgressUpdate += new Stats.progressEventHandler(statistics_ProgressUpdate);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: spazer/FPL_Calculator
        /// <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, Convert.ToDouble(textBoxPointMod.Text));

                // 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.PrintPlayerTrVal();
                statistics.PrintTeamStats();
                statistics.PrintTeamTrVal();

                // 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.");
            }
        }