Exemplo n.º 1
0
 /// <summary>
 /// Get the Monk string of given device
 /// </summary>
 /// <param name="deviceName">Device Name</param>
 /// <returns>String the Monk String</returns>
 private string GetMonkString(string deviceName)
 {
     if (WebCams.IndexOf(deviceName) != -1)
     {
         return(WebCamsMonkList[WebCams.IndexOf(deviceName)]);
     }
     return(null);
 }
Exemplo n.º 2
0
        private bool InitializeDevices()
        {
            try
            {
                WriteLog("Initialize barcode drivers... ");
                BarcodeDriverFactory driverFactory = new BarcodeDriverFactory();
                driverFactory.LoadDrivers(Properties.Settings.Default.Drivers.OfType <string>().ToArray(), (s, ex) =>
                {
                    WriteLog(string.Format("Failed to load driver library '{0}'", s), ex);
                });

                cbBarcodeDriver.DataSource = driverFactory.Drivers;

                if (driverFactory.Drivers.Count > 0)
                {
                    WriteLog(driverFactory.Drivers.Count + " camera(s) found:", false, false);

                    foreach (IBarcodeDriver driver in driverFactory.Drivers)
                    {
                        WriteLog(driver.Name, true);
                    }
                }
                else
                {
                    WriteLog("no barcode drivers loaded", false, false);
                    return(false);
                }

                WriteLog("Prepare camera... ");
                IEnumerable <IWebCam> devices = (_webCams = new WebCams()).EnumerateDevices();
                cbCamera.DataSource = devices;

                if (cbCamera.Items.Count > 0)
                {
                    WriteLog(cbCamera.Items.Count + " camera(s) found:", false, false);
                    foreach (IWebCam webCam in devices)
                    {
                        WriteLog(webCam.Name, true);
                    }

                    return(true);
                }

                WriteLog(" no camera detected", false, false);
            }
            catch (Exception ex)
            {
                WriteLog("Failed to initialize devices", ex);
            }

            return(false);
        }