Exemplo n.º 1
0
        public static void KeyHandlerDown(Object o, UI.Keypad.KeyEventArgs evArgs)
        {
            int keyCode;

            keyCode = evArgs.KeyChar;

            if (keyCode == 43)
            {
                Environment.Exit(0);
            }
            else if (keyCode == 1 && !BarcodeScanner.barcodeIsSet)
            {
                BarcodeScanner.Scan();
            }
            else if (!CountSetter.countSet)
            {
                CountSetter.SetCount(keyCode);
            }
            else
            {
                if (keyCode == 10)
                {
                    Printer.Print();
                }
                else if (keyCode == 9)
                {
                    BarcodeScanner.barcodeIsSet = false;
                    CountSetter.ResetCount();
                    SetInitialScreen();
                }
            }
        }
Exemplo n.º 2
0
        public static void Scan()
        {
            Communication.USBHost usbHost = new Communication.USBHost("/dev/ttyUSB0");

            usbHost.Open();

            if (usbHost.IsOpen)
            {
                FileStream fileStream = usbHost.GetStream();

                try
                {
                    int length;

                    while (true)
                    {
                        Byte[] bytes = new Byte[256];

                        if ((length = fileStream.Read(bytes, 0, bytes.Length)) > 0)
                        {
                            scannedBarcode = Encoding.ASCII.GetString(bytes, 0, length).Trim();

                            barcodeIsSet = true;

                            CountSetter.SetCountScreen();
                            break;
                        }
                        else
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }
                catch (Exception ex)
                {
                }

                usbHost.Close();
            }

            usbHost.Dispose();
        }