/// <summary> /// Start Button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnStart_Click(object sender, EventArgs e) { if (!Scanner_RedKill.IsBusy) { PeopleAlive = 0; KillCount = 0; tsLblAlive.Text = "Alive: 0"; tsLblAlive.Text = "Kills: 0"; WriteToLog("Scanning for kills..."); btnStart.Text = "Stop"; Scanner_RedKill.RunWorkerAsync(); btnStart.BackColor = Color.PaleVioletRed; toolStripProgressBar1.Style = ProgressBarStyle.Marquee; toolStripProgressBar1.MarqueeAnimationSpeed = 100; } else { WriteToLog("Stopped scanning for kills..."); btnStart.Text = "Start"; Scanner_RedKill.CancelAsync(); Scanner_KillNumber.CancelAsync(); Worker_KillMessageCleaner.CancelAsync(); btnStart.BackColor = Color.LightGreen; toolStripProgressBar1.MarqueeAnimationSpeed = 0; toolStripProgressBar1.Style = ProgressBarStyle.Blocks; toolStripProgressBar1.Value = toolStripProgressBar1.Minimum; } }
/// <summary> /// Progress of TopKillScanner /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Scanner_KillNumber_ProgressChanged(object sender, ProgressChangedEventArgs e) { //If new KillNumber is bigger than the current Killcount and not bigger than the current Killcount+6, accept it as valid. if (e.ProgressPercentage > KillCount && e.ProgressPercentage < KillCount + 20) { KillCount = e.ProgressPercentage; WriteToLog("New Kill detected!" + e.ProgressPercentage); //Wait for KillMessageCleaner to end and start it again. while (Worker_KillMessageCleaner.IsBusy) { Worker_KillMessageCleaner.CancelAsync(); } Worker_KillMessageCleaner.RunWorkerAsync(); tsLblKills.Text = "Kills: " + e.ProgressPercentage.ToString(); } }