Exemple #1
0
        /****************************************************************************************************/
        #region Implementation of IImageAnalyzer
        public void Analyze(ImageChangedEventArgs imgArgs, DeviceType device)
        {
            //logger.Info("entering Analyze Method");
            var qwe = AnalyzeCompleted.GetInvocationList();

            Image inputImage = imgArgs.Img;

            //logger.Info("Анализируемый файл: " + imgArgs.ImgPath);

            ProcessNewImageFromDevice(inputImage, device, imgArgs);

            //logger.Info("After run parrallel framegraber. Exiting Analyze");
        }
Exemple #2
0
 private void ScanFiles()
 {
     lock (thisLock) {
         _autoEvent.Reset();
         AnalyzeResult result = AnalyzeResult.Success;
         Exception     error  = null;
         try {
             if (string.IsNullOrEmpty(_directory))
             {
                 throw new ArgumentNullException(_directory);
             }
             if (!Directory.Exists(_directory))
             {
                 throw new FileNotFoundException();
             }
             string[] _files;
             if (_scanSubFolder)
             {
                 _files = Directory.GetFiles(_directory, "*.*", SearchOption.AllDirectories);
             }
             else
             {
                 _files = Directory.GetFiles(_directory, "*.*");
             }
             _totalFiles = _files.Length;
             if (_files.Length > 0)
             {
                 int progress   = 0;
                 int entryIndex = 0;
                 foreach (string file in _files)
                 {
                     FileInfo info = new FileInfo(file);
                     if (_autoEvent.WaitOne(0, false))
                     {
                         result = AnalyzeResult.Cancel;
                         break;
                     }
                     else
                     {
                         if (Progress != null)
                         {
                             AnalyzeProgress ap = new AnalyzeProgress(progress, info);
                             Progress(this, ap);
                             // _synchronizationContext.Post((o) => Progress(this, ap), null);
                         }
                         FileEntry entry = _controlAnalyzer.ValidateSource(info);
                         if (entry != null)
                         {
                             if (FileEntryAdded != null)
                             {
                                 FileEntryChanged fec = new FileEntryChanged(entryIndex, entry);
                                 FileEntryAdded(this, fec);
                                 // _synchronizationContext.Post((o) => FileEntryAdded(this, fec), null);
                             }
                         }
                     }
                     progress++;
                 }
             }
         } catch (Exception ex) {
             result = AnalyzeResult.Error;
             error  = ex;
         } finally {
         }
         if (Completed != null)
         {
             AnalyzeCompleted ac = new AnalyzeCompleted(result, error);
             Completed(this, ac);
         }
     }
 }