Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win RT - universal app with barcode scanner

I am developing a universal app for both Windows 8.1 and Windows Phone 8.1 which I want to be able to scan barcodes. For Windows 8.1, there exists a native class BarcodeScanner which is unfortunately inaccessible for Windows Phone 8.1 (I really don't understand what led Microsoft to do it this way). I found a 3rd party solution called zxing, but here I have read that it works terribly for universal apps. What is the best way to implement barcode scanning functionality in universal apps?

Thank you!

like image 347
marek_lani Avatar asked Jul 13 '14 08:07

marek_lani


1 Answers

I would just use a text box. Most barcode scanners will act as keyboards and after a scan will send an enter key input. If your text box listens to the key up event and checks for the enter key you will know when a scan is complete. I personally would not use the Point of service. It's from an old version of .NET and from my experience it won't even work on desktop apps. This is what it would look like for me.

private void TextBox1_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            this.MyFunction(this.TextBox1.Text);
        }
    }

The nice thing about doing it this way is that the program can run without the barcode scanner if needed. The user can just type in the number and hit enter. The downside is that the text box needs to be selected in order for the program to receive input. In order to reduce or eliminate the user having to select the textbox all the time you can set the focus using this.TextBox1.Focus().

like image 119
LochnessLAM Avatar answered Nov 14 '22 23:11

LochnessLAM