private void GoBackSecondStep(object sender, RoutedEventArgs e) { TxtBlock_FingerprintMessage.Text = "Place any of your finger on the device below."; studentInfo.Firstfinger = null; studentInfo.Lastfinger = null; fingerprint.CancelCaptureAndCloseReader(this.OnCaptured); Expander_ThirdStep.IsExpanded = false; Expander_ThirdStep.IsEnabled = false; Expander_SecondStep.IsEnabled = true; Expander_SecondStep.IsExpanded = true; }
private void OnCaptured(CaptureResult captureResult) { try { if (!fingerprintReader.CheckCaptureResult(captureResult)) { return; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI); if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { fingerprintReader.CurrentReader.Reset(); throw new Exception(captureResult.ResultCode.ToString()); } // See the SDK documentation for an explanation on threshold scores. int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; if (isAdminLogin) { IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, AdminFingerPrints.ToArray(), thresholdScore, AdminFingerPrints.Count); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length > 0) { fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured); Application.Current.Dispatcher.Invoke((Action) delegate { AdminDashboard adminDashboard = new AdminDashboard(); adminDashboard.CurrentAdminId = AdminId.ElementAt(identifyResult.Indexes[0][0]); adminDashboard.Show(); fingerprintReader.CurrentReader.Dispose(); fingerprintReader.CurrentReader = null; this.Close(); }); } } else { IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, StudenFingerPrints.ToArray(), thresholdScore, StudenFingerPrints.Count); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length > 0) { fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured); Application.Current.Dispatcher.Invoke((Action) delegate { StudentDashboard studentDash = new StudentDashboard(StudentId.ElementAt(identifyResult.Indexes[0][0]).ToString(), database); studentDash.Show(); fingerprintReader.CurrentReader.Dispose(); fingerprintReader.CurrentReader = null; this.Close(); }); } } } catch (Exception) { Application.Current.Dispatcher.Invoke((Action) delegate { ErrorHeader1.Text = "Fingerprint device error"; ErrorContent1.Text = "Error while capturing the fingerprint."; DialogMessage1.IsOpen = true; }); } }
private void OnCaptured(CaptureResult captureResult) { try { if (!fingerprintReader.CheckCaptureResult(captureResult)) { return; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI); if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { fingerprintReader.CurrentReader.Reset(); Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nError\nPlease try again.\nPlace your finger on the device."); }); throw new Exception(captureResult.ResultCode.ToString()); } if (isFingerprintDataExist(resultConversion.Data)) { firstFinger = null; secondFinger = null; MessageBox.Show("It seems that there's slightly the same fingerprint data as yours.\n\nPlease use your other fingers.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nPlace any finger on the device."); }); } else { if (firstFinger == null) { firstFinger = resultConversion.Data; Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nFinger was captured\nNow Place the same finger on the device."); }); } else { if (secondFinger == null) { secondFinger = resultConversion.Data; Fmd[] fmds = new Fmd[1]; fmds[0] = firstFinger; // See the SDK documentation for an explanation on threshold scores. int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; IdentifyResult identifyResult = Comparison.Identify(secondFinger, 0, fmds, thresholdScore, 1); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { throw new Exception(identifyResult.ResultCode.ToString()); } if (identifyResult.Indexes.Length <= 0) { Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nFailed, first finger and second finger not matched.\nPlease try again, place any finger on the device."); firstFinger = null; secondFinger = null; }); } else { Application.Current.Dispatcher.Invoke((Action) delegate { richTextBox.Document.Blocks.Clear(); richTextBox.AppendText("\nSuccess, please submit your registration now."); btn_submit.IsEnabled = true; }); fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured); } } } } } catch (Exception ex) { MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Dispatcher.Invoke((Action) delegate { fingerprintReader.CurrentReader.Dispose(); fingerprintReader.CurrentReader = null; this.Close(); }); } }