Exemplo n.º 1
0
        private async void EnrollButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                StatusText.Text = "Put Your Finger on scanner";
                if (!_isVerified)
                {
                    return;
                }
                var pageId = 10;//int.Parse(PageIdTextBox.Text.Trim());
                //await _fingerPrint.Reset();

                var firstImage = await _fingerPrint.GenerateImage();

                while (firstImage == ReturnCode.NoFinger)
                {
                    firstImage = await _fingerPrint.GenerateImage();
                }

                if (firstImage == ReturnCode.Ok)
                {
                    StatusText.Text = "Put off your finger";
                    await _fingerPrint.GenerateImageToTz(1);
                }

                await Task.Delay(TimeSpan.FromMilliseconds(1000));

                StatusText.Text = "Put your finger again";
                var secoundImage = await _fingerPrint.GenerateImage();

                while (secoundImage == ReturnCode.NoFinger)
                {
                    secoundImage = await _fingerPrint.GenerateImage();
                }

                if (secoundImage == ReturnCode.Ok)
                {
                    await _fingerPrint.GenerateImageToTz(2);

                    StatusText.Text = "Put off your finger";
                }

                await _fingerPrint.GenerateTemplate();

                await _fingerPrint.StoreTemplate(1, ConvertIntToByteArray(pageId));

                StatusText.Text = "Your finger saved";
            }
            catch (Exception ex)
            {
                StatusText.Text = ex.Message;
            }
        }
        private async void EnrollButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!_isVerified)
                {
                    return;
                }
                var pageIdDialog = new PageSelectorDialog();
                if (pageIdDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                var pageId = pageIdDialog.PageId;
                if (!ConfirmDialog(@"Please put your finger on scanner and then select 'OK' from the box"))
                {
                    return;
                }
                await _fingerPrint.Reset();

                var firstImage = 0xff;
                while (firstImage != ReturnCode.Ok)
                {
                    firstImage = await _fingerPrint.GenerateImage();
                }

                await _fingerPrint.GenerateImageToTz(1);

                Thread.Sleep(2000);

                var secoundImage = await _fingerPrint.GenerateImage();

                while (secoundImage != ReturnCode.Ok)
                {
                    secoundImage = await _fingerPrint.GenerateImage();
                }

                await _fingerPrint.GenerateImageToTz(2);

                await _fingerPrint.GenerateTemplate();

                await _fingerPrint.StoreTemplate(1, ConvertIntToByteArray(pageId));
            }
            catch (Exception ex)
            {
                OnError(ex.Message);
            }
        }