// reads the values needed for ScanSettings from the Settings class
        // and applies them to the Picker
        void updateScanSettings()
        {
            bool addOnEnabled = false;

            foreach (string setting in Convert.settingToSymbologies.Keys)
            {
                bool enabled = Settings.getBoolSetting(setting);
                foreach (Symbology sym in Convert.settingToSymbologies[setting])
                {
                    _scanSettings.EnableSymbology(sym, enabled);
                    if (Settings.hasInvertedSymbology(setting))
                    {
                        _scanSettings.Symbologies[sym].ColorInvertedEnabled = Settings.getBoolSetting(
                            Settings.getInvertedSymboloby(setting));
                    }

                    if (enabled && (sym == Symbology.TwoDigitAddOn ||
                                    sym == Symbology.FiveDigitAddOn))
                    {
                        addOnEnabled = true;
                    }
                }
            }

            if (addOnEnabled)
            {
                _scanSettings.MaxNumberOfCodesPerFrame = 2;
            }

            _scanSettings.Symbologies[Symbology.MsiPlessey].Checksums =
                Convert.msiPlesseyChecksumToScanSetting[Settings.getStringSetting(Settings.MsiPlesseyChecksumString)];

            _scanSettings.RestrictedAreaScanningEnabled = Settings.getBoolSetting(Settings.RestrictedAreaString);
            if (_scanSettings.RestrictedAreaScanningEnabled)
            {
                Double HotSpotHeight = Settings.getDoubleSetting(Settings.HotSpotHeightString);
                Double HotSpotWidth  = Settings.getDoubleSetting(Settings.HotSpotWidthString);
                Double HotSpotY      = Settings.getDoubleSetting(Settings.HotSpotYString);

                Rect restricted = new Rect(0.5f - HotSpotWidth * 0.5f, HotSpotY - 0.5f * HotSpotHeight,
                                           HotSpotWidth, HotSpotHeight);

                _scanSettings.ScanningHotSpot = new Scandit.BarcodePicker.Unified.Point(
                    0.5, Settings.getDoubleSetting(Settings.HotSpotYString));
                _scanSettings.ActiveScanningAreaPortrait  = restricted;
                _scanSettings.ActiveScanningAreaLandscape = restricted;
            }
            _scanSettings.ResolutionPreference =
                Convert.resolutionToScanSetting[Settings.getStringSetting(Settings.ResolutionString)];

            _picker.ApplySettingsAsync(_scanSettings);
        }
예제 #2
0
        private BarcodePicker GetBarcodePicker()
        {
            ScanSettings settings = new ScanSettings();

            settings.EnableSymbology(BarcodeSymbology.Qr);
            settings.EnableSymbology(BarcodeSymbology.Code39);
            settings.EnableSymbology(BarcodeSymbology.Code128);

            settings.Symbologies[BarcodeSymbology.Code128].ActiveSymbolCounts = new ushort[]
            {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
            };

            settings.Symbologies[BarcodeSymbology.Code39].ActiveSymbolCounts = new ushort[]
            {
                7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
            };

            settings.CodeDuplicateFilter = 5000;
            Size viewFinderSize = new Size();

            viewFinderSize.Height = 0.32;
            viewFinderSize.Width  = 0.75;

            BarcodePicker picker = new BarcodePicker(barcodeCamera.ApiKey, settings)
            {
                BeepEnabled = false,
                ScanOverlay = new ScanOverlay()
                {
                    GuiStyle = GuiStyle.Rectangle,
                    ViewFinderSizePortrait  = viewFinderSize,
                    ViewFinderSizeLandscape = viewFinderSize
                }
            };

            return(picker);
        }
        // reads the values needed for ScanSettings from the Settings class
        // and applies them to the Picker
        void updateScanSettings()
        {
            foreach (string setting in Convert.settingToSymbologies.Keys)
            {
                bool enabled = Settings.getBoolSetting(setting);
                foreach (Symbology sym in Convert.settingToSymbologies[setting])
                {
                    _scanSettings.EnableSymbology(sym, enabled);
                    if (Settings.hasInvertedSymbology(setting))
                    {
                        _scanSettings.Symbologies[sym].ColorInvertedEnabled = Settings.getBoolSetting(
                            Settings.getInvertedSymboloby(setting));
                    }
                }
            }

            _scanSettings.Symbologies[Symbology.MsiPlessey].Checksums =
                Convert.msiPlesseyChecksumToScanSetting[Settings.getStringSetting(Settings.MsiPlesseyChecksumString)];

            _scanSettings.RestrictedAreaScanningEnabled = Settings.getBoolSetting(Settings.RestrictedAreaString);
            if (_scanSettings.RestrictedAreaScanningEnabled)
            {
                Double HotSpotHeight = Settings.getDoubleSetting(Settings.HotSpotHeightString);
                Double HotSpotWidth  = Settings.getDoubleSetting(Settings.HotSpotWidthString);
                Double HotSpotY      = Settings.getDoubleSetting(Settings.HotSpotYString);

                Rect restricted = new Rect(0.5f - HotSpotWidth * 0.5f, HotSpotY - 0.5f * HotSpotHeight,
                                           HotSpotWidth, HotSpotHeight);

                _scanSettings.ScanningHotSpot = new Scandit.BarcodePicker.Unified.Point(
                    0.5, Settings.getDoubleSetting(Settings.HotSpotYString));
                _scanSettings.ActiveScanningAreaPortrait  = restricted;
                _scanSettings.ActiveScanningAreaLandscape = restricted;
            }
            _picker.ApplySettingsAsync(_scanSettings);
        }
        private async void InitSettings()
        {
            IBarcodePicker _picker = ScanditService.BarcodePicker;

            // The scanning behavior of the barcode picker is configured through scan
            // settings. We start with empty scan settings and enable a very generous
            // set of symbologies. In your own apps, only enable the symbologies you
            // actually need.
            _scanSettings = _picker.GetDefaultScanSettings();
            var symbologiesToEnable = new Symbology[] {
                Symbology.Qr,
                Symbology.Ean13,
                Symbology.Upce,
                Symbology.Code128,
                Symbology.Ean8,
                Symbology.Upca,
                Symbology.DataMatrix
            };

            foreach (var sym in symbologiesToEnable)
            {
                _scanSettings.EnableSymbology(sym, true);
            }
            await _picker.ApplySettingsAsync(_scanSettings);

            // This will open the scanner in full-screen mode.
            ScanditService.BarcodePicker.CancelButtonText  = "Done";
            ScanditService.BarcodePicker.DidScan          += OnDidScan;
            ScanditService.BarcodePicker.DidStop          += OnDidStopAsync;
            ScanditService.BarcodePicker.AlwaysShowModally = true;
            await UpdateScanSettings();

            UpdateScanOverlay();
            //ScanditService.BarcodePicker.CancelButtonText = "Done";
            await ScanditService.BarcodePicker.StartScanningAsync(false);
        }
예제 #5
0
        // reads the values needed for ScanSettings from the Settings class
        // and applies them to the Picker
        void updateScanSettings()
        {
            bool addOnEnabled = false;
            bool isScanningAreaOverriddenByDpmMode = false;

            foreach (string setting in Convert.settingToSymbologies.Keys)
            {
                bool enabled = Settings.getBoolSetting(setting);

                // DPM Mode
                if (Settings.isDpmMode(setting) && enabled)
                {
                    Rect restricted = new Rect(0.33f, 0.33f, 0.33f, 0.33f);
                    _scanSettings.ActiveScanningAreaPortrait  = restricted;
                    _scanSettings.ActiveScanningAreaLandscape = restricted;

                    isScanningAreaOverriddenByDpmMode = true;

                    // Enabling the direct_part_marking_mode extension comes at the cost of increased frame processing times.
                    // It is recommended to restrict the scanning area to a smaller part of the image for best performance.
                    _scanSettings.Symbologies[Symbology.DataMatrix].SetExtensionEnabled("direct_part_marking_mode", true);
                    continue;
                }

                if (Convert.settingToSymbologies[setting] == null)
                {
                    continue;
                }
                foreach (Symbology sym in Convert.settingToSymbologies[setting])
                {
                    _scanSettings.EnableSymbology(sym, enabled);
                    if (Settings.hasInvertedSymbology(setting))
                    {
                        _scanSettings.Symbologies[sym].ColorInvertedEnabled = Settings.getBoolSetting(
                            Settings.getInvertedSymbology(setting));
                    }

                    if (enabled && (sym == Symbology.TwoDigitAddOn ||
                                    sym == Symbology.FiveDigitAddOn))
                    {
                        addOnEnabled = true;
                    }
                }
            }

            if (addOnEnabled)
            {
                _scanSettings.MaxNumberOfCodesPerFrame = 2;
            }

            _scanSettings.Symbologies[Symbology.MsiPlessey].Checksums =
                Convert.msiPlesseyChecksumToScanSetting[Settings.getStringSetting(Settings.MsiPlesseyChecksumString)];

            _scanSettings.RestrictedAreaScanningEnabled = isScanningAreaOverriddenByDpmMode || Settings.getBoolSetting(Settings.RestrictedAreaString);
            if (Settings.getBoolSetting(Settings.RestrictedAreaString) && !isScanningAreaOverriddenByDpmMode)
            {
                Double HotSpotHeight = Settings.getDoubleSetting(Settings.HotSpotHeightString);
                Double HotSpotWidth  = Settings.getDoubleSetting(Settings.HotSpotWidthString);
                Double HotSpotY      = Settings.getDoubleSetting(Settings.HotSpotYString);

                Rect restricted = new Rect(0.5f - HotSpotWidth * 0.5f, HotSpotY - 0.5f * HotSpotHeight,
                                           HotSpotWidth, HotSpotHeight);

                _scanSettings.ScanningHotSpot = new Scandit.BarcodePicker.Unified.Point(
                    0.5, Settings.getDoubleSetting(Settings.HotSpotYString));
                _scanSettings.ActiveScanningAreaPortrait  = restricted;
                _scanSettings.ActiveScanningAreaLandscape = restricted;
            }
            _scanSettings.ResolutionPreference =
                Convert.resolutionToScanSetting[Settings.getStringSetting(Settings.ResolutionString)];

            _picker.ApplySettingsAsync(_scanSettings);
        }