Ejemplo n.º 1
0
 protected void barcode_Click(object sender, EventArgs e)
 {
     k++;
     if (fileUploader.HasFile)
     {
         try
         {
             #region Upload File
             string filename = Path.GetFileName(fileUploader.FileName);
             fileUploader.SaveAs(Server.MapPath(@"~/images/") + "barcodeImg" + k + Path.GetExtension(filename));
             image.ImageUrl = @"~/images/" + "barcodeImg" + k + Path.GetExtension(filename);
             #endregion
             #region Barcode Reader
             Bitmap        bitmap = new Bitmap(Server.MapPath(image.ImageUrl));
             BarcodeResult Result = IronBarCode.BarcodeReader.QuicklyReadOneBarcode(bitmap);
             txtISBN.Text = Result.Text;
             #endregion
             lblUpload.Style.Value = "Color:Gray";
             lblUpload.Text        = "ISBN textbox kısmı dolduruldu silme işlemi yapmak için sil butonuna basınız.";
         }
         catch (Exception ex)
         {
             lblUpload.Style.Value = "Color:Red";
             lblUpload.Text        = "Bir hata oluştu.<html></br></html> Hata Mesajı: " + ex.Message;
         }
     }
     else if (!fileUploader.HasFile)
     {
         lblUpload.Style.Value = "Color:Red";
         lblUpload.Text        = "Dosya Seçmediniz.";
     }
 }
Ejemplo n.º 2
0
        private void btnBrowseBarCode_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = "E:\\an3facsem2\\pdpf2\\FireCaffe\\FireCaffe\\bin\\Debug";
            dlg.Filter           = "Image files (*.jpeg)|*.jpeg|All Files (*.*)|*.*";
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() == true)
            {
                string      selectedFileName = dlg.FileName;
                BitmapImage bitmap           = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri(selectedFileName);
                bitmap.EndInit();
                userBarCode.Source = bitmap;
                BarcodeResult FormatsResult = BarcodeReader.QuicklyReadOneBarcode("barcode.jpeg", BarcodeEncoding.Code128);
                string        result        = FormatsResult.Text;

                ClientServices clientServices = new ClientServices();
                List <Client>  scannedClient  = clientServices.GetClientByPassword(result);
                scannedClient[0].SilverCups += 2;
                if (scannedClient[0].SilverCups >= num)
                {
                    scannedClient[0].GoldenCups += 1;
                    scannedClient[0].SilverCups  = scannedClient[0].SilverCups % 10;
                }

                clientServices.Update(scannedClient[0]);
                MessageBox.Show("User: "******" has received 2 SilverCups");
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            txtResult.Text = string.Empty;

            if (txtImageFile.Text != "")
            {
                string[] words     = txtImageFile.Text.Split('.');
                string   extension = words[words.Length - 1];

                if (extension.ToLower() == "pdf")
                {
                    //Create a new barcode reader
                    BarcodeReader reader = new BarcodeReader(txtImageFile.Text, FormatType.PDF);

                    if (this.checkBox1.Checked)
                    {
                        //Scan multiple barcodes
                        BarcodeResultCollection results = reader.ScanMultipleBarcode();
                        DisplayResult(results);
                    }
                    else
                    {
                        //scan barcode
                        BarcodeResult result = reader.ScanBarcode();
                        DisplayResult(result);
                    }
                }
                else
                {
                    MessageBox.Show("Please select PDF", "Barcode Reader", MessageBoxButtons.OK);
                }
            }
        }
        internal void BarcodeScannedResult(BarcodeResult result)
        {
            barcodeTextLabel.Text = result.BarcodeString;

            RLBarcodeType btype = (RLBarcodeType) result.BarcodeType;

            // update view with scanned barcode type
            if (btype == RLBarcodeType.EAN13)
            {
                // Use first digit to differentiate between EAN13 and UPCA
                if (result.BarcodeString[0] == '0')
                {
                    barcodeTextLabel.Text = result.BarcodeString.Substring (1);
                    typeLabel.Text = "UPC-A";
                }
                else
                    typeLabel.Text = "EAN-13";
            }
            else if (btype == RLBarcodeType.EAN8) typeLabel.Text = "EAN-8";
            else if (btype == RLBarcodeType.UPCE) typeLabel.Text = "UPC-E";
            else if (btype == RLBarcodeType.QRCODE) typeLabel.Text = "QR Code";
            else if (btype == RLBarcodeType.Code128) typeLabel.Text = "Code 128";
            else if (btype == RLBarcodeType.Code39) typeLabel.Text = "Code 39";
            else if (btype == RLBarcodeType.DataMatrix) typeLabel.Text = "Data Matrix";
            else if (btype == RLBarcodeType.ITF) typeLabel.Text = "ITF";
            else if (btype == RLBarcodeType.STICKY) typeLabel.Text = "STICKYBITS";
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Clear text box
            txtResult.Text = string.Empty;

            string[] words     = txtImageFile.Text.Split('.');
            string   extension = words[words.Length - 1];

            if (extension.ToLower() == "png" || extension.ToLower() == "bmp" || extension.ToLower() == "jpg")
            {
                if (txtImageFile.Text != "" && txtImageFile.Text != string.Empty)
                {
                    if (checkBox1.Checked)
                    {
                        //Read multiple barcodes
                        BarcodeResultCollection result = BarcodeReader.ScanMultipleBarcode(txtImageFile.Text);
                        AddText(result);
                    }
                    else
                    {
                        //Read barcode
                        BarcodeResult result = BarcodeReader.ScanBarcode(txtImageFile.Text);
                        AddText(result);
                    }
                }
            }
            else if (extension.ToLower() == "pdf")
            {
                Bitmap[] images;

                //Load existing document
                PdfLoadedDocument ldoc = new PdfLoadedDocument(txtImageFile.Text);

                //Export the document as images
                images = ldoc.ExportAsImage(0, ldoc.Pages.Count - 1);

                //Scan barcodes
                foreach (Bitmap img in images)
                {
                    BarcodeReader reader = new BarcodeReader(img);
                    if (checkBox1.Checked)
                    {
                        reader.Settings.TryHarder = true;
                        BarcodeResultCollection results = reader.ScanMultipleBarcode();
                        AddText(results);
                    }
                    else
                    {
                        BarcodeResult result = reader.ScanBarcode();
                        AddText(result);
                    }
                }
            }

            else
            {
                MessageBox.Show("Please select a barcode image or PDF", "Barcode Reader", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 6
0
 protected void ver()
 {
     try
     {
         i++;
         string filename = Path.GetFileName(fileUploader2.FileName);
         fileUploader2.SaveAs(Server.MapPath(@"~/images/") + "image" + i + Path.GetExtension(filename));
         image2.ImageUrl = @"~/images/image" + i + Path.GetExtension(filename);
         Bitmap        bitmap   = new Bitmap(Server.MapPath(image2.ImageUrl));
         BarcodeResult Result   = IronBarCode.BarcodeReader.QuicklyReadOneBarcode(bitmap);
         SqlCommand    kullanim = new SqlCommand("SELECT KULLANIMDA FROM KITAPLAR WHERE ISBN='" + Result.Text + "'", connection);
         kullanim.ExecuteNonQuery();
         System.Data.DataTable dataTable   = new System.Data.DataTable();
         SqlDataAdapter        dataAdapter = new SqlDataAdapter(kullanim);
         dataAdapter.Fill(dataTable);
         string kullanimda = dataTable.Rows[0].ItemArray[0].ToString();
         kullanimda = kullanimda.Replace(" ", "");
         if (kullanimda == "1")
         {
             SqlCommand kota = new SqlCommand("SELECT KITAP_KOTA FROM KULLANICILAR WHERE KULLANICI_ADI='" + userName + "'", connection);
             kota.ExecuteNonQuery();
             System.Data.DataTable kotaTable   = new System.Data.DataTable();
             SqlDataAdapter        kotaAdapter = new SqlDataAdapter(kota);
             kotaAdapter.Fill(kotaTable);
             string kotaSTR = kotaTable.Rows[0].ItemArray[0].ToString();
             kotaSTR = kotaSTR.Replace(" ", "");
             int kotaN = Convert.ToInt32(kotaSTR.ToString());
             if (kotaN > 0)
             {
                 SqlCommand command = new SqlCommand("DELETE FROM KITAPSURE WHERE KULLANICI_ID='" + userName + "' AND KITAP_ID='" + Result.Text + "'", connection);
                 if (connection.State == System.Data.ConnectionState.Open)
                 {
                     connection.Close();
                 }
                 connection.Open();
                 command.ExecuteNonQuery();
                 SqlCommand kullanimc = new SqlCommand("UPDATE KITAPLAR SET KULLANIMDA='0',KITAP_SAHIP=NULL WHERE ISBN='" + Result.Text + "'", connection);
                 kullanimc.ExecuteNonQuery();
                 SqlCommand kotaK = new SqlCommand("UPDATE KULLANICILAR SET KITAP_KOTA-=1 WHERE KULLANICI_ADI='" + userName + "'", connection);
                 kotaK.ExecuteNonQuery();
                 Response.Write("<script>alert('Kitap Başarıyla Verilmiştir.')</script>");
             }
             else
             {
                 Response.Write("<script>alert('Elinizde Hiç Kitap Yok. Olmayan Kitapları Veremezsiniz.')</script>");
             }
         }
         else
         {
             Response.Write("<script>alert('Kitap Zaten Verilmiş.')</script>");
         }
         goruntule();
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('Hata" + ex.Message + "')</script>");
     }
 }
Ejemplo n.º 7
0
        public static void GetStarted()
        {
            BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png");

            if (Result != null && Result.Text == "https://ironsoftware.com/csharp/barcode/")
            {
                Console.WriteLine("GetStarted was a success.  Read Value: " + Result.Text);
            }
        }
Ejemplo n.º 8
0
        private void prs_barcode_btn_Click(object sender, EventArgs e)
        {
            BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png");

            if (Result != null && Result.Text == "https://ironsoftware.com/csharp/barcode/")
            {
                MessageBox.Show("vahid", "vahid");
            }
        }
Ejemplo n.º 9
0
    public override void OnReceive(Context context, Intent intent)
    {
        BarcodeResult barcodeResult = new BarcodeResult(intent);

        if (barcodeResult.IsBarcodeAction)
        {
            this.Barcode = barcodeResult.Barcode;
            OnScannerResponseEvent(new EventArgs());
        }
    }
 private void DisplayResult(BarcodeResult result)
 {
     if (result != null)
     {
         txtResult.Text += "Barcode Type: " + result.BarcodeType + " " + "Text: " + result.Text + "\r\n";
     }
     else
     {
         MessageBox.Show("Barcode could not be detected", "Barcode Reader", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 11
0
 protected void ekle()
 {
     txtISBN.Text = "";
     txtName.Text = "";
     i++;
     if (fileUploader.HasFile)
     {
         try
         {
             #region Upload File
             string filename = Path.GetFileName(fileUploader.FileName);
             fileUploader.SaveAs(Server.MapPath(@"~/images/") + "image" + i + Path.GetExtension(filename));
             image.ImageUrl = @"~/images/" + "image" + i + Path.GetExtension(filename);
             #endregion
             #region Barcode Reader
             Bitmap        bitmap = new Bitmap(Server.MapPath(image.ImageUrl));
             BarcodeResult Result = IronBarCode.BarcodeReader.QuicklyReadOneBarcode(bitmap);
             txtISBN.Text = Result.Text;
             #endregion
             #region Get Data From Web Site
             var      url   = "https://www.abebooks.com/servlet/SearchResults?sts=t&isbn=" + txtISBN.Text;
             var      web   = new HtmlWeb();
             var      doc   = web.Load(url);
             String[] value = new String[3];
             value[0]     = doc.DocumentNode.SelectSingleNode("//*[@id='book-1']/div[2]/div[1]/h2/a/span").InnerText.ToString();
             value[1]     = doc.DocumentNode.SelectSingleNode("//*[@id='book-1']/div[2]/div[1]/p[1]/strong").InnerText.ToString();
             value[2]     = doc.DocumentNode.SelectSingleNode("//*[@id='listing_1']/div/img").Attributes["src"].Value;
             value[1]     = value[1].Replace("Author:", "");
             txtName.Text = value[0].Replace("&#39;", "'");
             #endregion
             #region Insert Book into Database
             SqlCommand command = new SqlCommand("declare @isbn varchar(30); declare @name varchar(100); declare @author varchar(100); declare @image varchar(100);set @name=@namePar;set @isbn =@isbnPar; set @author=@authorPar; set @image=@imagePar;INSERT INTO KITAPLAR VALUES(@isbn, @name, DEFAULT, @author, @image,NULL)", connection);
             command.Parameters.AddWithValue("@isbnPar", txtISBN.Text);
             command.Parameters.AddWithValue("@namePar", txtName.Text);
             command.Parameters.AddWithValue("@authorPar", value[1]);
             command.Parameters.AddWithValue("@imagePar", value[2]);
             if (connection.State == System.Data.ConnectionState.Open)
             {
                 connection.Close();
             }
             connection.Open();
             command.ExecuteNonQuery();
             lblUpload.Style.Value = "Color:Green";
             lblUpload.Text        = "Yükleme İşlemi:Başarılı!";
             #endregion
         }
         catch (Exception ex)
         {
             lblUpload.Style.Value = "Color:Red";
             lblUpload.Text        = "Yükleme İşlemi:Bir hata oluştu.Bir nedenden dolayı dosyayı yükleyemedik.<html></br></html> Hata Mesajı: " + ex.Message;
         }
     }
 }
Ejemplo n.º 12
0
        public string BarkodOku(string sFileName)
        {
            BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode(sFileName);

            if (Result != null)
            {
                ViewBag.Barkod = Result.ToString();
                return(Result.ToString());
            }
            else
            {
                ViewBag.Barkod = "okunmadı";
                return("Okunamadı.");
            }
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            /******     WRITE     *******/
            // Create A Barcode in 1 Line of Code
            //BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode).SaveAsJpeg("D:\\svg\\QuickStart.jpg");
            /******    READ    *******/
            // Read A Barcode in 1 Line of Code.  Gets Text, Numeric Codes, Binary Data and an Image of the barcode
            BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("D:\\svg\\BARCODE.jpg");

            // Assert that IronBarCode Works :-)
            if (Result != null)
            {
                System.Console.WriteLine(Result.Text);
            }
            Console.Read();
        }
Ejemplo n.º 14
0
        // Распознавание QR-кода в PDF-файле
        public void PDFQRCodeRecognition(string PDF)
        {
            Bitmap        bmp     = new Bitmap("c:\\QRPDF Test Directory\\Cutted QR\\Test11.png");
            BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp);

            Console.WriteLine("barcode data:{0}.", barcode.Data);


            BarcodeResult[] results = BarCodeScanner.Scan("c:\\QRPDF Test Directory\\Cutted QR\\Test11.png", BarCodeType.QRCode);

            foreach (BarcodeResult result in results)
            {
                Console.WriteLine(result.BarType.ToString() + "-" + result.Data);
            }

            Console.ReadKey();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Handles the Click event of the ScanBarcodeButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void ScanBarcodeButton_Click(object sender, RoutedEventArgs e)
        {
            if (Image.Source != null &&
                Image.Source.IsFilled)
            {
                IBarcodeReader barcodeReader = new ZXingBarcodeReader(true, BinarizerMode.Hybrid);

                BarcodeResult result = barcodeReader.ReadBarcode(Image.Source);

                if (result != null)
                {
                    BarcodeTextTextBox.Text   = result.Text;
                    BarcodeFormatTextBox.Text = result.Format.ToString();
                }
                else
                {
                    BarcodeTextTextBox.Text   = "Barcode not detected!";
                    BarcodeFormatTextBox.Text = "Barcode not detected!";
                }
            }
        }
Ejemplo n.º 16
0
        protected void al()
        {
            try
            {
                i++;
                string filename = Path.GetFileName(fileUploader1.FileName);
                fileUploader1.SaveAs(Server.MapPath(@"~/images/") + "image" + i + Path.GetExtension(filename));
                image1.ImageUrl = @"~/images/image" + i + Path.GetExtension(filename);
                Bitmap        bitmap = new Bitmap(Server.MapPath(image1.ImageUrl));
                BarcodeResult Result = IronBarCode.BarcodeReader.QuicklyReadOneBarcode(bitmap);
                SqlCommand    date   = new SqlCommand("SELECT KITAP_SURE FROM KITAPSURE WHERE KULLANICI_ID='" + userName + "'", connection);
                date.ExecuteNonQuery();
                System.Data.DataTable dateTable   = new System.Data.DataTable();
                SqlDataAdapter        dateAdapter = new SqlDataAdapter(date);
                dateAdapter.Fill(dateTable);
                string     onay    = "";
                string     yeni    = "";
                DateTime[] dateRow = new DateTime[3];
                if (dateTable.Rows.Count == 0)
                {
                    yeni = "yeni";
                }
                for (int t = 0; t < dateTable.Rows.Count; t++)
                {
                    dateRow[t] = Convert.ToDateTime(dateTable.Rows[t].ItemArray[0]);
                    int a = (DateTime.Now.Subtract(dateRow[t])).Days;
                    if (7 > a)
                    {
                        onay = "verildi";
                    }
                    else
                    {
                        onay = "verilmedi";
                        break;
                    }
                }

                if (onay == "verildi" || yeni == "yeni")
                {
                    SqlCommand kullanim = new SqlCommand("SELECT KULLANIMDA FROM KITAPLAR WHERE ISBN='" + Result.Text + "'", connection);
                    kullanim.ExecuteNonQuery();
                    System.Data.DataTable dataTable   = new System.Data.DataTable();
                    SqlDataAdapter        dataAdapter = new SqlDataAdapter(kullanim);
                    dataAdapter.Fill(dataTable);
                    string kullanimda = dataTable.Rows[0].ItemArray[0].ToString();
                    kullanimda = kullanimda.Replace(" ", "");
                    if (kullanimda == "0")
                    {
                        SqlCommand kota = new SqlCommand("SELECT KITAP_KOTA FROM KULLANICILAR WHERE KULLANICI_ADI='" + userName + "'", connection);
                        kota.ExecuteNonQuery();
                        System.Data.DataTable kotaTable   = new System.Data.DataTable();
                        SqlDataAdapter        kotaAdapter = new SqlDataAdapter(kota);
                        kotaAdapter.Fill(kotaTable);
                        string kotaSTR = kotaTable.Rows[0].ItemArray[0].ToString();
                        kotaSTR = kotaSTR.Replace(" ", "");
                        int kotaN = Convert.ToInt32(kotaSTR.ToString());
                        if (kotaN < 3)
                        {
                            SqlCommand command = new SqlCommand("INSERT INTO KITAPSURE VALUES ('" + userName + "','" + Result.Text + "',GETDATE())", connection);
                            if (connection.State == System.Data.ConnectionState.Open)
                            {
                                connection.Close();
                            }
                            connection.Open();
                            command.ExecuteNonQuery();
                            SqlCommand kullanimc = new SqlCommand("UPDATE KITAPLAR SET KULLANIMDA='1',KITAP_SAHIP='" + userName + "' WHERE ISBN='" + Result.Text + "'", connection);
                            kullanimc.ExecuteNonQuery();
                            SqlCommand kotaK = new SqlCommand("UPDATE KULLANICILAR SET KITAP_KOTA+=1 WHERE KULLANICI_ADI='" + userName + "'", connection);
                            kotaK.ExecuteNonQuery();
                            Response.Write("<script>alert('Kitap Başarıyla Alınmıştır.')</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('3 Kitaptan Fazlasını Alamazsınız!')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('Kitap Kullanımda')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Tarihi Geçmiş Kitaplarınız Bulunmaktadır.')</script>");
                }

                goruntule();
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('Hata" + ex.Message + "')</script>");
            }
        }
Ejemplo n.º 17
0
        private void ShowBarcodeResults(BarcodeResult[] barcodeResults, float timeElapsed)
        {
            tbResults.Clear();
            m_results.Clear();
            m_barcodes = barcodeResults;

            if (barcodeResults != null && barcodeResults.Length > 0)
            {
                tbResults.AppendText(String.Format("Total barcode(s) found: {0}. Total time spent: {1} seconds\r\n\r\n", barcodeResults.Length, (timeElapsed / 1000)));
                for (int i = 0; i < barcodeResults.Length; i++)
                {
                    tbResults.AppendText(String.Format("  Barcode {0}:\r\n", i + 1));
                    tbResults.AppendText(String.Format("    Page: {0}\r\n", barcodeResults[i].PageNumber));
                    tbResults.AppendText(String.Format("    Type: {0}\r\n", barcodeResults[i].BarcodeFormat));
                    tbResults.AppendText(String.Format("    Value: {0}\r\n", barcodeResults[i].BarcodeText));
                    tbResults.AppendText(String.Format("    Region: {{Left: {0}, Top: {1}, Width: {2}, Height: {3}}}\r\n", barcodeResults[i].BoundingRect.Left, barcodeResults[i].BoundingRect.Top, barcodeResults[i].BoundingRect.Width, barcodeResults[i].BoundingRect.Height));
                    tbResults.AppendText("\r\n");
                }
                tbResults.SelectionStart = 0;
                tbResults.ScrollToCaret();

                int iLastPageNumber = int.MinValue + 10;
                int iStartIndex = barcodeResults.Length - 1;
                for (int i = 0; i < iPageCount; i++)
                    m_results.Add(null);
                for (int i = iStartIndex; i >= 0; i--)
                {
                    if (barcodeResults[i] != null)
                    {
                        if (barcodeResults[i].PageNumber != iLastPageNumber)
                        {
                            if (i != iStartIndex)
                            {
                                int iEnd = i > iStartIndex ? i - 1 : i + 1;
                                int iStart = iEnd > iStartIndex ? iStartIndex : iEnd;
                                iEnd = iEnd > iStartIndex ? iEnd : iStartIndex;
                                int[] resultsOnePage = new int[iEnd - iStart + 1];
                                for (int k = iStart; k <= iEnd; k++)
                                {
                                    resultsOnePage[k - iStart] = k;
                                }
                                m_results[iLastPageNumber-1] = resultsOnePage;
                            }
                            iStartIndex = i;
                            iLastPageNumber = barcodeResults[i].PageNumber;
                        }

                        if (i == 0)
                        {
                            int iStart = i > iStartIndex ? iStartIndex : i;
                            int iEnd = i > iStartIndex ? i : iStartIndex;
                            int[] resultsOnePage = new int[iEnd - iStart + 1];
                            for (int k = iStart; k <= iEnd; k++)
                            {
                                resultsOnePage[k - iStart] = k;
                            }
                            m_results[iLastPageNumber-1] = resultsOnePage;
                        }
                    }
                }
            }
            else
                tbResults.AppendText(String.Format("No barcode found. Total time spent: {0} seconds\r\n", (timeElapsed / 1000)));

            SetImageViewerImage();
        }
Ejemplo n.º 18
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer < 0)
            {
                MessageBox.Show("Please load an image before reading barcode!", "Index out of bounds", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            try
            {
                Dynamsoft.Barcode.BarcodeReader reader = new Dynamsoft.Barcode.BarcodeReader();
                reader.LicenseKeys = m_StrProductKey;
                reader.ReaderOptions.MaxBarcodesToReadPerPage = int.Parse(tbxMaxNum.Text);
                this.textBox1.Text = "";
                switch (cbxFormat.SelectedIndex)
                {
                case 0:
                    break;

                case 1:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.OneD;
                    break;

                case 2:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_39;
                    break;

                case 3:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_128;
                    break;

                case 4:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODE_93;
                    break;

                case 5:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.CODABAR;
                    break;

                case 6:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.ITF;
                    break;

                case 7:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.EAN_13;
                    break;

                case 8:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.EAN_8;
                    break;

                case 9:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.UPC_A;
                    break;

                case 10:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.UPC_E;
                    break;

                case 11:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.PDF417;
                    break;

                case 12:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.QR_CODE;
                    break;

                case 13:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.DATAMATRIX;
                    break;

                case 14:
                    reader.ReaderOptions.BarcodeFormats = Dynamsoft.Barcode.BarcodeFormat.INDUSTRIAL_25;
                    break;
                }
                this.textBox1.Text = "Recognizing...";
                BarcodeResult[] aryResult = null;
                Rectangle       rect      = dsViewer1.GetSelectionRect(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer);
                if (rect == Rectangle.Empty)
                {
                    int iWidth  = m_ImageCore.ImageBuffer.GetBitmap(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer).Width;
                    int iHeight = m_ImageCore.ImageBuffer.GetBitmap(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer).Height;
                    rect = new Rectangle(0, 0, iWidth, iHeight);
                }
                reader.AddRegion(rect.Left, rect.Top, rect.Right, rect.Bottom, false);
                aryResult = reader.DecodeBitmap((Bitmap)(m_ImageCore.ImageBuffer.GetBitmap(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer)));

                StringBuilder strText = new StringBuilder();
                if (aryResult == null)
                {
                    this.textBox1.Text = "The barcode for selected format is not found.\r\n";
                }
                else
                {
                    strText.AppendFormat(aryResult.Length + " total barcode" + (aryResult.Length == 1 ? "" : "s") + " found.\r\n");
                    for (int i = 0; i < aryResult.Length; i++)
                    {
                        BarcodeResult objResult = aryResult[i];
                        strText.AppendFormat("      Result " + (i + 1) + "\r\n");
                        strText.AppendFormat("      BarcodeFormat: " + objResult.BarcodeFormat.ToString() + "\r\n");
                        strText.AppendFormat("      Text read:{0}\r\n", objResult.BarcodeText);
                    }
                    this.textBox1.Text = strText.ToString();
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Decoding error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textBox1.Text = "";
            }
        }
Ejemplo n.º 19
0
 public void SetBarcodeResults(int index, BarcodeResult[] results)
 {
     if (index >= 0 && index < m_data.Count)
     {
         if (m_data[index] != null && results.Length > 0)
         {
             Pen pen = new Pen(Color.Red, 1);
             Brush textBrush = new SolidBrush(Color.Blue);
             Graphics g = Graphics.FromImage(m_data[index]);
             for (int i = results.Length - 1; i >= 0; i--)
             {
                 if (results[i] != null)
                 {
                     g.DrawRectangle(pen, results[i].BoundingRect);
                     g.DrawString("[" + i + "] {" + results[i].BarcodeText + "}", SystemFonts.DefaultFont, textBrush, results[i].BoundingRect);
                 }
             }
             pen.Dispose();
             textBrush.Dispose();
             g.Dispose();
             if (index == m_index)
                 Refresh();
         }
     }
 }
Ejemplo n.º 20
0
 protected void OnBarcodeScanned(BarcodeResult barcode)
 {
     ReturnResult(barcode);
 }
Ejemplo n.º 21
0
 protected void OnBarcodeScanned(BarcodeResult result)
 {
     ReturnResult(result);
 }
Ejemplo n.º 22
0
        public void HandleDecode(BarcodeResult rawResult, Bitmap barcode)
        {
            PlayBeepSound();

            if(StatusManager.ScannerStatus == StatusManager.RLScannerStatus.DisabledSdkMode)
            {
                DenyDecode("Unregistered SDK Limit Reached");
            }
            else if(StatusManager.ScannerStatus == StatusManager.RLScannerStatus.Error)
            {
                DenyDecode("Redlaser Error");
            }
            else
            {
                Log.Debug("BarcodeScanActivity", rawResult.BarcodeType + ": " + rawResult.BarcodeString);

                var results = new List<BarcodeResult>();
                results.Add(rawResult);
                StatusManager.LogScans(results);

                OnBarcodeScanned(rawResult);
            }
        }
Ejemplo n.º 23
0
        protected void ReturnResult(BarcodeResult barcode)
        {
            if(barcode != null) {
                var returnIntent = new Intent();
                returnIntent.SetAction(barcode.BarcodeString);
                returnIntent.PutExtra("barcode_type", barcode.BarcodeType);
                SetResult (Result.Ok, returnIntent);
            }

            Finish();
        }