/// <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> /// Gets called when we're finished with Kill-Number detection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Scanner_KillNumber_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //Start Scanner again if (!Scanner_RedKill.IsBusy && !Scanner_RedKill.CancellationPending) { Scanner_RedKill.RunWorkerAsync(); } }
/// <summary> /// KillScanner - Scans for red colored kill message. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Scanner_RedKill_DoWork(object sender, DoWorkEventArgs e) { while (!Scanner_RedKill.CancellationPending) { //Check for Kill if (learninghelper.CheckForKill(GetScreenData())) { Scanner_RedKill.ReportProgress(1, ""); } else { Scanner_RedKill.ReportProgress(0, ""); } Thread.Sleep(iKillCheckInterval); } }