/// <summary> /// Performs OCR on project images. /// </summary> /// <returns></returns> public ActionResult PerformOcr() { Gallery.RecognizableElementOcrCompleted += Gallery_RecognizableElementOcrCompleted; _longOperationsDataContainer = new LongOperationsData(0, Gallery.GetRecognizableElementsQuantity(), Properties.Resources.PerformOcr_CurrentIterationMessageTemplate, Properties.Resources.PerformOcr_Description); ProjectElementOcrCompleted?.Invoke(this, new LongOperationsDataEventArgs(_longOperationsDataContainer)); try { foreach (GalleryImage image in Gallery.Images) { image.PerformOcr(DataColumns); } return(new ActionResult()); } catch (Exception e) { LogHelper.Logger.Error(e, $"Unable to perform OCR in the project '{Name}'"); return(new ActionResult(ActionResultType.Error, e.Message)); } finally { _longOperationsDataContainer = null; Gallery.RecognizableElementOcrCompleted -= Gallery_RecognizableElementOcrCompleted; } }
private void Gallery_RecognizableElementOcrCompleted(object sender, EventArgs eventArgs) { if (_longOperationsDataContainer != null) { _longOperationsDataContainer.Iterate(); ProjectElementOcrCompleted?.Invoke(this, new LongOperationsDataEventArgs(_longOperationsDataContainer)); } }