Beispiel #1
0
        private void btnSelectionUpdateTemplate_Click(object sender, EventArgs e)
        {
            UFD_STATUS ufd_res;
            int        Serial;

            if (lvDatabaseList.SelectedIndices.Count == 0)
            {
                tbxMessage.AppendText("Select data\r\n");
                return;
            }
            else
            {
                Serial = Convert.ToInt32(lvDatabaseList.SelectedItems[0].SubItems[DATABASE_COL_SERIAL].Text);
            }

            if (!ExtractTemplate(m_Template1, out m_Template1Size))
            {
                return;
            }

            DrawCapturedImage(m_Scanner);

            ufd_res = m_Database.UpdateDataBySerial(Serial, m_Template1, m_Template1Size, null, 0, null);
            if (ufd_res == UFD_STATUS.OK)
            {
                tbxMessage.AppendText("UFD_UpdateDataBySerial: OK\r\n");
                UpdateDatabaseList();
            }
            else
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase UpdateDataBySerial: " + m_strError + "\r\n");
            }
        }
Beispiel #2
0
        private void btnSelectionDelete_Click(object sender, EventArgs e)
        {
            UFD_STATUS ufd_res;
            int        Serial;

            if (lvDatabaseList.SelectedIndices.Count == 0)
            {
                tbxMessage.AppendText("Select data\r\n");
                return;
            }
            else
            {
                Serial = Convert.ToInt32(lvDatabaseList.SelectedItems[0].SubItems[DATABASE_COL_SERIAL].Text);
            }

            ufd_res = m_Database.RemoveDataBySerial(Serial);
            if (ufd_res == UFD_STATUS.OK)
            {
                tbxMessage.AppendText("UFDatabase RemoveDataBySerial: OK\r\n");
                UpdateDatabaseList();
            }
            else
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase RemoveDataBySerial: " + m_strError + "\r\n");
            }
        }
Beispiel #3
0
        private void btnEnroll_Click(object sender, EventArgs e)
        {
            if (!ExtractTemplate(m_Template1, out m_Template1Size))
            {
                return;
            }

            DrawCapturedImage(m_Scanner);

            UserInfoForm dlg = new UserInfoForm(false);
            UFD_STATUS   ufd_res;

            tbxMessage.AppendText("Input user data\r\n");
            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                tbxMessage.AppendText("User data input is cancelled by user\r\n");
                return;
            }

            ufd_res = m_Database.AddData(dlg.UserID, dlg.FingerIndex, m_Template1, m_Template1Size, null, 0, dlg.Memo);

            if (ufd_res != UFD_STATUS.OK)
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase AddData: " + m_strError + "\r\n");
            }
            else
            {
                cbScanTemplateType.Enabled = false;
            }

            UpdateDatabaseList();
        }
Beispiel #4
0
        private void btnSelectionVerify_Click(object sender, EventArgs e)
        {
            UFD_STATUS ufd_res;
            UFM_STATUS ufm_res;
            int        Serial;

            // Input finger data
            byte[] Template = new byte[MAX_TEMPLATE_SIZE];
            int    TemplateSize;
            //
            bool VerifySucceed;

            if (lvDatabaseList.SelectedIndices.Count == 0)
            {
                tbxMessage.AppendText("Select data\r\n");
                return;
            }
            else
            {
                Serial = Convert.ToInt32(lvDatabaseList.SelectedItems[0].SubItems[DATABASE_COL_SERIAL].Text);
            }

            ufd_res = m_Database.GetDataBySerial(Serial,
                                                 out m_UserID, out m_FingerIndex, m_Template1, out m_Template1Size, m_Template2, out m_Template2Size, out m_Memo);
            if (ufd_res != UFD_STATUS.OK)
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase UpdateDataBySerial: " + m_strError + "\r\n");
                return;
            }

            if (!ExtractTemplate(Template, out TemplateSize))
            {
                return;
            }

            DrawCapturedImage(m_Scanner);

            ufm_res = m_Matcher.Verify(Template, TemplateSize, m_Template1, m_Template1Size, out VerifySucceed);
            if (ufm_res != UFM_STATUS.OK)
            {
                UFMatcher.GetErrorString(ufm_res, out m_strError);
                tbxMessage.AppendText("UFMatcher Verify: " + m_strError + "\r\n");
                return;
            }

            if (VerifySucceed)
            {
                tbxMessage.AppendText("Verification succeed (Serial = " + Serial + ")\r\n");
            }
            else
            {
                tbxMessage.AppendText("Verification failed\r\n");
            }
        }
Beispiel #5
0
        private void btnIdentify_Click(object sender, EventArgs e)
        {
            UFD_STATUS ufd_res;
            UFM_STATUS ufm_res;

            // Input finger data
            byte[] Template = new byte[MAX_TEMPLATE_SIZE];
            int    TemplateSize;

            // DB data
            byte[][] DBTemplate     = null;
            int[]    DBTemplateSize = null;
            int[]    DBSerial       = null;
            int      DBTemplateNum;
            //
            int MatchIndex;

            ufd_res = m_Database.GetTemplateListWithSerial(out DBTemplate, out DBTemplateSize, out DBTemplateNum, out DBSerial);
            if (ufd_res != UFD_STATUS.OK)
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFD_GetTemplateListWithSerial: " + m_strError + "\r\n");
                return;
            }

            if (!ExtractTemplate(Template, out TemplateSize))
            {
                return;
            }

            DrawCapturedImage(m_Scanner);

            Cursor.Current = Cursors.WaitCursor;
            ufm_res        = m_Matcher.Identify(Template, TemplateSize, DBTemplate, DBTemplateSize, DBTemplateNum, 5000, out MatchIndex);
            Cursor.Current = this.Cursor;
            if (ufm_res != UFM_STATUS.OK)
            {
                UFMatcher.GetErrorString(ufm_res, out m_strError);
                tbxMessage.AppendText("UFMatcher Identify: " + m_strError + "\r\n");
                return;
            }

            if (MatchIndex != -1)
            {
                tbxMessage.AppendText("Identification succeed (Serial = " + DBSerial[MatchIndex] + ")\r\n");
            }
            else
            {
                tbxMessage.AppendText("Identification failed\r\n");
            }
        }
Beispiel #6
0
        private void btnDeleteAll_Click(object sender, EventArgs e)
        {
            UFD_STATUS ufd_res;

            ufd_res = m_Database.RemoveAllData();
            if (ufd_res == UFD_STATUS.OK)
            {
                tbxMessage.AppendText("UFDatabase RemoveAllData: OK\r\n");
                UpdateDatabaseList();
            }
            else
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase RemoveAllData: " + m_strError + "\r\n");
            }
        }
Beispiel #7
0
        private void btnUninit_Click(object sender, EventArgs e)
        {
            //=========================================================================//
            // Uninit scanner module
            //=========================================================================//
            UFS_STATUS ufs_res;

            Cursor.Current = Cursors.WaitCursor;
            ufs_res        = m_ScannerManager.Uninit();
            Cursor.Current = this.Cursor;
            if (ufs_res == UFS_STATUS.OK)
            {
                tbxMessage.AppendText("UFScanner Uninit: OK\r\n");
            }
            else
            {
                UFScanner.GetErrorString(ufs_res, out m_strError);
                tbxMessage.AppendText("UFScanner Uninit: " + m_strError + "\r\n");
            }
            //=========================================================================//

            //=========================================================================//
            // Close database
            //=========================================================================//
            UFD_STATUS ufd_res;

            if (m_Database != null)
            {
                ufd_res = m_Database.Close();
                if (ufd_res == UFD_STATUS.OK)
                {
                    tbxMessage.AppendText("UFDatabase Close: OK\r\n");
                }
                else
                {
                    UFDatabase.GetErrorString(ufd_res, out m_strError);
                    tbxMessage.AppendText("UFDatabase Close: " + m_strError + "\r\n");
                }
            }

            lvDatabaseList.Items.Clear();
            //=========================================================================//
        }
Beispiel #8
0
        private void UpdateDatabaseList()
        {
            if (m_Database == null)
            {
                return;
            }

            UFD_STATUS ufd_res;
            int        DataNumber;
            int        i;

            ufd_res = m_Database.GetDataNumber(out DataNumber);
            if (ufd_res == UFD_STATUS.OK)
            {
                tbxMessage.AppendText("UFDatabase GetDataNumber: " + DataNumber + "\r\n");
            }
            else
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase GetDataNumber: " + m_strError + "\r\n");
                return;
            }

            lvDatabaseList.Items.Clear();

            for (i = 0; i < DataNumber; i++)
            {
                ufd_res = m_Database.GetDataByIndex(i,
                                                    out m_Serial, out m_UserID, out m_FingerIndex, m_Template1, out m_Template1Size, m_Template2, out m_Template2Size, out m_Memo);
                if (ufd_res != UFD_STATUS.OK)
                {
                    UFDatabase.GetErrorString(ufd_res, out m_strError);
                    tbxMessage.AppendText("UFDatabase GetDataByIndex: " + m_strError + "\r\n");
                    return;
                }

                AddRow(m_Serial, m_UserID, m_FingerIndex, (m_Template1Size != 0), (m_Template2Size != 0), m_Memo);
            }
        }
Beispiel #9
0
        private void btnSelectionUpdateUserInfo_Click(object sender, EventArgs e)
        {
            UserInfoForm dlg = new UserInfoForm(true);
            UFD_STATUS   ufd_res;
            int          Serial;

            if (lvDatabaseList.SelectedIndices.Count == 0)
            {
                tbxMessage.AppendText("Select data\r\n");
                return;
            }
            else
            {
                Serial          = Convert.ToInt32(lvDatabaseList.SelectedItems[0].SubItems[DATABASE_COL_SERIAL].Text);
                dlg.UserID      = lvDatabaseList.SelectedItems[0].SubItems[DATABASE_COL_USERID].Text;
                dlg.FingerIndex = Convert.ToInt32(lvDatabaseList.SelectedItems[0].SubItems[DATABASE_COL_FINGERINDEX].Text);
                dlg.Memo        = lvDatabaseList.SelectedItems[0].SubItems[DATABASE_COL_MEMO].Text;
            }

            tbxMessage.AppendText("Update user data\r\n");
            tbxMessage.AppendText("UserID and FingerIndex will not be updated\r\n");
            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                tbxMessage.AppendText("User data input is cancelled by user\r\n");
                return;
            }

            ufd_res = m_Database.UpdateDataBySerial(Serial, null, 0, null, 0, dlg.Memo);
            if (ufd_res == UFD_STATUS.OK)
            {
                tbxMessage.AppendText("UFD_UpdateDataBySerial: OK\r\n");
                UpdateDatabaseList();
            }
            else
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase UpdateDataBySerial: " + m_strError + "\r\n");
            }
        }
Beispiel #10
0
        //=========================================================================//

        //=========================================================================//
        private void btnInit_Click(object sender, EventArgs e)
        {
            //=========================================================================//
            // Initilize scanners
            //=========================================================================//
            UFS_STATUS ufs_res;
            int        nScannerNumber;

            Cursor.Current = Cursors.WaitCursor;
            ufs_res        = m_ScannerManager.Init();
            Cursor.Current = this.Cursor;
            if (ufs_res == UFS_STATUS.OK)
            {
                tbxMessage.AppendText("UFScanner Init: OK\r\n");
            }
            else
            {
                UFScanner.GetErrorString(ufs_res, out m_strError);
                tbxMessage.AppendText("UFScanner Init: " + m_strError + "\r\n");
                return;
            }

            nScannerNumber = m_ScannerManager.Scanners.Count;
            tbxMessage.AppendText("UFScanner GetScannerNumber: " + nScannerNumber + "\r\n");

            if (nScannerNumber == 0)
            {
                tbxMessage.AppendText("There's no available scanner\r\n");
                return;
            }
            else
            {
                tbxMessage.AppendText("First scanner will be used\r\n");
            }

            m_Scanner = m_ScannerManager.Scanners[0];
            //=========================================================================//

            //=========================================================================//
            // Open database
            //=========================================================================//
            UFD_STATUS ufd_res;

            m_Database = new UFDatabase();

            // Generate connection string
            string szDataSource;
            string szConnection;

            /*
             * szDataSource = "UFDatabase.mdb";
             * /*/
            tbxMessage.AppendText("Select a database file\r\n");
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.FileName   = "UFDatabase.mdb";
            dlg.Filter     = "Database Files (*.mdb)|*.mdb";
            dlg.DefaultExt = "mdb";
            DialogResult res = dlg.ShowDialog();

            if (res != DialogResult.OK)
            {
                return;
            }
            szDataSource = dlg.FileName;
            //*/
            szConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + szDataSource + ";";

            ufd_res = m_Database.Open(szConnection, null, null);
            if (ufd_res == UFD_STATUS.OK)
            {
                tbxMessage.AppendText("UFDatabase Open: OK\r\n");
            }
            else
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFDatabase Open: " + m_strError + "\r\n");
                return;
            }

            UpdateDatabaseList();
            //=========================================================================//

            //=========================================================================//
            // Create matcher
            //=========================================================================//
            m_Matcher = new UFMatcher();

            if (m_Matcher.InitResult == UFM_STATUS.OK)
            {
                tbxMessage.AppendText("UFMatcher Init: OK\r\n");
            }
            else
            {
                UFMatcher.GetErrorString(m_Matcher.InitResult, out m_strError);
                tbxMessage.AppendText("UFMatcher Init: " + m_strError + "\r\n");
            }
            //=========================================================================//

            cbScanTemplateType.SelectedIndex = 0;
        }