public void StartTimer(int timeEstimate, string operationType) { Console.WriteLine("StartTimer entered"); if (operationType == "FollowerStat") { FollowerStatsPanel.Invoke((MethodInvoker)(() => { FollowerStatTimer.Start(); FollowerStatProgressLabel.Visible = true; TimeSpan timeLeft = TimeSpan.FromSeconds(timeEstimate); FollowerStatProgressLabel.Text = "Gathering data from lichess API. Estimated time: " + string.Format("{0:%m}m {0:%s}s", timeLeft); apiTimeLeft = timeEstimate; databaseTimeLeft = apiTimeLeft / 5; })); } else { RatingComparatorPanel.Invoke((MethodInvoker)(() => { RatingComparatorTimer.Start(); RatingComparatorProgressLabel.Visible = true; TimeSpan timeLeft = TimeSpan.FromSeconds(timeEstimate); RatingComparatorProgressLabel.Text = "Gathering data from lichess API. Estimated time: " + string.Format("{0:%m}m {0:%s}s", timeLeft); apiTimeLeft = timeEstimate; databaseTimeLeft = apiTimeLeft / 4; })); } }
/// <summary> /// Sets up the results page for the FollowerStats mode /// </summary> public void SetupFollowerStatPage(string username, string relationship, int followerCount, Link mostActiveLinkRoot, Link mostTvLinkRoot, Link countryLinkRoot, Dictionary <int, int> ratingMap) { FollowerStatsPanel.Invoke((MethodInvoker)(() => { FollowerStatTimer.Stop(); FollowerStatProgressLabel.Visible = false; })); FollowerStatsResultsPanel.Invoke((MethodInvoker)(() => { FollowerStatsResultsPanel.Visible = true; TitleUsernameLabel.Text = char.ToUpper(username[0]) + username.Substring(1) + "'s"; FollowerStatFollowersLabel.Text = followerCount + " " + relationship; string tvOutputString = GetOutputString(mostTvLinkRoot, true, ""); string timePlayedOutputString = GetOutputString(mostActiveLinkRoot, true, ""); string countryOutputString = GetOutputString(countryLinkRoot, false, ""); FollowerStatCountryLabel.Text = "Most popular countries: \n" + countryOutputString; TVLabel.Text = "Most time on TV: \n" + tvOutputString; TimePlayedLabel.Text = "Most time played: \n" + timePlayedOutputString; RatingChart.Series.Clear(); RatingChart.ChartAreas.Clear(); RatingChart.Legends.Clear(); RatingChart.ChartAreas.Add("ChartArea1"); RatingChart.Series.Add("Frequency"); foreach (int key in ratingMap.Keys) { if ((ratingMap[key] != 0 || key < 2000) && relationship == "Followers") { RatingChart.Series["Frequency"].Points.AddXY(key, ratingMap[key]); } else if ((ratingMap[key] != 0 || key > 1400) && relationship == "Following") { RatingChart.Series["Frequency"].Points.AddXY(key, ratingMap[key]); } } })); ChangePage(4); }
private void FollowerStatCancelButton_Click(object sender, EventArgs e) { FollowerStatsPanel.Invoke((MethodInvoker)(() => { FollowerStatTimer.Stop(); FollowerStatProgressLabel.Visible = false; })); if (CancelButtonHit != null) { CancelButtonHit(); } }
/// <summary> /// Method that is used to switch between the application's different pages. /// </summary> private void ChangePage(int pageNum) { switch (pageNum) { case 0: { HomePanel.Invoke((MethodInvoker)(() => { HomePanel.Visible = true; CompareRatingsButton.Enabled = true; HomePanel.BringToFront(); ComparatorCancelButton.Enabled = false; })); ComparatorResultsPanel.Invoke((MethodInvoker)(() => { ComparatorResultsPanel.Visible = false; })); FollowerStatsResultsPanel.Invoke((MethodInvoker)(() => { FollowerStatsResultsPanel.Visible = false; })); FollowerStatsPanel.Invoke((MethodInvoker)(() => { FollowerStatsPanel.Visible = false; })); RatingComparatorPanel.Invoke((MethodInvoker)(() => { RatingComparatorPanel.Visible = false; })); break; } case 1: { HomePanel.Invoke((MethodInvoker)(() => { HomePanel.Visible = false; })); RatingComparatorPanel.Invoke((MethodInvoker)(() => { RatingComparatorPanel.Enabled = true; RatingComparatorPanel.Visible = true; RatingComparatorPanel.BringToFront(); })); ComparatorResultsPanel.Invoke((MethodInvoker)(() => { ComparatorResultsPanel.Visible = false; })); break; } case 2: { RatingComparatorPanel.Invoke((MethodInvoker)(() => { RatingComparatorPanel.Visible = false; ToggleControls("RatingComparator"); })); ComparatorResultsPanel.Invoke((MethodInvoker)(() => { ComparatorResultsPanel.Visible = true; })); break; } case 3: { HomePanel.Invoke((MethodInvoker)(() => { HomePanel.Visible = false; })); FollowerStatsPanel.Invoke((MethodInvoker)(() => { FollowerStatsPanel.Visible = true; FollowerStatsPanel.BringToFront(); FollowerStatsPanel.Enabled = true; FollowerStatCancelButton.Enabled = false; })); FollowerStatsResultsPanel.Invoke((MethodInvoker)(() => { FollowerStatsResultsPanel.Visible = false; })); break; } case 4: { FollowerStatsPanel.Invoke((MethodInvoker)(() => { FollowerStatsPanel.Visible = false; ToggleControls("FollowerStat"); })); FollowerStatsResultsPanel.Invoke((MethodInvoker)(() => { FollowerStatsResultsPanel.Visible = true; })); break; } } }