private void Run(CorrectedPage p) { p.AnalyzeGraphical(criteriumSure, criteriumDoubt); if (!p.Status.AnyError() && p.PageNumber > -1) // Passed all error checks { p.AnalyzeTooManyAndDoubts(); } Application.DoEvents(); }
private void Calibrate(List <string> fileNames) { try // Number of files == pages in test (already checked) { var frmProc = new frmProcessing(this); frmProc.Show(); var correctPageNumbers = new List <int>(); var colDist = new ColorDistribution(); // Better not do this in parallel (colDist is shared); most of the time this is one page only anyway for (int i = 0; i < fileNames.Count; i++) { using (var cPage = new CorrectedPage(fileNames[i])) { cPage.AnalyzeGraphical(criteriumSure, criteriumDoubt); if (cPage.PageNumber > -1) // Passed all error checks { correctPageNumbers.Add(cPage.PageNumber); colDist.Add(cPage.CheckImage.ColorDistribution.Values); } } } frmProc.Dispose(); bool pagesOk = true; if (correctPageNumbers.Count == Program.Test.Pages.Count) { for (int i = 0; i < correctPageNumbers.Count; i++) { if (!correctPageNumbers.Contains(i)) { pagesOk = false; break; } } } else { pagesOk = false; } if (pagesOk) { using (var frm = new frmCalibrationResults(colDist)) { frm.ShowDialog(); } } else { #if DEBUG if (MessageBox.Show("The barcode of the file you selected could not be read correctly or doesn't match the open test.\r\nDo you want to continue the calibration? " + "Try again with barcode check turned off?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { Settings.IgnoreBarCodeErrors = true; Calibrate(fileNames); Settings.IgnoreBarCodeErrors = false; } #else MessageBox.Show(Convert.ToString(Program.Test.Pages.Count - CorrectedPages.Count) + " of the selected images could not be used for calibration. " + "Make sure the images you're trying to use correspond to the current test. Consider scanning images again using higher quality settings.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); #endif } } catch (Exception ex) { MessageBox.Show("Calibration failed: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }