Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();
            InitialDefaultValue();
            string mSettingsPath = null;
            string strTempFolder = Application.ExecutablePath;

            strTempFolder = strTempFolder.Replace("/", "\\");
            if (!strTempFolder.EndsWith(@"\", false, System.Globalization.CultureInfo.CurrentCulture))
            {
                strTempFolder += @"\";
            }
            int pos = strTempFolder.LastIndexOf("\\Samples\\");

            if (pos != -1)
            {
                strTempFolder = strTempFolder.Substring(0, strTempFolder.IndexOf(@"\", pos));
                mSettingsPath = strTempFolder + @"\Samples\Bin\Templates\";
            }
            else
            {
                pos           = strTempFolder.LastIndexOf("\\");
                strTempFolder = Application.StartupPath + "\\Bin";
                mSettingsPath = strTempFolder + @"\\Templates\\";
            }
            barcodeReader.LicenseKeys = m_StrProductKey;

            try
            {
                barcodeReader.LoadSettingsFromFile(mSettingsPath + "template_aggregation.json");
            }
            catch
            {
                MessageBox.Show("Failed to load the settings file, please check the file path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!Directory.Exists(_lastOpenedDirectory))
            {
                _lastOpenedDirectory = string.Empty;
            }
        }
Esempio n. 2
0
        public Form1()
        {
            InitializeComponent();
            InitialDefaultValue();
            barcodeReader.LicenseKeys = "t0068MgAAAEBDbYNoTMuh5/ccI24YdlzcggFG93NGuHrF/AWmcbKAsObdABAWC5GvZZpXBlfrsJhkQ1yMO4B8qTUnk6S8HdY=";

            try
            {
                string _mSettingsFilePath = "E:\\Program Files (x86)\\Dynamsoft\\Barcode Reader 6.2\\Templates\\template_aggregation.json";
                barcodeReader.LoadSettingsFromFile(_mSettingsFilePath);
            }
            catch
            {
                MessageBox.Show("Failed to load the settings file, please check the file path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!Directory.Exists(_lastOpenedDirectory))
            {
                _lastOpenedDirectory = string.Empty;
            }
        }
Esempio n. 3
0
 private void Barcode_Click(object sender, RoutedEventArgs e)
 {
     if (m_CoreForImageThum.ImageBuffer.HowManyImagesInBuffer > 0)
     {
         try
         {
             BarcodeReader m_BarcodeReader = new BarcodeReader();
             m_BarcodeReader.LicenseKeys = m_StrProductKey;
             m_BarcodeReader.LoadSettingsFromFile(mSettingsPath + "template_aggregation.json");
             Bitmap       bmp = (Bitmap)(m_CoreForImageThum.ImageBuffer.GetBitmap(m_CoreForImageThum.ImageBuffer.CurrentImageIndexInBuffer));
             DateTime     beforeRead = DateTime.Now;
             TextResult[] aryResult = m_BarcodeReader.DecodeBitmap(bmp, "All_DEFAULT"); DateTime afterRead = DateTime.Now;
             int          timeElapsed = (int)(afterRead - beforeRead).TotalMilliseconds;
             this.ShowResult(aryResult, timeElapsed);
         }
         catch (Exception exp)
         {
             MessageBox.Show(exp.Message, "Decoding Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }