示例#1
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox1.Checked)
     {
         checkBox2.Checked = false;
         checkBox3.Checked = false;
         checkBox4.Checked = false;
         checkBox5.Checked = false;
         CM = ConnMethod.Clear;
         PM = PrMethod.low;
         button1.Enabled = true;
     }
 }
示例#2
0
 private void checkBox5_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox5.Checked)
     {
         checkBox1.Checked = false;
         checkBox2.Checked = false;
         checkBox3.Checked = false;
         checkBox4.Checked = false;
         groupBox2.Visible = true;
         groupBox3.Visible = true;
         groupBox4.Visible = true;
         PM = PrMethod.custom;
         button1.Enabled = true;
     }
     else
     {
         groupBox2.Visible = false;
         groupBox3.Visible = false;
         groupBox4.Visible = false;
     }
 }
示例#3
0
 public NetworkSetup(ConnectionMethod.ConnMethod CM, PrMethod PM)
 {
     InitializeComponent();
     this.CM = CM;
     this.PM = PM;
     if (PM == PrMethod.custom)
     {
         button1.Enabled = true;
         button2.Enabled = true;
         button3.Enabled = true;
     }
     if (CM == ConnectionMethod.ConnMethod.Clear)
     {
         button1.Enabled = true;
     }
     else if (CM == ConnectionMethod.ConnMethod.I2P)
     {
         button3.Enabled = true;
     }
     else if (CM == ConnectionMethod.ConnMethod.Tor)
     {
         button2.Enabled = true;
     }
 }
示例#4
0
        private void backgroundWorkerListen_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            ARHScanner sc = e.Result as ARHScanner;

            if (sc != null && ErrorCode == 0)
            {
                //if (sc.DeviceState == (int)pr.PR_TESTDOC.PR_TD_OUT && !_noOut)
                if (sc.DeviceState == (int)Pr22.Util.PresenceState.Empty && !_noOut)
                {
                    _noOut = true;

                    if (toolStripStatusLabelError.Text == "Image processing...")
                        toolStripStatusLabelError.Text = "";

                    tabControl1.TabPages[0].Tag = "No barcode found";
                    tabControl1.TabPages[1].Tag = "No MRZ found";

                    button1.Enabled = true;
                    button1.Focus();
                }
                //else if (sc.DeviceState == (int)pr.PR_TESTDOC.PR_TD_NOMOVE && !_noMove)
                else if (sc.DeviceState == (int)Pr22.Util.PresenceState.NoMove && !_noMove)
                {
                    _noMove = true;
                    _noOut = false;

                    button1.Enabled = false;
                    button2.Enabled = false;
                    button3.Enabled = false;

                    ShowStatusMessage("Image processing...");
                    startProgressBar();

                    textBox1.Text = "";
                    pictureBox1.Image = null;
                    pictureBox1.BorderStyle = BorderStyle.None;
                    textBox2.Text = "";
                    pictureBox2.Image = null;
                    pictureBox2.BorderStyle = BorderStyle.None;
                    textBox3.Text = "";

                    //System.Threading.Thread.Sleep(100);
                    Application.DoEvents();

                    PrMethod[] delegates = new PrMethod[] {
                                                    sc.prCaptureImage,
                                                    sc.prCaptureBarcode,
                                                    sc.prGetGTIN,
                                                    sc.prGetBarcodeData,
                                                    sc.prGetBarcodeImage,
                                                    sc.prSaveBarcodeImage,
                                                    sc.prReleaseDocument,
                                                    sc.prCaptureMRZ,
                                                    sc.prGetMRZData,
                                                    sc.prGetMRZImage,
                                                    sc.prSaveMRZImage,
                                                    sc.prReleaseDocument
                                                };

                    foreach (PrMethod prMethod in delegates)
                    {
                        if (prMethod.Method.Name == "prGetBarcodeData" ||
                            prMethod.Method.Name == "prGetMRZData")
                        {
                            IList list = new ArrayList();
                            if (prMethod.Method.Name == "prGetBarcodeData")
                                ErrorCode = sc.prGetBarcodeData(list);
                            else
                                ErrorCode = sc.prGetMRZData(list);

                            if (ErrorCode != 0)
                            {
                                break;
                            }

                            if (list.Count != 0)
                            {
                                StringBuilder sb = new StringBuilder();
                                for (int i = 0; i < list.Count; i++)
                                {
                                    sb.Append(list[i]);
                                    sb.Append(Environment.NewLine);
                                }
                                if (prMethod.Method.Name == "prGetBarcodeData")
                                    textBox1.Text = sb.ToString();
                                else
                                    textBox2.Text = sb.ToString();
                            }

                            if (prMethod.Method.Name == "prGetBarcodeData")
                                textBox1.Select(0, 0);
                            else
                                textBox2.Select(0, 0);
                        }
                        else if (prMethod.Method.Name == "prGetBarcodeImage" ||
                                prMethod.Method.Name == "prGetMRZImage")
                        {
                            GetImage method;
                            if (prMethod.Method.Name == "prGetBarcodeImage")
                            {
                                //IntPtr hDc = GetWindowDC(pictureBox1.Handle);
                                //sc.prGetBarcodeImage(hDc);
                                //ReleaseDC(pictureBox1.Handle, hDc);

                                method = new GetImage(sc.prGetBarcodeImage);
                                ErrorCode = ShowImage(method, pictureBox1);
                            }
                            else
                            {
                                method = new GetImage(sc.prGetMRZImage);
                                ErrorCode = ShowImage(method, pictureBox2);
                            }

                            if (ErrorCode != 0)
                            {
                                break;
                            }
                        }
                        else if (prMethod.Method.Name == "prGetGTIN")
                        {
                            if ((ErrorCode = sc.prGetGTIN(out _gtin, out _barcodeType)) != 0)
                            {
                                break;
                            }
                        }
                        else
                        {
                            ErrorCode = prMethod();

                            switch (prMethod.Method.Name)
                            {
                                case "prCaptureBarcode":
                                    if (ErrorCode == 1303)
                                        tabControl1.TabPages[0].Tag = sc.ErrorMessage;
                                    else
                                        tabControl1.TabPages[0].Tag = "";
                                    break;
                                case "prCaptureMRZ":
                                    if (ErrorCode == 1303)
                                        tabControl1.TabPages[1].Tag = sc.ErrorMessage;
                                    else
                                        tabControl1.TabPages[1].Tag = "";
                                    break;

                                //case "prSaveBarcodeImage":
                                //ShowImage(pictureBox1, "barcode.jpg");
                                //  break;
                                //case "prSaveMRZImage":
                                //ShowImage(pictureBox2, "mrz.jpg");
                                //  break;
                            }

                            if (ErrorCode == 1303)
                                ErrorCode = 0;

                            if (ErrorCode != 0)
                            {
                                break;
                            }
                        }

                        button1.Enabled = true;
                        button1.Focus();

                        Application.DoEvents();
                    }   // end of foreach

                    if (ErrorCode == 0)
                        ShowStatusMessage("");
                    else
                        ShowError(sc);

                    Application.DoEvents();

                    foreach (TabPage page in tabControl1.TabPages)
                    {
                        if (!String.IsNullOrEmpty(page.Tag as string))
                        {
                            if (page.Equals(tabControl1.SelectedTab))
                            {
                                toolStripStatusLabelError.Text = page.Tag as string;
                            }
                            else
                            {
                                if (String.IsNullOrEmpty(toolStripStatusLabelError.Text))
                                    ShowStatusMessage(page.Tag as string);
                            }

                            toolStripStatusLabelError.ForeColor = Color.Red;
                        }
                        /*
                                                else
                                                {
                                                    if (!page.Equals(tabControl1.SelectedTab))
                                                        tabControl1.SelectTab(page.Name);
                                                }
                        */
                    }
                }
                //else if (sc.DeviceState != (int)pr.PR_TESTDOC.PR_TD_NOMOVE)
                else if (sc.DeviceState != (int)Pr22.Util.PresenceState.NoMove)
                    _noMove = false;

                stopProgressBar();

                button1.Enabled = true;

                if (_barcodeType.StartsWith("EAN") || _barcodeType.StartsWith("UPC"))
                {
                    button2.Enabled = true;
                    button3.Enabled = true;
                }

                //button1.Focus();

                startListenProcess(sc);
            }
            else if (ErrorCode != 0)
                ShowError(sc);
        }