/// <summary>
        /// Clear the control of readers, get readers and display.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRefresh_Click(System.Object sender, System.EventArgs e)
        {
            cboReaders.Text = string.Empty;
            cboReaders.Items.Clear();
            cboReaders.SelectedIndex = -1;

            try
            {
                _readers = ReaderCollection.GetReaders();

                foreach (Reader Reader in _readers)
                {
                    cboReaders.Items.Add(Reader.Description.SerialNumber);
                }

                if (cboReaders.Items.Count > 0)
                {
                    cboReaders.SelectedIndex = 0;
                    btnCaps.Enabled          = true;
                    btnSelect.Enabled        = true;
                }
                else
                {
                    btnSelect.Enabled = false;
                    btnCaps.Enabled   = false;
                    _sender.txtReaderSelected.Text = "";
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                //message box:
                String text = ex.Message;
                text += "\r\n\r\nPlease check if DigitalPersona service has been started";
                String caption = "Cannot access readers";
                MessageBox.Show(text, caption);
            }
        }
Exemple #2
0
 private void CargarLectores()
 {
     try
     {
         cboLectores.Items.Clear();
         readers = ReaderCollection.GetReaders();
         foreach (Reader rd in readers)
         {
             cboLectores.Items.Add(rd.Description.SerialNumber);
         }
         if (cboLectores.Items.Count > 0)
         {
             cboLectores.SelectedIndex = 0;
         }
     }
     catch (ArgumentOutOfRangeException ex)
     {
         Clases.CFuncionesGenerales.MensajeError("Indice fuera de rango.", ex);
     }
     catch (ArgumentNullException ex)
     {
         Clases.CFuncionesGenerales.MensajeError("No se pueden agregar argumentos nulos a un ComboBox.", ex);
     }
 }
Exemple #3
0
        public VerificationForm(AppWindow owner)
        {
            InitializeComponent();

            //this.Dock = DockStyle.Fill;
            //this.BackColor = Color.White;

            //picVerification = new PictureBox()
            //{
            //    Location = new Point(20, 20),
            //    Size = new Size(100, 100)
            //};
            //this.Controls.Add(picVerification);

            //btnScan = new Button()
            //{
            //    Location = new Point(picVerification.Left, picVerification. Bottom + 10),
            //    Size = new Size(100, 25)
            //};
            //this.Controls.Add(btnScan);

            //this.Load += VerificationForm_Load;
            ReaderCollection rc = ReaderCollection.GetReaders();
        }
Exemple #4
0
 public DigitalPersona()
 {
     _readers = ReaderCollection.GetReaders();
     if (_readers.Count > 0)
     {
         _reader = _readers[0];
         if (!OpenReader())
         {
             _exception = new Exception("");
         }
         else
         {
             if (!(_reader is null))
             {
                 _name         = _reader.Description.Id.ProductName;
                 _manufacturer = _reader.Description.Id.VendorName;
                 _vendorID     = _reader.Description.Id.VendorId.ToString();
                 _productID    = _reader.Description.Id.ProductId.ToString();
             }
             else
             {
                 _exception = new Exception("DigitalPersona reader is null.");
             }
         }
Exemple #5
0
        public FingerPrint()
        {
            var _readers = ReaderCollection.GetReaders();

            CurrentReader = _readers.FirstOrDefault();
        }
Exemple #6
0
        private void deviceThread()
        {
            List <Fmd>    preenrollmentFmds = new List <Fmd>();
            Reader        activeReader      = null;
            CaptureResult captureResult;
            STATE         state       = STATE.IDLE;
            COMMAND       com         = COMMAND.NONE;
            int           enrollCount = 0;

            try
            {
                ReaderCollection readers = ReaderCollection.GetReaders();

                foreach (var reader in readers)
                {
                    if (reader.Description.Name == Id)
                    {
                        activeReader = reader;
                        break;
                    }
                }
                if (activeReader != null)
                {
                    activeReader.Open(Constants.CapturePriority.DP_PRIORITY_EXCLUSIVE);
                }

                while (true)
                {
                    cancelToken.Token.ThrowIfCancellationRequested();

                    if (state == STATE.IDLE)
                    {
                        com = queue.Take(cancelToken.Token);
                    }
                    else
                    {
                        // non blocking take
                        if (queue.Count > 0)
                        {
                            com = queue.Take();
                        }
                    }

                    StopOngoingStream(ref state, activeReader, com);
                    switch (com)
                    {
                    case COMMAND.LIVECAPTURE_START:
                        activeReader.StartStreaming();
                        state = STATE.TEST;
                        break;

                    case COMMAND.LIVECAPTURE_STOP:
                        state = STATE.IDLE;
                        break;

                    case COMMAND.SINGLECAPTURE_START:
                        state = STATE.GETSINGLE;
                        break;

                    case COMMAND.SINGLECAPTURE_STOP:
                        state = STATE.IDLE;
                        break;

                    case COMMAND.ENROLLMENT_START:
                        state       = STATE.GETFINGER;
                        enrollCount = 0;
                        preenrollmentFmds.Clear();
                        resultBios.Clear();
                        break;

                    case COMMAND.ENROLLMENT_STOP:
                        state = STATE.IDLE;
                        break;
                    }
                    com = COMMAND.NONE;

                    switch (state)
                    {
                    case STATE.TEST:
                        SendBaseMessage("Please, touch the scanner");
                        captureResult = activeReader.GetStreamImage(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, activeReader.Capabilities.Resolutions[0]);
                        if (captureResult.ResultCode == Constants.ResultCode.DP_DEVICE_FAILURE || captureResult.ResultCode == Constants.ResultCode.DP_DEVICE_BUSY)
                        {
                            Console.WriteLine("DEVICE_FAILURE, perfoming RESET" + captureResult.ResultCode);
                            activeReader.Reset();
                            activeReader.StartStreaming();
                            break;
                        }
                        if (!CheckIfReaderIsOnline(captureResult, activeReader))
                        {
                            state = STATE.IDLE;
                            break;
                        }

                        if (captureResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                        {
                            OnBiometricsCaptured(new FingerImageDP(captureResult.Data));
                        }
                        else
                        {
                            System.Console.WriteLine(captureResult.ResultCode);
                        }
                        break;

                    case STATE.GETSINGLE:
                        state = STATE.GETSINGLEIMAGE;
                        SendBaseMessage("Please, touch the scanner");
                        break;

                    case STATE.GETSINGLEIMAGE:
                        captureResult = activeReader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, 50, activeReader.Capabilities.Resolutions[0]);

                        if (!CheckIfReaderIsOnline(captureResult, activeReader))
                        {
                            state = STATE.IDLE;
                            break;
                        }

                        if (!CheckCaptureResult(captureResult))
                        {
                            break;
                        }

                        OnSingleCaptured(new FingerImageDP(captureResult.Data));

                        state = STATE.GETSINGLE;

                        break;

                    case STATE.GETFINGER:
                        SendBaseMessage("Put finger on the scanner and then lift it up, when Image is captured");
                        state = STATE.GETIMAGE;
                        break;

                    case STATE.GETIMAGE:
                        captureResult = activeReader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, 50, activeReader.Capabilities.Resolutions[0]);

                        if (!CheckIfReaderIsOnline(captureResult, activeReader))
                        {
                            state = STATE.IDLE;
                            break;
                        }

                        if (!CheckCaptureResult(captureResult))
                        {
                            break;
                        }

                        FingerImageDP image = new FingerImageDP(captureResult.Data);
                        OnBiometricsCaptured(image);
                        enrollCount++;

                        OnSendProgressMessage(enrollCount * 20);
                        var template = _devControl.Extract(image);
                        if (template == null)
                        {
                            OnBiometricsEnrolled(null);
                            break;
                        }

                        preenrollmentFmds.Add((template as TemplateDP).fmd);

                        if (enrollCount > 4)
                        {
                            state = STATE.IDLE;
                            DataResult <Fmd> resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                            if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                            {
                                resultBios.Add(new TemplateDP(resultEnrollment.Data));
                                SendPopUpMessage("Successfully registered");
                                OnBiometricsEnrolled(resultBios.ToList());
                                break;
                            }
                            SendPopUpMessage("Can't create template, please repeat");
                            OnBiometricsEnrolled(null);
                        }
                        else
                        {
                            state = STATE.GETFINGER;
                        }

                        break;

                    case STATE.IDLE:
                        break;
                    }
                }
            }
            catch
            {
            }

            finally
            {
                activeReader.Reset();
            }
        }
Exemple #7
0
        //In Load lets enumerate and open fingerprint reader
        private void IdentifyDlg_Load(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.None;
            ReaderCollection readers = ReaderCollection.GetReaders();

            if (readers.Count == 0)
            {
                MessageBox.Show("Registration requires a plugged in fingerprint reader.");
                readers.Dispose();
                readers = null;
                this.Close();
                return;
            }

            if (readers.Count > 1)
            {
                MessageBox.Show("This sample is designed for a single connected reader.  Please connect only 1 device.");
                readers.Dispose();
                readers = null;
                this.Close();
                return;
            }

            reader = readers[0];

            if (reader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE) != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Could not open device.");
                readers.Dispose();
                readers = null;
                this.Close();
                return;
            }

            if (reader.GetStatus() != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Error getting device status.");
                readers.Dispose();
                readers = null;
                this.Close();
                return;
            }

            if (reader.Status.Status != Constants.ReaderStatuses.DP_STATUS_READY)
            {
                MessageBox.Show("Device not ready.  Try again in a few seconds.");
                readers.Dispose();
                readers = null;
                this.Close();
                return;
            }

            HelperFunctions.LoadAllUsers();

            reader.On_Captured += new Reader.CaptureCallback(reader_On_Captured);

            Constants.ResultCode captureResult = reader.CaptureAsync(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, reader.Capabilities.Resolutions[0]);

            if (captureResult != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Error CaptureResult: " + captureResult.ToString());
            }
        }