using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Windows.Forms;
namespace Nasrullah.WPF { /// /// Interaction logic for TestFacebookLogin.xaml /// public partial class TestFacebookLogin : Window { public TestFacebookLogin() { InitializeComponent();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using Nasrullah.Properties;
using Nasrullaht.Controller;
namespace Reactive.ActivityControl.Register
{
/// /// Interaction logic for frmEnrollment.xaml ///
public partial class frmEnrollment : Window, DPFP.Capture.EventHandler
{
protected void Process(DPFP.Sample Sample)
{
// Process the sample and create a feature set for the enrollment purpose.
DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Enrollment);
// Check quality of the sample and add to enroller if it's good
if (features != null) try
{
SetPrompt("The fingerprint feature set was created.");
Enroller.AddFeatures(features); // Add feature set to template.
}
finally
{
// Check if template has been created.
switch (Enroller.TemplateStatus)
{
case DPFP.Processing.Enrollment.Status.Ready: // report success and stop capturing
// OnTemplate(Enroller.Template);
// Call Login and pass in template.
SetPrompt("Click Close, and then click Fingerprint Verification.");
Stop();
// Set stream for array of bytes
MemoryStream ms = new MemoryStream(Enroller.Template.Bytes);
bool status = false;
pCustomerDetail icustomerdetailobj = new pCustomerDetail();
icustomerdetailobj.CustomerID = customerId;
icustomerdetailobj.FingerTemplate = ms.ToArray(); // save array of bytes in DB
bCustomerDetail bCustomerdetailobj = new bCustomerDetail();
status = bCustomerdetailobj.SaveCustomerDetail(icustomerdetailobj);
if (!status)
MessageBox.Show("Information not saved successfully");
else
{
MessageBox.Show("Information saved successfully");
//Closet the current window
this.Dispatcher.Invoke(new Function(delegate()
{
Stop();
this.Close();
}));
}
break;
case DPFP.Processing.Enrollment.Status.Failed: // report failure and restart capturing
Enroller.Clear();
Stop();
OnTemplate(null);
Start();
break;
}
}
}
protected void Start()
{
if (null != Capturer)
{
try
{
SetPrompt("Using the fingerprint reader, scan your fingerprint.");
Capturer.StartCapture();
}
catch
{
SetPrompt("Can't initiate capture!");
}
}
}
#region EventHandler Members
public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
{
SetPrompt("The fingerprint sample was captured.");
Process(Sample);
}
public void OnFingerGone(object Capture, string ReaderSerialNumber)
{
SetPrompt("The finger was removed from the fingerprint reader.");
}
public void OnFingerTouch(object Capture, string ReaderSerialNumber)
{
SetPrompt("The fingerprint reader was touched.");
}
public void OnReaderConnect(object Capture, string ReaderSerialNumber)
{
SetPrompt("The fingerprint reader was connected.");
}
public void OnReaderDisconnect(object Capture, string ReaderSerialNumber)
{
SetPrompt("The fingerprint reader was disconnected.");
}
public void OnSampleQuality(object Capture, string ReaderSerialNumber, DPFP.Capture.CaptureFeedback CaptureFeedback)
{
if (CaptureFeedback == DPFP.Capture.CaptureFeedback.Good)
SetPrompt("The quality of the fingerprint sample is good.");
else
SetPrompt("The quality of the fingerprint sample is poor.");
}
#endregion
protected DPFP.FeatureSet ExtractFeatures(DPFP.Sample Sample, DPFP.Processing.DataPurpose Purpose)
{
DPFP.Processing.FeatureExtraction Extractor = new DPFP.Processing.FeatureExtraction(); // Create a feature extractor
DPFP.Capture.CaptureFeedback feedback = DPFP.Capture.CaptureFeedback.None;
DPFP.FeatureSet features = new DPFP.FeatureSet();
Extractor.CreateFeatureSet(Sample, Purpose, ref feedback, ref features); // TODO: return features as a result?
if (feedback == DPFP.Capture.CaptureFeedback.Good)
return features;
else
return null;
}