コード例 #1
0
        /// <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.");
            }
                );
        }
コード例 #2
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;
            });
        }
コード例 #3
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);
            }
                );
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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;
        }
コード例 #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);
     });
 }
コード例 #7
0
ファイル: Page1.xaml.cs プロジェクト: hjgode/FastScan
        /// <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);
        }
コード例 #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);
     });
 }
コード例 #9
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);
            }
                );
        }
コード例 #10
0
        //</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);
            });
        }
コード例 #11
0
        string GetDataLabelString(IBuffer data, uint scanDataType)
        {
            string result = null;

            // Only certain data types contain encoded text.
            //   To keep this simple, we'll just decode a few of them.
            if (data == null)
            {
                result = "No data";
            }
            else
            {
                switch (BarcodeSymbologies.GetName(scanDataType))
                {
                case "Upca":
                case "UpcaAdd2":
                case "UpcaAdd5":
                case "Upce":
                case "UpceAdd2":
                case "UpceAdd5":
                case "Ean8":
                case "TfStd":
                    // The UPC, EAN8, and 2 of 5 families encode the digits 0..9
                    // which are then sent to the app in a UTF8 string (like "01234")

                    // This is not an exhaustive list of symbologies that can be converted to a string

                    DataReader reader = DataReader.FromBuffer(data);
                    result = reader.ReadString(data.Length);
                    break;

                default:
                    // Some other symbologies (typically 2-D symbologies) contain binary data that
                    //  should not be converted to text.
                    result = string.Format("Decoded data unavailable. Raw label data: {0}", GetDataString(data));
                    break;
                }
            }

            return(result);
        }
コード例 #12
0
        string GetDataLabelString(IBuffer data, uint scanDataType)
        {
            string result = null;

            // Only certain data types contain encoded text.
            //   To keep this simple, we'll just decode a few of them.
            if (data == null)
            {
                result = "No data";
            }
            else
            {
                switch (BarcodeSymbologies.GetName(scanDataType))
                {
                case "Upca":
                case "UpcaAdd2":
                case "UpcaAdd5":
                case "Upce":
                case "UpceAdd2":
                case "UpceAdd5":
                case "Ean8":
                case "Ean13":
                // The UPC, EAN8, EAN13, and 2 of 5 families encode the digits 0..9
                // which are then sent to the app in a UTF8 string (like "01234")
                // This is not an exhaustive list of symbologies that can be converted to a string
                case "Qr":
                    // Need to distinguish the scan data among Numeric, Alphanumeric, Binary/Byte, and Kanji/Kana.
                    // But as current barcode scanner could not distinguish the data is in Binary/Byte format or in rest 3 formats.
                    // So to read the decoded data as string.
                    result = string.Format("{0}", System.Text.Encoding.UTF8.GetString(data.ToArray()));
                    break;

                default:
                    // Some other unsupport symbologies and just leave it as binary data
                    //result = string.Format("Decoded data unavailable. Raw label data: {0}", GetDataString(data));
                    break;
                }
            }

            return(result);
        }
コード例 #13
0
        string GetDataLabelString(IBuffer data, uint scanDataType)
        {
            string result = null;

            if (data == null)
            {
                result = string.Empty;
            }
            else
            {
                switch (BarcodeSymbologies.GetName(scanDataType))
                {
                case "Upca":
                case "UpcaAdd2":
                case "UpcaAdd5":
                case "Upce":
                case "UpceAdd2":
                case "UpceAdd5":
                case "Ean8":
                case "Ean13":
                case "TfStd":
                case "Code39":
                case "Code128":
                case "Qr":
                    // The UPC, EAN8, and 2 of 5 families encode the digits 0..9
                    // which are then sent to the app in a UTF8 string (like "01234")
                    DataReader reader = DataReader.FromBuffer(data);
                    result = reader.ReadString(data.Length);
                    break;

                default:
                    // Some other symbologies (typically 2-D symbologies) contain binary data that
                    //  should not be converted to text.
                    result = string.Format("Decoded data unavailable. Raw label data: {0}", GetDataString(data));
                    break;
                }
            }

            return(result);
        }
        /// <summary>
        /// Initializes the <see cref="ReaderSettingsBarcodeTypesControl"/> class.
        /// </summary>
        static ReaderSettingsBarcodeTypesControl()
        {
            BarcodeSymbology[]       baseSymbologies  = BarcodeSymbologies.GetSupportedBarcodeSymbologies();
            BarcodeSymbologySubset[] symbologySubsets = BarcodeSymbologySubsets.GetSupportedBarcodeSymbologySubsets();

            _barcodeSymbologies = new BarcodeSymbology[baseSymbologies.Length + symbologySubsets.Length];
            baseSymbologies.CopyTo(_barcodeSymbologies, 0);
            symbologySubsets.CopyTo(_barcodeSymbologies, baseSymbologies.Length);
            Array.Sort(_barcodeSymbologies);

            _barcodeTypeToSymbology = new Dictionary <BarcodeType, BarcodeSymbology>();
            foreach (BarcodeSymbology symbology in baseSymbologies)
            {
                _barcodeTypeToSymbology.Add(symbology.BarcodeType, symbology);
            }

            _nameToSymbologySubset = new Dictionary <string, BarcodeSymbologySubset>();
            foreach (BarcodeSymbologySubset symbologySubset in symbologySubsets)
            {
                _nameToSymbologySubset.Add(symbologySubset.Name, symbologySubset);
            }
        }
コード例 #15
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
            });
        }