void DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            PluginResult result = new PluginResult(PluginResult.Status.OK, this.GetDataString(args.Report.ScanData));

            result.KeepCallback = true;
            DispatchCommandResult(result);
        }
Example #2
0
        private async void OnBarcodeDetected(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            string regId = "<undefined>";
            string ek    = "<undefined>";

            // Parse the data
            string  decodedText = BarcodeDecoder.DecodeLabel(args.Report.ScanDataLabel);
            JObject jsonData    = (JObject)JsonConvert.DeserializeObject(decodedText);

            if (jsonData.ContainsKey(JsonRegId))
            {
                regId = (string)jsonData[JsonRegId];
            }

            if (jsonData.ContainsKey(JsonEK))
            {
                ek = (string)jsonData[JsonEK];
            }

            // Update the UI
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                RegIdBox.Text = regId;
                EKBox.Text    = ek;
            });
        }
Example #3
0
        private async void ClaimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            lock (SyncRootProvider.SyncRoot)
            {
                if (IsRunning)
                {
                    return;
                }
                IsRunning = true;
            }

            string BarcodeType  = BarcodeSymbologies.GetName(args.Report.ScanDataType).ToUpper();
            string BarcodeLabel = GetDataLabel(args);

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                ContentDialog dialog = new ContentDialog
                {
                    Content         = BarcodeLabel,
                    Title           = BarcodeType + "标签内容",
                    CloseButtonText = "确定",
                    Background      = Application.Current.Resources["DialogAcrylicBrush"] as Brush
                };
                await dialog.ShowAsync();

                BarcodeHistory.Add(new BarcodeItem(BarcodeType, BarcodeLabel));

                IsRunning = false;
            });
        }
        void claimedBarcodeScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            string symbologyName       = BarcodeSymbologies.GetName(args.Report.ScanDataType);
            var    scanDataLabelReader = DataReader.FromBuffer(args.Report.ScanDataLabel);
            string barcode             = scanDataLabelReader.ReadString(args.Report.ScanDataLabel.Length);

            scannerData.TryAddBarcode(barcode);
        }
        private void ClaimedBarcode_DataRecieved(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            string symbologyName       = BarcodeSymbologies.GetName(args.Report.ScanDataType);
            var    scanDataLabelReader = DataReader.FromBuffer(args.Report.ScanDataLabel);
            string barcode             = scanDataLabelReader.ReadString(args.Report.ScanDataLabel.Length);

            ScanningData = barcode;
        }
Example #6
0
 /// <summary>
 /// Scan data was received from the selected scanner.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private async void ClaimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         ScenarioOutputScanDataLabel.Text = DataHelpers.GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
         ScenarioOutputScanData.Text      = DataHelpers.GetDataString(args.Report.ScanData);
         ScenarioOutputScanDataType.Text  = BarcodeSymbologies.GetName(args.Report.ScanDataType);
     });
 }
        private void WhenScannerDataReceived(object sender, BarcodeScannerDataReceivedEventArgs args)
        {
            var data = args.Report.ScanDataLabel;

            using (var reader = DataReader.FromBuffer(data))
            {
                var text = reader.ReadString(data.Length);
                var bsea = new BarcodeScannedEventArgs(text);
                this.BarcodeScanned?.Invoke(this, bsea);
            }
        }
Example #8
0
 /// <summary>
 /// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
 async void claimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
 {
     // need to update the UI data on the dispatcher thread.
     // update the UI with the data received from the scan.
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         // read the data from the buffer and convert to string.
         ScenarioOutputScanDataLabel.Text = DataHelpers.GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
         ScenarioOutputScanData.Text      = DataHelpers.GetDataString(args.Report.ScanData);
         ScenarioOutputScanDataType.Text  = BarcodeSymbologies.GetName(args.Report.ScanDataType);
     });
 }
        //</SnippetReleaseDeviceRequested>

        /// <summary>
        /// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
        //<SnippetDataReceived>
        async void claimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            // update the UI with the data received from the scan.
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                // read the data from the buffer and convert to string.
                var scanDataLabelReader          = DataReader.FromBuffer(args.Report.ScanDataLabel);
                ScenarioOutputScanDataLabel.Text = scanDataLabelReader.ReadString(args.Report.ScanDataLabel.Length);

                var scanDataReader          = DataReader.FromBuffer(args.Report.ScanData);
                ScenarioOutputScanData.Text = scanDataReader.ReadString(args.Report.ScanData.Length);

                ScenarioOutputScanDataType.Text = BarcodeSymbologies.GetName(args.Report.ScanDataType);
            });
        }
Example #10
0
        /// <summary>
        /// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
        public async void claimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            try
            {
                var barcodeLabel = GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
                Debug.WriteLine("BARCODE");
                Debug.WriteLine(barcodeLabel);

                Task.Run(() =>
                {
                    if (BarcodeEvent != null)
                    {
                        OnBarcode(barcodeLabel);
                    }
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Could not send barcode to ViewModel");
            }
        }
Example #11
0
        async private void ClamedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            UInt32 symbology;
            string label;
            string data;

            symbology = args.Report.ScanDataType;

            using (var datareader = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanDataLabel))
            {
                label = datareader.ReadString(args.Report.ScanDataLabel.Length);
            }
            using (var datareader = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanData))
            {
                data = datareader.ReadString(args.Report.ScanData.Length);
            }

            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                textBoxSymbology.Text = BarcodeSymbologies.GetName(symbology); //Send the data to the UI through the dispatcher. tbData is a textbox in the UI
                textBoxData.Text      = label;                                 //Send the data to the UI through the dispatcher. tbLabel is a textbox in the UI
            });
        }
 void DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
 {
     PluginResult result = new PluginResult(PluginResult.Status.OK, this.GetDataString(args.Report.ScanData));
     result.KeepCallback = true;
     DispatchCommandResult(result);
 }
Example #13
0
    private void ClaimedBarcodeScanner_DataReceivedAsync(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
    {
        if (_callback == null)     // don't bother with ConvertBinaryToString if we don't need to
        {
            return;
        }
        // all we need do here is convert to a string and pass it to the client
        var barcode = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8,
                                                                args.Report.ScanDataLabel);

        _callback(barcode);
    }
        /// <summary>
        /// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
        async void claimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            // need to update the UI data on the dispatcher thread.
            // update the UI with the data received from the scan.
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                // read the data from the buffer and convert to string.
                ScenarioOutputScanDataLabel.Text = GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);

                ScenarioOutputScanData.Text = GetDataString(args.Report.ScanData);

                ScenarioOutputScanDataType.Text = BarcodeSymbologies.GetName(args.Report.ScanDataType);
            });
        }
Example #15
0
 private void ClaimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
 {
     var scanDataLabelReader = DataReader.FromBuffer(args.Report.ScanDataLabel);
     string barcode = scanDataLabelReader.ReadString(args.Report.ScanDataLabel.Length);
     UpdateMessage(barcode);
 }
        /// <summary>
        /// This is an event handler for the claimed scanner Instance 1 when it scans and recieves data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void claimedBarcodeScannerInstance1_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            // Grab the data from the IBuffers
            string scanData      = String.Empty;
            string scanDataLabel = String.Empty;

            if (args.Report.ScanData != null)
            {
                scanData = GetDataString(args.Report.ScanData);
            }

            if (args.Report.ScanDataLabel != null)
            {
                scanDataLabel = GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
            }

            await MainPage.Current.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                () =>
            {
                ScanDataType1.Text = String.Format("{0}", BarcodeSymbologies.GetName(args.Report.ScanDataType));

                // DataLabel
                DataLabel1.Text = String.Format("{0}", scanDataLabel);

                // Data
                ScanData1.Text = String.Format("{0}", scanData);

                UpdateOutput("Instance1 Data Received from Barcode Scanner.");
            }
                );
        }
        /// <summary>
        /// This is an event handler for the claimed scanner Instance 1 when it scans and recieves data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void claimedBarcodeScannerInstance1_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            // Grab the data from the IBuffers
            string scanData = String.Empty;
            string scanDataLabel = String.Empty;

            if (args.Report.ScanData != null)
            {
                scanData = GetDataString(args.Report.ScanData);
            }

            if (args.Report.ScanDataLabel != null)
            {
                scanDataLabel = GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
            }

            await MainPage.Current.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                () =>
                {
                    ScanDataType1.Text = String.Format("{0}", BarcodeSymbologies.GetName(args.Report.ScanDataType));

                    // DataLabel
                    DataLabel1.Text = String.Format("{0}", scanDataLabel);

                    // Data
                    ScanData1.Text = String.Format("{0}", scanData);

                    UpdateOutput("Instance1 Data Received from Barcode Scanner.");
                }
            );
        }
Example #18
0
        /// <summary>
        /// This is an event handler for the claimed scanner Instance 2 when it scans and recieves data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void claimedBarcodeScannerInstance2_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            // Grab the data from the IBuffers
            string scanData      = String.Empty;
            string scanDataLabel = String.Empty;

            if (args.Report.ScanData != null)
            {
                scanData = GetDataString(args.Report.ScanData);
            }

            if (args.Report.ScanDataLabel != null)
            {
                scanDataLabel = GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
            }

            await MainPage.Current.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                () =>
            {
                // Symbology
                ScanDataType2.Text = String.Format("{0}", BarcodeSymbologies.GetName(args.Report.ScanDataType));

                // DataLabel
                DataLabel2.Text = String.Format("{0}", scanDataLabel);

                // Data
                ScanData2.Text = String.Format("{0}", scanData);

                rootPage.NotifyUser("Instance 2 received data from the barcode scanner.", NotifyType.StatusMessage);
            }
                );
        }
        async private void ClamedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            UInt32 symbology;
            string label;
            string data;
            symbology = args.Report.ScanDataType;

            using(var datareader = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanDataLabel))
            {
                label = datareader.ReadString(args.Report.ScanDataLabel.Length);
            }
            using (var datareader = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanData))
            {
                data = datareader.ReadString(args.Report.ScanData.Length);
            }
            
            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                textBoxSymbology.Text = BarcodeSymbologies.GetName(symbology); //Send the data to the UI through the dispatcher. tbData is a textbox in the UI
                textBoxData.Text = label; //Send the data to the UI through the dispatcher. tbLabel is a textbox in the UI
            });
        }
        /// <summary>
        /// Event handler for the DataReceived event fired when a barcode is scanned by the barcode scanner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"> Contains the BarcodeScannerReport which contains the data obtained in the scan</param>
        async void claimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            var detectedBarcode = GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);

            HandleNewBarcodeDetected(detectedBarcode);
        }
 private void ScannerController_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
 {
     claimedScanner_DataReceived(sender, args);
 }
Example #22
0
 protected virtual void OnDataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs e)
 {
     DataReceived?.Invoke(sender, e);
 }
        /// <summary>
        /// This is an event handler for the claimed scanner Instance 2 when it scans and recieves data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void claimedBarcodeScannerInstance2_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            // Grab the data from the IBuffers
            string scanData = String.Empty;
            string scanDataLabel = String.Empty;

            if (args.Report.ScanData != null)
            {
                scanData = GetDataString(args.Report.ScanData);
            }

            if (args.Report.ScanDataLabel != null)
            {
                scanDataLabel = GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
            }

            await MainPage.Current.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                () =>
                {
                    // Symbology
                    ScanDataType2.Text = String.Format("{0}", BarcodeSymbologies.GetName(args.Report.ScanDataType));

                    // DataLabel
                    DataLabel2.Text = String.Format("{0}", scanDataLabel);

                    // Data
                    ScanData2.Text = String.Format("{0}", scanData);

                    rootPage.NotifyUser("Instance 2 received data from the barcode scanner.", NotifyType.StatusMessage);
                }
            );
        }
Example #24
0
        /// <summary>
        /// Each time a barcode is read this routing gets the type of barcode read and the barcode data.
        /// It then calls the GUI update method.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void _ClaimedBarcodeScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            Class1.doLog("_ClaimedBarcodeScanner_DataReceived: " + args.Report.ScanData.ToString());
            string label;
            UInt32 symCode = args.Report.ScanDataType; // the symbology of the scanned data

            using (var datareader = Windows.Storage.Streams.DataReader.FromBuffer(args.Report.ScanDataLabel))
            {
                label = datareader.ReadString(args.Report.ScanDataLabel.Length);
            }
            UpdateUI_scandata(BarcodeSymbologies.GetName(symCode), label);
        }
Example #25
0
        /// <summary>
        /// This is an event handler for the claimed scanner Instance 2 when it scans and recieves data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void claimedBarcodeScannerInstance2_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            await MainPage.Current.Dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                () =>
            {
                ScanDataType2.Text = BarcodeSymbologies.GetName(args.Report.ScanDataType);
                DataLabel2.Text    = DataHelpers.GetDataLabelString(args.Report.ScanDataLabel, args.Report.ScanDataType);
                ScanData2.Text     = DataHelpers.GetDataString(args.Report.ScanData);

                rootPage.NotifyUser("Instance 2 received data from the barcode scanner.", NotifyType.StatusMessage);
            }
                );
        }
Example #26
0
 private string GetDataLabel(BarcodeScannerDataReceivedEventArgs args)
 {
     return(args.Report.ScanDataLabel == null
         ? "数据不存在"
         : CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, args.Report.ScanDataLabel));
 }
Example #27
0
 private void ClaimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
 {
     OnDataReceived(sender, args);
 }