Exemple #1
0
        private void UpdateUIState()
        {
            bool itemSelected = _barcodesListView.SelectedItems.Count > 0;

            _deleteButton.Enabled = itemSelected;
            _zoomToButton.Enabled = itemSelected;

#if LEADTOOLS_V20_OR_LATER
            _aamvaButton.Enabled = false;
            if (_rasterImage != null)
            {
                PageBarcodes pageBarcodes = _documentBarcodes.Pages[_rasterImage.Page - 1];
                if (pageBarcodes.SelectedIndex > -1)
                {
                    BarcodeData data = pageBarcodes.Barcodes[pageBarcodes.SelectedIndex];
                    if (data.Symbology == BarcodeSymbology.PDF417)
                    {
                        AAMVAID id = BarcodeData.ParseAAMVAData(data.GetData(), false);
                        if (id != null)
                        {
                            _aamvaButton.Enabled = true;
                            id.Dispose();
                        }
                    }
                }
            }
#endif // #if LEADTOOLS_V20_OR_LATER
        }
Exemple #2
0
        private void Reader_ReadSymbology(object sender, BarcodeReadSymbologyEventArgs e)
        {
            bool   firstInGroup;
            double ms = 0;

            switch (e.Operation)
            {
            case BarcodeReadSymbologyOperation.PreRead:
                UpdateMessageLabel(e.Options);
                _stopWatch.Start();
                break;

            case BarcodeReadSymbologyOperation.PostRead:
                if (_stopWatch.IsRunning)
                {
                    _stopWatch.Stop();
                    ms = _stopWatch.ElapsedMilliseconds;
                    _stopWatch.Reset();
                    firstInGroup = true;
                }
                else
                {
                    firstInGroup = false;
                }

                // Add this item to the list
                if (e.Data != null)
                {
                    if (firstInGroup)
                    {
                        ListViewGroup group = new ListViewGroup(string.Format(DemosGlobalization.GetResxString(GetType(), "Resx_GroupRead"), ms));
                        _barcodesListView.Groups.Add(group);
                    }

                    ListViewItem item = new ListViewItem();
                    item.Text = _currentPageNumber.ToString();
                    item.SubItems.Add(BarcodeEngine.GetSymbologyFriendlyName(e.Data.Symbology));

                    string value    = string.Empty;
                    string location = string.Empty;

                    BarcodeData data = e.Data;
                    if (data != null)
                    {
                        value = data.Value;
                        if (value == null)
                        {
                            value = string.Empty;
                        }

                        location = string.Format("{0}, {1}, {2}, {3}", data.Bounds.Left, data.Bounds.Top, data.Bounds.Right, data.Bounds.Bottom);
                    }
                    else if (e.Error != null)
                    {
                        value = e.Error.Message;
                    }

                    // Parse the QR barcodes for ECI data
                    string eciData = null;
                    if (data.Symbology == BarcodeSymbology.QR || data.Symbology == BarcodeSymbology.MicroQR)
                    {
                        eciData = BarcodeData.ParseECIData(data.GetData());
                    }

                    if (!string.IsNullOrEmpty(eciData))
                    {
                        item.SubItems.Add(eciData);
                    }
                    else
                    {
                        item.SubItems.Add(value);
                    }

                    item.SubItems.Add(location);

                    item.Group = _barcodesListView.Groups[_barcodesListView.Groups.Count - 1];
                    _barcodesListView.Items.Add(item);
                }
                break;
            }

            Application.DoEvents();

            if (_isAborted)
            {
                e.Status = BarcodeReadSymbologyStatus.Abort;
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // provide drivers license file with PDF417 barcode to recognize
            string inputFilePath = @"PATH TO IMAGE";

            RasterSupport.SetLicense(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC", System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC.KEY"));

            using (RasterCodecs codecs = new RasterCodecs())
                using (RasterImage inputImage = codecs.Load(inputFilePath))
                {
                    BarcodeEngine engine = new BarcodeEngine();
                    BarcodeData   data   = engine.Reader.ReadBarcode(inputImage, LeadRect.Empty, BarcodeSymbology.PDF417);
                    if (data != null)
                    {
                        using (AAMVAID id = BarcodeData.ParseAAMVAData(data.GetData(), false))
                        {
                            if (id != null)
                            {
                                Console.WriteLine("Issuer Identification Number: " + id.IssuerIdentificationNumber);
                                Console.WriteLine("Jurisdiction: " + id.Jurisdiction.ToString());
                                Console.WriteLine("AAMVA CDS Version: " + id.Version.ToString());
                                Console.WriteLine("Jurisdiction Version: " + id.JurisdictionVersion);
                                Console.WriteLine("Number of Entries: " + id.NumberOfEntries.ToString());

                                AAMVANameResult firstNameResult = id.FirstName;
                                if (firstNameResult != null)
                                {
                                    Console.WriteLine("First Name: " + firstNameResult.Value + ", Inferred?: " + firstNameResult.InferredFromFullName);
                                }

                                AAMVANameResult lastNameResult = id.LastName;
                                if (lastNameResult != null)
                                {
                                    Console.WriteLine("Last Name: " + lastNameResult.Value + ", Inferred?: " + lastNameResult.InferredFromFullName);
                                }

                                string addressStreet1 = id.AddressStreet1;
                                if (addressStreet1 != null)
                                {
                                    Console.WriteLine("Address Street 1: " + addressStreet1);
                                }

                                string addressStreet2 = id.AddressStreet2;
                                if (addressStreet2 != null)
                                {
                                    Console.WriteLine("Address Street 2: " + addressStreet2);
                                }

                                string addressStateAbbreviation = id.AddressStateAbbreviation;
                                if (addressStateAbbreviation != null)
                                {
                                    Console.WriteLine("Address State Abbreviation: " + addressStateAbbreviation);
                                }

                                string addressCity = id.AddressCity;
                                if (addressCity != null)
                                {
                                    Console.WriteLine("Address City: " + addressCity);
                                }

                                string addressPostalCode = id.AddressPostalCode;
                                if (addressPostalCode != null)
                                {
                                    Console.WriteLine("Address Postal Code: " + addressPostalCode);
                                }

                                AAMVARegion addressRegion = id.AddressRegion;
                                Console.WriteLine("Address Region: " + addressRegion.ToString());

                                string dateOfBirth = id.DateOfBirth;
                                if (dateOfBirth != null)
                                {
                                    Console.WriteLine("Date of Birth: " + dateOfBirth);
                                }

                                if (id.Over18Available)
                                {
                                    Console.WriteLine("Over 18?: " + id.Over18);
                                }

                                if (id.Over19Available)
                                {
                                    Console.WriteLine("Over 19?: " + id.Over19);
                                }

                                if (id.Over21Available)
                                {
                                    Console.WriteLine("Over 21?: " + id.Over21);
                                }

                                if (id.ExpirationAvailable)
                                {
                                    Console.WriteLine("Expired?: " + id.Expired);
                                }

                                string expirationDate = id.ExpirationDate;
                                if (expirationDate != null)
                                {
                                    Console.WriteLine("Expiration Date: " + expirationDate);
                                }

                                string issueDate = id.IssueDate;
                                if (issueDate != null)
                                {
                                    Console.WriteLine("Issue Date: " + issueDate);
                                }

                                string idNumber = id.Number;
                                if (idNumber != null)
                                {
                                    Console.WriteLine("ID Number: " + idNumber);
                                }

                                AAMVAEyeColor eyeColor = id.EyeColor;
                                Console.WriteLine("Eye Color: " + eyeColor.ToString());

                                AAMVAHairColor hairColor = id.HairColor;
                                Console.WriteLine("Hair Color: " + hairColor.ToString());

                                AAMVASex sex = id.Sex;
                                Console.WriteLine("Sex: " + sex.ToString());
                                Console.ReadLine();
                            }
                        }
                    }
                }
        }