private void btnRecursiveVerify_Click(object sender, System.EventArgs e) { //CHECK IF USERS HAVE SELECTED FILES TO SCAN if ( this.chklistboxRecursive.Items.Count == 0 ) { MessageBox.Show( this, "Please Scan files first!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); RestartScanCleanUp(); return; } bVerifyScanRequested = true; bRecursiveScanRequested = true; pbarVerifySystemScan.Enabled = true; pbarVerifySystemScan.ProgressBarColor = System.Drawing.Color.Black; this.lstVerifySFV.Items.Clear(); this.lstRecursiveSFVs.Items.Clear(); edtVerifyFileSFV.Text = edtVerifyFileSFV.Text.Trim(); edtVerifyFileSFV.Enabled = false; btnVerifyFileSFV.Enabled = false; edtVerifySingleFile.Enabled = false; btnVerifySingleFile.Enabled = false; this.btnVerify.Text = "Abort Scan"; btnVerify.Click -= new EventHandler(this.VerifyScan); btnVerify.Click += new EventHandler(this.StopScan); this.btnRecursiveVerify.Text = "Abort Scan"; btnRecursiveVerify.Click -= new EventHandler(this.btnRecursiveVerify_Click); btnRecursiveVerify.Click += new EventHandler(this.StopScan); //RUN CHECK AND VERIFY myState = new CRCState(); string []sfvFiles = new string[this.chklistboxRecursive.CheckedItems.Count]; this.chklistboxRecursive.CheckedItems.CopyTo( sfvFiles, 0 ); foreach ( string sfvName in sfvFiles ) { if ( ( sfvName != null ) && ( sfvName != "" ) ) { myState.setSFVFileNames(sfvName); } } tabMain.SelectedTab = tabValidate; //PUT SETTINGS INTO myState (required as the new thread cant cross thread call to UI) if (chkVerifyShowFailed.Checked) { myState.boolShowFailed = true; } if (chkVerifyUnrar.Checked) { myState.boolUnrar = true; } if (chkVerifyDel.Checked) { myState.boolDelRars = true; } if (chkVerifyDelSFV.Checked) { myState.boolDelSFV = true; } if (chkVerifyBG.Checked) { myState.boolVerBG = true; } //RUN PROGRAM IN BACKGROUND MINIMISED TO TRAY if (chkVerifyBG.Checked) { this.Hide(); } dtVerifyScanStart = DateTime.Now; pbarVerifySystemScan.Value = 0; pbarVerifySystemScan.Minimum = 0; VerifyCRCThread = new System.Threading.Thread( new System.Threading.ThreadStart( VerifyCRC )); VerifyCRCThread.IsBackground = true; VerifyCRCThread.Name = "Verify File CRC"; VerifyCRCThread.Priority = System.Threading.ThreadPriority.Normal; VerifyCRCThread.Start(); }
private void VerifyScan(object sender, System.EventArgs e) { bVerifyScanRequested = true; pbarVerifySystemScan.Enabled = true; pbarVerifySystemScan.ProgressBarColor = System.Drawing.Color.Black; this.lstVerifySFV.Items.Clear(); this.btnVerify.Text = "Abort Scan"; edtVerifyFileSFV.Text = edtVerifyFileSFV.Text.Trim(); edtVerifyFileSFV.Enabled = false; btnVerifyFileSFV.Enabled = false; edtVerifySingleFile.Enabled = false; btnVerifySingleFile.Enabled = false; pbarVerifySystemScan.Value = 0; pbarVerifySystemScan.Minimum = 0; btnVerify.Click -= new EventHandler(this.VerifyScan); btnVerify.Click += new EventHandler(this.StopScan); myState = new CRCState(); try { //WHOLE RELEASE (NO SINGLE FILE) VALIDATION if ( (edtVerifyFileSFV.Text == "") || (edtVerifyFileSFV.TextLength == 0) ) { MessageBox.Show( this, "You have not entered a valid location path for your SFV File.", "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RestartScanCleanUp(); return; } else if ( (edtVerifyFileSFV.Text.Length < 2) || (edtVerifyFileSFV.Text.Substring( 0, 1 ) != "\\") && (edtVerifyFileSFV.Text.Substring( 1, 1 ) != "\\") ) { if ( (edtVerifyFileSFV.Text.Length < 2) || (edtVerifyFileSFV.Text.Substring( 1, 1 ) != ":" ) ) { MessageBox.Show( this, "You entered an invalid location path for your SFV. The location" + "\nyou wish to use must begin with a drive letter or network path. Some" + "\nexamples are: D:\\, or \\\\computername\\sharename, or C:\\dir", "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RestartScanCleanUp(); return; } } else if ( !(new FileInfo( edtVerifyFileSFV.Text ).Exists ) ) { MessageBox.Show( this, "The SFV File you chose to verify does not exist!\n" + "Please re-check the location path and retry the scan." , "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Information ); RestartScanCleanUp(); return; } //SINGLE FILE VALIDATION if ( chkVerifySingleFile.Checked ) { if ( (edtVerifySingleFile.Text == "") || (edtVerifySingleFile.Text.Length == 0) ) { MessageBox.Show( this, "You have not entered a valid location path for your Single File.", "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RestartScanCleanUp(); return; } else if ( (edtVerifySingleFile.Text.Length < 2) || (edtVerifySingleFile.Text.Substring( 0, 1 ) != "\\") && (edtVerifySingleFile.Text.Substring( 1, 1 ) != "\\") ) { if ( (edtVerifySingleFile.Text.Length < 2) || (edtVerifySingleFile.Text.Substring( 1, 1 ) != ":" ) ) { MessageBox.Show( this, "You entered an invalid location path for your Single File. The location" + "\nyou wish to use must begin with a drive letter or network path. Some" + "\nexamples are: D:\\, or \\\\computername\\sharename, or C:\\dir", "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); RestartScanCleanUp(); return; } } else if ( !(new FileInfo( this.edtVerifySingleFile.Text ).Exists ) ) { MessageBox.Show( this, "The Single File you chose to verify does not exist!\n" + "Please re-check the location path and retry the scan." , "Invalid Scan Location", MessageBoxButtons.OK, MessageBoxIcon.Information ); RestartScanCleanUp(); return; } //if singlefile + all is valid then add to mystate myState.boolSingleFile = true; myState.strSingleFile = StripPath(edtVerifySingleFile.Text); } //PUT SETTINGS INTO myState (required as the new thread cant cross thread call to UI) if ( chkVerifyShowFailed.Checked ) { myState.boolShowFailed = true; } if ( chkVerifyUnrar.Checked ) { myState.boolUnrar = true; } if ( chkVerifyDel.Checked ) { myState.boolDelRars = true; } if ( chkVerifyDelSFV.Checked ) { myState.boolDelSFV = true; } if ( chkVerifyBG.Checked ) { myState.boolVerBG = true; } //RUN PROGRAM IN BACKGROUND MINIMISED TO TRAY if ( chkVerifyBG.Checked ) { this.Hide(); } //RUN CHECK AND VERIFY myState.setSFVFileNames(edtVerifyFileSFV.Text); dtVerifyScanStart = DateTime.Now; VerifyCRCThread = new System.Threading.Thread( new System.Threading.ThreadStart( VerifyCRC )); VerifyCRCThread.IsBackground = true; VerifyCRCThread.Name = "Verify File CRC"; VerifyCRCThread.Priority = System.Threading.ThreadPriority.Normal; VerifyCRCThread.Start(); } catch ( System.Threading.ThreadAbortException se ) { RestartScanCleanUp(); return; } catch ( System.ArgumentException se ) { RestartScanCleanUp(); return; } }