Пример #1
0
        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.
            var settings            = picker.GetDefaultScanSettings();
            var symbologiesToEnable = new Symbology[] {
                Symbology.Qr,
                Symbology.Ean13,
                Symbology.Upce,
                Symbology.Ean8,
                Symbology.Upca,
                Symbology.Qr,
                Symbology.DataMatrix
            };

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

            // This will open the scanner in full-screen mode.
        }
        // 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);
        }
        // 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);
        }