コード例 #1
0
        private void ShowError(Exception ex)
        {
            // Shows an error, check if the exception is an OCR, raster or general one
            OcrException ocr = ex as OcrException;

            if (ocr != null)
            {
                Messager.ShowError(this, string.Format(DemosGlobalization.GetResxString(GetType(), "Resx_OCRError"), ocr.Code, ocr.Message));
                return;
            }

#if LEADTOOLS_V175_OR_LATER
            OcrComponentMissingException ocrComponent = ex as OcrComponentMissingException;
            if (ocrComponent != null)
            {
                Messager.ShowError(this, string.Format("OCR Component Missing\n\n{0}\n\nUse 'Engine/Componets' from the menu to show the available components and instructions of how to install the additional components of this OCR engine.", ocrComponent.Message));
                return;
            }
#endif // #if LEADTOOLS_V175_OR_LATER

            RasterException raster = ex as RasterException;
            if (raster != null)
            {
                Messager.ShowError(this, string.Format(DemosGlobalization.GetResxString(GetType(), "Resx_LEADError"), raster.Code, raster.Message));
                return;
            }

            Messager.ShowError(this, ex);
        }
コード例 #2
0
ファイル: Messager.cs プロジェクト: 1059444127/DicomViewer
        public static string CheckIfSupportError(Exception ex, bool ignoreIfNotSupportError)
        {
            string message = ex.Message;

            if (ignoreIfNotSupportError)
            {
                return(message);
            }

            RasterException rex = ex as RasterException;

            if (rex != null)
            {
                if (rex.Code == RasterExceptionCode.FeatureNotSupported | rex.Code == RasterExceptionCode.DicomNotEnabled |
                    rex.Code == RasterExceptionCode.DocumentNotEnabled | rex.Code == RasterExceptionCode.MedicalNotEnabled |
                    /*rex.Code == RasterExceptionCode.ExtGrayNotEnabled | */
                    rex.Code == RasterExceptionCode.ProNotEnabled |
                    rex.Code == RasterExceptionCode.LzwLocked | rex.Code == RasterExceptionCode.JbigNotEnabled |
                    rex.Code == RasterExceptionCode.Jbig2Locked | rex.Code == RasterExceptionCode.J2kLocked |
                    rex.Code == RasterExceptionCode.PdfNotEnabled | rex.Code == RasterExceptionCode.CmwLocked |
                    rex.Code == RasterExceptionCode.AbcLocked | rex.Code == RasterExceptionCode.MedicalNetNotEnabled |
                    rex.Code == RasterExceptionCode.NitfLocked | rex.Code == RasterExceptionCode.JpipLocked |
                    rex.Code == RasterExceptionCode.FormsLocked | rex.Code == RasterExceptionCode.DocumentWritersNotEnabled |
                    rex.Code == RasterExceptionCode.MediaWriterNotEnabled | rex.Code == RasterExceptionCode.DocumentWritersPdfNotEnabled |
                    rex.Code == RasterExceptionCode.LeadPrinterNotEnabled | rex.Code == RasterExceptionCode.LeadPrinterServerNotEnabled |
                    rex.Code == RasterExceptionCode.LeadPrinterNetworkNotEnabled | rex.Code == RasterExceptionCode.AppStoreNotEnabled |
                    rex.Code == RasterExceptionCode.BasicNotEnabled | rex.Code == RasterExceptionCode.NoServerLicense)
                {
                    message = string.Format("Your runtime license does not include support for this functionality.\n* {0}\nPlease contact [email protected] to discuss options to include this feature set in your runtime license.", rex.Message);
                }
            }
            return(message);
        }
コード例 #3
0
        public void ImageImageException()
        {
            try
            {
                RasterException imageException  = new RasterException(string.Empty);
                RasterException imageException2 = new RasterException(string.Empty, null);
            }
            catch (Exception exception) { Assert.Fail(exception.Message); }

            Assert.Pass();
        }
コード例 #4
0
 public void ShowError(Exception ex, IWin32Window owner, OcrEngineType engineType)
 {
     if (ex is OcrException)
     {
         OcrException oe = ex as OcrException;
         Messager.ShowError(owner, string.Format("LEADTOOLS Error\nCode: {0}\nMessage:{1}", oe.Code, ex.Message));
     }
     else if (ex is RasterException)
     {
         RasterException re = ex as RasterException;
         Messager.ShowError(owner, string.Format("OCR Error\nCode: {0}\nMessage:{1}", re.Code, ex.Message));
     }
     else
     {
         Messager.ShowError(owner, ex);
     }
 }
コード例 #5
0
        private void buttonOcrOptions_Click(object sender, EventArgs e)
        {
            EngineSettingsDialog dlg = new EngineSettingsDialog(_ocrEngine);

            dlg.ShowDialog();
            _ocrEngine.SettingManager.SetBooleanValue("Recognition.ShareOriginalImage", false);//this demo does not support the sharing mode
            SaveOcrSettings(_ocrEngine);

            if (_imageViewer.Image != null)
            {
                var result = MessageBox.Show("Do you want to retry the OCR with the updated settings?", "Retry?", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        // OCR the image and get back an RTF file
                        string document = DoOcr(_imageViewer.Image);
                        if (!string.IsNullOrEmpty(document))
                        {
                            var options = new LoadDocumentOptions()
                            {
                                UseCache = false
                            };
                            // Load the RTF file
                            var doc = DocumentFactory.LoadFromFile(document, options);
                            doc.AutoDisposeDocuments = true;
                            _svgViewer.SetDocument(doc);
                            _svgViewer.Commands.Run(DocumentViewerCommands.ViewFitPage);
                        }
                    }
                    catch (Exception ex)
                    {
                        RasterException rasex = ex as RasterException;
                        Messager.ShowError(this, ex);
                    }
                    finally
                    {
                        EnableUI(true);
                    }
                }
            }
        }
コード例 #6
0
ファイル: ProcessDialog.cs プロジェクト: sakpung/webstudy
 private void ShowError(Exception ex)
 {
     if (ex is OcrException)
     {
         OcrException oe = ex as OcrException;
         Messager.ShowError(this, string.Format("LEADTOOLS Error\nCode: {0}\nMessage:{1}", oe.Code, ex.Message));
         _canceled = true;
     }
     else if (ex is RasterException)
     {
         RasterException re = ex as RasterException;
         Messager.ShowError(this, string.Format("OCR Error\nCode: {0}\nMessage:{1}", re.Code, ex.Message));
         _canceled = true;
     }
     else
     {
         Messager.ShowError(this, ex);
         _canceled = true;
     }
 }
コード例 #7
0
        private void ShowError(Exception ex)
        {
            RasterException re = ex as RasterException;

            if (re != null)
            {
                Messager.ShowError(this, string.Format(BarcodeGlobalization.GetResxString(GetType(), "Resx_LEADError"), re.Code, ex.Message));
            }
            else
            {
                TwainException tw = ex as TwainException;
                if (tw != null)
                {
                    Messager.ShowError(this, string.Format(BarcodeGlobalization.GetResxString(GetType(), "Resx_TwainError"), tw.Code, ex.Message));
                }
                else
                {
                    Messager.ShowError(this, ex);
                }
            }
        }
コード例 #8
0
 private void DoShowError(Exception ex)
 {
     BeginInvoke(new MethodInvoker(delegate()
     {
         // Shows an error, check if the exception is an OCR, raster or general one
         OcrException oe = ex as OcrException;
         if (oe != null)
         {
             Messager.ShowError(this, string.Format("LEADTOOLS Error\n\nCode: {0}\n\n{1}", oe.Code, ex.Message));
         }
         else
         {
             RasterException re = ex as RasterException;
             if (re != null)
             {
                 Messager.ShowError(this, string.Format("OCR Error\n\nCode: {0}\n\n{1}", re.Code, ex.Message));
             }
             else
             {
                 Messager.ShowError(this, ex);
             }
         }
     }));
 }
コード例 #9
0
 public void RasterExceptionConstructors() => Assert.DoesNotThrow(() =>
 {
     RasterException e = new RasterException();
     e = new RasterException(string.Empty);
     e = new RasterException(string.Empty, null);
 });
コード例 #10
0
        private void buttonScreenCapture_Click(object sender, EventArgs e)
        {
            if (_tsUseHotkey.Checked && !showMessagebox)
            {
                MyMessageBox myMessageBox = new MyMessageBox("Hotkey Capture", "Press F11 to start capture");
                myMessageBox.Show(this);
                showMessagebox = myMessageBox.Checked;
            }

            EnableUI(false);
            System.Threading.Thread.Sleep(500);
            try
            {
                // Capture an area from the screen
                RasterImage image = DoCapture(_tsUseHotkey.Checked);

                this.BringToFront();

                ColorResolutionCommand colorRes = new ColorResolutionCommand(ColorResolutionCommandMode.InPlace, 24,
                                                                             RasterByteOrder.Bgr, RasterDitheringMethod.None, ColorResolutionCommandPaletteFlags.Fixed, null);
                colorRes.Run(image);

                EnableUI(true);
                if (image != null)
                {
                    ClearDocument();
                    ClearImage();

                    // Store the new image
                    _imageViewer.Image = image;

                    // Set the image to the PictureBox
                    UpdateViewer();

                    // OCR the image and get back an RTF file
                    string document = DoOcr(_imageViewer.Image);

                    if (!string.IsNullOrEmpty(document))
                    {
                        var options = new LoadDocumentOptions()
                        {
                            UseCache = false
                        };
                        // Load the RTF file
                        var doc = DocumentFactory.LoadFromFile(document, options);
                        doc.AutoDisposeDocuments = true;
                        _svgViewer.SetDocument(doc);
                        _svgViewer.Commands.Run(DocumentViewerCommands.ViewFitPage);
                    }
                }
            }
            catch (Exception ex)
            {
                RasterException rasex = ex as RasterException;
                if (rasex != null)
                {
                    if (rasex.Code != RasterExceptionCode.UserAbort)
                    {
                        Messager.ShowError(this, ex);
                    }
                }
                else
                {
                    Messager.ShowError(this, ex);
                }
            }
            finally
            {
                EnableUI(true);
            }
        }