private void btn_scan_Click(object sender, RoutedEventArgs e)
        {
            int total_sheets = Convert.ToInt16(this.txt_sheet_count.Text);
            scanned_files = new List<string>(total_sheets);
            bool scanner_flag = false;
            Scanner.Scanner scanner = null;
            try
            {
                scanner = new Scanner.Scanner();
                
            }
            catch (Exception expcep)
            {
                scanner_flag = true;
                MessageBox.Show(" Scanner has not been detected. Please turn on your scanner and connect to the system and make sure it has been detected by Windows.\n The application will now shut down", "Scanner not detected.",
                    MessageBoxButton.OK, MessageBoxImage.Exclamation);

            }
            
            if (scanner_flag == true)
            {
                Application.Current.Shutdown();
            }
            else
            {
                
                List<OMRSoft.OMRSoft> sheets = new List<OMRSoft.OMRSoft>(total_sheets);
                for (int i = 0; i < total_sheets; ++i)
                {
                    MessageBox.Show("Place Sheet on the scanner and close the lid.", "Next Sheet", MessageBoxButton.OK, MessageBoxImage.Information);
                    string file = Worker.scanned_img_dir + "/Scan_" + Worker.scanned_image_index.ToString() + ".jpg";
                    Worker.scanned_image_index++;

                    Scanner.Scanner scanner1 = new Scanner.Scanner();
                    scanner1.scan(XMLRead.Scanner_DPI.dpi_value);
                    scanner1.save(file);
                    scanned_files.Add(file);
                    preview_window.Source = new BitmapImage( new Uri(file));
                    OMRSoft.OMRSoft sh = new OMRSoft.OMRSoft(file);
                    sh.PreProcess();
                    sh.blob_detect();
                    sh.generate_results(sheet);
                    sheets.Add(sh);
                    lbl_scanned_count.Content = (i+1).ToString();
                }

                Save_to_DB new_window = new Save_to_DB(sheets, scanned_files, total_sheets);
                new_window.ShowDialog();
            }
            

            
        }
Exemple #2
0
        private void btn_scan_Click(object sender, RoutedEventArgs e)
        {
            int total_sheets = Convert.ToInt16(this.txt_sheet_count.Text);

            scanned_files = new List <string>(total_sheets);
            bool scanner_flag = false;

            Scanner.Scanner scanner = null;
            try
            {
                scanner = new Scanner.Scanner();
            }
            catch (Exception expcep)
            {
                scanner_flag = true;
                MessageBox.Show(" Scanner has not been detected. Please turn on your scanner and connect to the system and make sure it has been detected by Windows.\n The application will now shut down", "Scanner not detected.",
                                MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }

            if (scanner_flag == true)
            {
                Application.Current.Shutdown();
            }
            else
            {
                List <OMRSoft.OMRSoft> sheets = new List <OMRSoft.OMRSoft>(total_sheets);
                for (int i = 0; i < total_sheets; ++i)
                {
                    MessageBox.Show("Place Sheet on the scanner and close the lid.", "Next Sheet", MessageBoxButton.OK, MessageBoxImage.Information);
                    string file = Worker.scanned_img_dir + "/Scan_" + Worker.scanned_image_index.ToString() + ".jpg";
                    Worker.scanned_image_index++;

                    Scanner.Scanner scanner1 = new Scanner.Scanner();
                    scanner1.scan(XMLRead.Scanner_DPI.dpi_value);
                    scanner1.save(file);
                    scanned_files.Add(file);
                    preview_window.Source = new BitmapImage(new Uri(file));
                    OMRSoft.OMRSoft sh = new OMRSoft.OMRSoft(file);
                    sh.PreProcess();
                    sh.blob_detect();
                    sh.generate_results(sheet);
                    sheets.Add(sh);
                    lbl_scanned_count.Content = (i + 1).ToString();
                }

                Save_to_DB new_window = new Save_to_DB(sheets, scanned_files, total_sheets);
                new_window.ShowDialog();
            }
        }