コード例 #1
0
        public async Task StartAsync()
        {
            if (this.scanner == null)
            {
                var collection = await DeviceInformation.FindAllAsync(PosBarcodeScanner.GetDeviceSelector());

                if (collection != null && collection.Count > 0)
                {
                    var identity = collection.First().Id;
                    var device   = await PosBarcodeScanner.FromIdAsync(identity);

                    if (device != null)
                    {
                        this.scanner = await device.ClaimScannerAsync();

                        if (this.scanner != null)
                        {
                            this.scanner.IsDecodeDataEnabled     = true;
                            this.scanner.ReleaseDeviceRequested += WhenScannerReleaseDeviceRequested;
                            this.scanner.DataReceived           += WhenScannerDataReceived;
                            await this.scanner.EnableAsync();
                        }
                    }
                }
            }
        }
コード例 #2
0
        async public void Enable(string options)
        {
            PluginResult result;

            if (barcodeScanner == null)
            {
                barcodeScanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync();

                if (claimedBarcodeScanner == null)
                {
                    claimedBarcodeScanner = await barcodeScanner.ClaimScannerAsync();

                    if (claimedBarcodeScanner != null)
                    {
                        await claimedBarcodeScanner.EnableAsync();

                        claimedBarcodeScanner.DataReceived += DataReceived;

                        result = new PluginResult(PluginResult.Status.NO_RESULT);
                        result.KeepCallback = true;
                    }
                    else
                    {
                        result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner could not get claimed");
                    }
                }
                else
                {
                    result = new PluginResult(PluginResult.Status.ERROR, "Claimed Barcode Scanner Object already there");
                }
            }
            else
            {
                result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner Object already there");
            }

            DispatchCommandResult(result);
        }
コード例 #3
0
        async public void Enable(string options)
        {
            PluginResult result;

            if (barcodeScanner == null)
            {
                barcodeScanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync();

                if (claimedBarcodeScanner == null)
                {
                    claimedBarcodeScanner = await barcodeScanner.ClaimScannerAsync();

                    if (claimedBarcodeScanner != null)
                    {
                        await claimedBarcodeScanner.EnableAsync();
                        claimedBarcodeScanner.DataReceived += DataReceived;

                        result = new PluginResult(PluginResult.Status.NO_RESULT);
                        result.KeepCallback = true;
                    }
                    else
                    {
                        result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner could not get claimed");
                    }
                }
                else
                {
                    result = new PluginResult(PluginResult.Status.ERROR, "Claimed Barcode Scanner Object already there");
                }
            }
            else
            {
                result = new PluginResult(PluginResult.Status.ERROR, "Barcode Scanner Object already there");
            }

            DispatchCommandResult(result);
        }