private void txtQRScan_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == (char)Keys.Return)
            {
                e.Handled = true;

                PDFcreator pDFcreator = new PDFcreator();

                this.txtQRScan.LostFocus += new System.EventHandler(this.returnFocus);

                pDFcreator.CreatePDF6x4(new BarcodeReading()
                {
                    Barcode = "", Floor = "", Job = "", Tag = ""
                }, "#000000");

                pdfViewer.setShowToolbar(false);
                pdfViewer.setShowScrollbars(true);
                pdfViewer.LoadFile(@"..\..\Labels\label.pdf");
                try
                {
                    BarcodeReading barcodeReading = controller.RegisterBarcodeScan(txtQRScan.Text);
                    pDFcreator.CreatePDF6x4(barcodeReading, controller.getJobColor(barcodeReading.Job));
                    pdfViewer.LoadFile(string.Format(@"..\..\Labels\{0}.pdf", barcodeReading.Barcode));

                    backgroundQueue.QueueTask(() => Print(barcodeReading.Barcode, barcodeReading.Line));
                }
                catch (Exception ex)
                {
                    controller.Log("Printing failed.", ex);
                    pdfViewer.LoadFile("none");
                }



                //pdfViewer.printAll();
                txtQRScan.Clear();
            }
        }
        private void txtQRScan_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == (char)Keys.Return && txtQRScan.Text.Trim().Length > 0)
            {
                try
                {
                    e.Handled = true;

                    PDFcreator pDFcreator = new PDFcreator();

                    this.txtQRScan.LostFocus += new System.EventHandler(this.returnFocus);

                    pdfViewer.LoadFile("none");


                    int line = Convert.ToInt32(txtQRScan.Text.Trim().Substring(1, 1));

                    if (line > 3)
                    {
                        throw new Exception("Line not registered");
                    }

                    if (!(lastScanings[line] != null && DateTime.Now < ((DateTime)lastScanings[line]).AddSeconds(WaitingTime)))
                    {
                        if (txtQRScan.Text.Contains("ScanToPrintTestLabel"))
                        {
                            lastScanings[line] = DateTime.Now;
                            int printer = controller.GetTargetPrinter(line);

                            BarcodeReading barcodeTest = GenerateTestBarcode(printer);

                            if (printer == line)
                            {
                                pDFcreator.CreatePDF6x4(GenerateTestBarcode(line), "#dedede");
                            }
                            else
                            {
                                pDFcreator.CreatePDF6x4FromAnotherLine(GenerateTestBarcode(line), "#dedede");
                            }

                            pdfViewer.LoadFile(string.Format(@"..\..\Labels\{0}.pdf", barcodeTest.Barcode));

                            backgroundQueue.QueueTask(() => Print(barcodeTest.Barcode, printer));
                        }
                        else
                        {
                            BarcodeReading barcodeReading = controller.RegisterBarcodeScan(txtQRScan.Text);

                            if (barcodeReading != null)
                            {
                                lastScanings[barcodeReading.Line] = DateTime.Now;
                            }

                            int printer = controller.GetTargetPrinter(barcodeReading.Line);

                            if (printer == barcodeReading.Line)
                            {
                                pDFcreator.CreatePDF6x4(barcodeReading, controller.GetJobColor(barcodeReading.Job));
                            }
                            else
                            {
                                pDFcreator.CreatePDF6x4FromAnotherLine(barcodeReading, controller.GetJobColor(barcodeReading.Job));
                            }

                            pdfViewer.LoadFile(string.Format(@"..\..\Labels\{0}.pdf", barcodeReading.Barcode));

                            backgroundQueue.QueueTask(() => Print(barcodeReading.Barcode, printer));
                        }
                    }
                }
                catch (Exception ex)
                {
                    controller.Log("Printing failed.", ex);
                    pdfViewer.LoadFile("none");
                }
                txtQRScan.Clear();
            }
        }