Example #1
0
        // Read a set of barcodes from an image.
        private BarCode[] RecognizeBarcodes(BarCodeReader reader, ReadOpts optionsIn)
        {
            BarCode[] results = null;
            var       options = new ReadOpts(optionsIn);

            if (options.Symbology == 0)
            {
                return(null);
            }

            try
            {
                results = reader.ReadBars(options);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                _statusBox.AppendText("Range error in options: " + ex.Message + "\r\n");
            }
            catch (Exception ex)
            {
                _statusBox.AppendText("General error: " + ex.Message + "\r\n");
            }

            return(results);
        }
Example #2
0
        private void Barcoder_Load(object sender, EventArgs e)
        {
            _recognizeButton.Enabled = false;

            // set a few reasonable default options
            _options = new ReadOpts
            {
                Symbology = Symbologies.Code39,
                Direction = Directions.East,

                // counter-intuitive - these defaults get pulled from the UI instead
                // of being pushed into the UI
                ScanInterval   = _scanInterval.Value,
                ScanBarsToRead = _expectedBarCodes.Value
            };

            // map the options into the UI
            MapBarcodeSymbologies(_barcodeSymbologyList, _options, _mySymbologyMap);
            MapScanDirections(_scanDirectionList, _options, _directionMap);
            _statusBox.AppendText("Application loaded.  Click \"Open Image\" to load an image.\r\n");

            // This should point to the "DotImage 7.0\Images\Barcodes" folder.
            _openFileDialog.FileName = Path.GetFullPath(@"..\..\Images\Barcodes\Code39Scanned.gif");
            if (!File.Exists(_openFileDialog.FileName))
            {
                _openFileDialog.FileName = Path.GetFullPath(@"..\..\..\..\..\Images\Barcodes\Code39Scanned.gif");
                if (!File.Exists(_openFileDialog.FileName))
                {
                    _openFileDialog.FileName = string.Empty;
                }
            }
        }
Example #3
0
 private void MapBarcodeSymbologies(CheckedListBox listBox, ReadOpts theOptions, SymbologyMap[] map)
 {
     // put each symbology into the check box,
     // checking it as needed.
     for (var i = 0; i < map.Length; i++)
     {
         listBox.Items.Add(map[i]);
         if ((theOptions.Symbology & map[i].Symbology) != 0)
         {
             listBox.SetItemChecked(i, true);
         }
     }
 }
Example #4
0
 private void MapScanDirections(CheckedListBox listBox, ReadOpts theOptions, ScanDirectionMap[] map)
 {
     // put each scan direction into the check box,
     // checking it as needed.
     for (var i = 0; i < map.Length; i++)
     {
         listBox.Items.Add(map[i]);
         if ((theOptions.Direction & map[i].Direction) != 0)
         {
             listBox.SetItemChecked(i, true);
         }
     }
 }
Example #5
0
 private static Task <int> Read(ReadOpts opts)
 {
     return(Task.FromResult(0));
 }