void SaveSettings() { try { Properties.Settings settings = new Properties.Settings(); settings.OcrEngineType = _ocrEngineType.ToString(); settings.OCRModule = ((MyItemData)_cmbOcrModules.SelectedItem).OriginalName; settings.DocumentFormat = _documentFormatSelector.SelectedFormat.ToString(); settings.ViewFinalDocument = _cbViewFinalDocument.Checked; settings.Save(); settings.Upgrade(); settings.Save(); } catch (Exception) { } }
private void Startup() { Properties.Settings settings = new Properties.Settings(); string engineType = settings.OcrEngineType; // Show the engine selection dialog using (OcrEngineSelectDialog dlg = new OcrEngineSelectDialog(Messager.Caption, engineType, true)) { dlg.RasterCodecsInstance = _codecs; if (dlg.ShowDialog(this) == DialogResult.OK) { _ocrEngine = dlg.OcrEngine; _ocrEngineType = dlg.SelectedOcrEngineType; InitEngines(); } else { // Close the demo Close(); } } }
void InitEngines() { _documentFormatSelector.SetDocumentWriter(_ocrEngine.DocumentWriterInstance, false); StartupEngine(); _documentFormatSelector.SetOcrEngineType(_ocrEngineType); if (_ocrEngineType == OcrEngineType.OmniPageArabic) { _autoOcrImageName = "ArabicSample.Tif"; } else { _autoOcrImageName = "OCR1.Tif"; } // Add the selected engine name to the demo caption Text = Text + " [" + _ocrEngineType.ToString() + " Engine]"; UpdateSupportedOcrModulesList(); UpdateMyControls(); Properties.Settings settings = new Properties.Settings(); // If user provided a command line argument then forget about the saved OCR Module // otherwise use the saved OCR module (if there is any). if (Environment.GetCommandLineArgs().Length > 1) { String[] arguments = Environment.GetCommandLineArgs(); if (arguments[1].Equals("Auto")) { _cmbOcrModules.SelectedIndex = 1; } else if (arguments[1].Equals("Omr")) { _cmbOcrModules.SelectedIndex = 2; } else if (arguments[1].Equals("HnrText")) { _cmbOcrModules.SelectedIndex = 3; } else if (arguments[1].Equals("HnrNum")) { _cmbOcrModules.SelectedIndex = 4; } else { _cmbOcrModules.SelectedIndex = 0; } } else { if (!String.IsNullOrEmpty(settings.OCRModule)) { for (int i = 0; i < _cmbOcrModules.Items.Count; i++) { MyItemData itemData = (MyItemData)_cmbOcrModules.Items[i]; if (itemData.ZoneType == (int)Enum.Parse(typeof(OcrZoneType), settings.OCRModule)) { _cmbOcrModules.SelectedIndex = i; break; } } if (_cmbOcrModules.SelectedIndex < 0) // No match found { _cmbOcrModules.SelectedIndex = 0; } } else { _cmbOcrModules.SelectedIndex = 0; } } if (_ocrEngine != null && _ocrEngine.IsStarted) { DocumentFormat format = DocumentFormat.Pdf; /* Load settings for the selected Document Format */ if (!String.IsNullOrEmpty(settings.DocumentFormat)) { try { format = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), settings.DocumentFormat); } catch { } } _documentFormatSelector.SelectedFormat = format; } /* Load settings for user selected View Final Document check box status */ _cbViewFinalDocument.Checked = settings.ViewFinalDocument; }