Microsoft Gulf Technical Community

The communication portal for the Gulf technical audience

Starting with Windows Embedded Apps

Starting with Windows Embedded Apps

  • Comments 1

First thing you have to know about writing applications with Windows Embedded, is the version that you are going to use of it.

In this article, I’m going to show you how to create applications for Windows Embedded 8.1 Handheld, that is the version that is running on most of the mobile POS devices (like for example the BM180 Pidion from Bluebird).

To develop for this version of WEH you just need two things:

- Visual Studio 2013 Update 2 RC or higher (any version, but recommended Ultimate if you want to have quality testing)

- Windows Embedded 8.1 Handheld SDK RC (http://www.microsoft.com/en-us/download/details.aspx?id=42538)

So just download and install the SDK in your computer before start working with it.

image image

During the installation process you will be warned that is not only the SDK with the documentation and the APIs the one to be installed but also the Emulators in case you don’t have an Embedded device.

Once is done, let’s see how to create an app.

Go to Visual Studio

1. Create a new Windows Phone Project, let’s call it BarCodeScaner, normal Windows Phone 8.1 Silverlight project

So the first thing you will notice is that we have new emulators installed:

image

2. Add the following statements to the top of your class file:

using Windows.Devices.PointOfService; // The Windows RT point of service APIs

3. Add the following variables inside your class:

private BarcodeScanner scanner;
private ClaimedBarcodeScanner claimedScanner;

scanner stores the instance of the default scanner object.
claimedScanner stores the instance of the barcode scanner object that is reserved for exclusive use by your application.

4. Generate the next method in your main class:

    private async void ClaimBarcodeScanner()
        {
            scanner = await BarcodeScanner.GetDefaultAsync(); // get the default instance of the scanner
            //fakeScanner = new FakeScanner(scanner.DeviceId);
            claimedScanner = await scanner.ClaimScannerAsync();//Attempts to get an exclusive access to the scanner.
            claimedScanner.DataReceived += claimedScanner_DataReceived;
            await claimedScanner.EnableAsync(); //Gets the barcode scanner into a ready state.
            claimedScanner.IsDecodeDataEnabled = true; // provide decoded label data
        }

5. Now that we have the ClaimBarcodeScanner method created, we are ready to start getting data from the barcode scanner, just let’s read the information captured on the claimedScanner_DataReceived event:

async void  claimedScanner_DataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
        {
            string label, data; //Label and data are de values returned by the scanner
            UInt32 symbology = 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);
            }
            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, () =>
            {
                tbData.Text = data; //Send the data to the UI through the dispatcher. tbData is a textbox in the UI
                tbLabel.Text = label; //Send the data to the UI through the dispatcher. tbLabel is a textbox in the UI
            });
              
           
        }
6. Just to finish it, you can call the new method from your constructor to execute it once you start the application.

WP_20140518_002 That’s all! Just deploy the application into your device and play

Now you can scan any kind of barcode you have at home or in your warehouse.

If you want to check with symbologies are recognized, check this website out, as the list is very long! But think on any kind of  barcode.

Just for extra information, the following most common barcodes are supported by the decoder:
UPC-A, UPC-E, EAN-8, EAN-13, Code 39, Code 93, Code 128, ITF, Codabar, MSI, RSS-14 (all variants), QR Code, Data Matrix, Aztec and PDF-417.

And if you are wondering how can you get a barcode using the camera instead the scanner, here you have a library that can do it: https://zxingnet.codeplex.com/ but this is a topic for another article :)

- May the code be with you -

References:

WEH 8.1 MSDN : http://msdn.microsoft.com/en-us/library/dn715922.aspx

WEH 8.1 SDK: http://www.microsoft.com/en-us/download/details.aspx?id=42538

  • Note that the RunAsync method is NOT available if you are building a phone 8.1 Silverlight application. In that case the method to call is BeginInvoke.

Page 1 of 1 (1 items)
Leave a Comment
  • Please add 6 and 7 and type the answer here:
  • Post