private void UpdateUIState() { _okButton.Enabled = _fileNameTextBox.Text.Trim().Length > 0; MyFormat mf = _formatComboBox.SelectedItem as MyFormat; if (mf == null) { return; } if (mf.Format == DocumentFormat.Ltd) { _viewDocumentCheckBox.Checked = false; _viewDocumentCheckBox.Enabled = false; _viewDocumentCheckBox.Enabled = false; } else { if (mf.Format == DocumentFormat.Html) { _htmlBackgroundColorLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorValueLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorButton.Enabled = _htmlUseBackgroundColorCheckBox.Checked; } _viewDocumentCheckBox.Enabled = true; } _altoXmlIndentationLabel.Enabled = _altoXmlFormattedCheckBox.Checked; _altoXmlIndentationTextBox.Enabled = _altoXmlFormattedCheckBox.Checked; }
public static MyFormat FromFileName(string fileName) { if (fileName == null) { throw new ArgumentNullException("fileName"); } // read the header of your file var header = new MyHeader(); using (var reader = new BinaryReader(File.OpenRead(fileName))) { byte b1 = reader.ReadByte(); if (b1 != 0xAA) { // return null or throw an exception } header.FirstByte = b1; // etc ... whenever something's wrong return null or throw an exception } // when you're done reading your header create and return the object var myFormat = new MyFormat(fileName); myFormat.Header = header; // the reest of the object is delivered only when needed, see method below return(myFormat); }
/// <summary> /// 透過時間設定 Text、Slider /// </summary> /// <param name="_slider">UI Slider</param> /// <param name="_text">UI Text</param> /// <param name="completeMsg">完成時顯示文字</param> /// <param name="completeTime">完成時間</param> /// <param name="totalTime">總共時間(秒)</param> /// <returns>如果 "現在時間" 已經超過 "完成時間" 回傳 TimeSpan.Zero</returns> public static TimeSpan SetTimeUI(Slider _slider, Text _text, string completeMsg, DateTime completeTime, float totalTime) { //算剩餘時間 TimeSpan lastTime = TimeGap(completeTime); //時間到 if (lastTime == TimeSpan.Zero) { if (_text != null) { _text.text = completeMsg; } if (_slider != null) { _slider.value = 1; } } else { if (_text != null) { _text.text = MyFormat.TimeSpanToString(lastTime); } if (_slider != null) { _slider.value = 1 - ((float)lastTime.TotalSeconds / (totalTime * 60)); } } return(lastTime); }
private void UpdateOutputFileName() { string inputFileName = _ldFileNameTextBox.Text.Trim(); MyFormat mf = _formatComboBox.SelectedItem as MyFormat; string extension = DocumentWriter.GetFormatFileExtension(mf.Format); string outputFileName = Path.ChangeExtension(inputFileName, extension); _outputFileNameTextBox.Text = outputFileName; }
void ValidCases(MyFormat myFormat) { 42.ToString(CultureInfo.CurrentCulture); string.Format(CultureInfo.CurrentUICulture, "{0}", 42); Activator.CreateInstance(); // Compliant - excluded // Error [CS0411] - cannot infer type var resourceManager = new ResourceManager(typeof(Program)); resourceManager.GetObject("a"); // Compliant - excluded resourceManager.GetString("a"); // Compliant - excluded "".StartsWith("", StringComparison.CurrentCulture); // Compliant - StringComparison implies culture "".StartsWith("", true, CultureInfo.CurrentCulture); // Compliant Console.WriteLine("Colors.Red = {0}", Colors.Red.ToString("d")); Colors myColor = Colors.Yellow; Console.WriteLine("Colors.Red = {0}", myColor.ToString("d")); Methods.DoStuff("foo"); Convert.ToInt32(1.23); Convert.ToInt32('1'); Convert.ToChar(15); Methods.DoStuff3("foo"); // Compliant - the other DoStuff3 does not have the same signature Methods.DoStuff4("foo", "", ""); // Compliant - the other DoStuff4 does not have the same signature Methods.DoStuff5("foo", "bar", "qix", myFormat); Methods.DoStuff6("foo", CultureInfo.CurrentCulture, "bar", "qix"); Methods.DoStuff7(CultureInfo.DefaultThreadCurrentCulture, "foo", "bar", "qix"); Methods.DoStuff8("foo", "bar", "qix"); // Compliant, alternative has too many params Methods.DoStuff9("foo", "bar", "qix"); // Compliant, alternative is not overload Methods.DoStuff10("foo"); // Compliant Methods.DoStuff11("foo"); // Compliant Methods.DoStuff12("foo"); // Compliant Methods.MyFormat(myFormat, "%s", "foo"); // Compliant Methods.MyFormat(myFormat, "%s", "foo", "bar"); // Compliant Methods.MyFormat(myFormat, "%s", "foo", "bar", "qix"); // Compliant Methods.MyFormat2(myFormat, "%s", true, "x"); // Compliant Methods.MyFormat2("%s", "bar"); // Compliant, there's no overload for it Methods.MyFormat2("%s", true, this); // Compliant, no overload Methods.MyFormat2("%s", this, "foo", "bar", "qix"); // Compliant, no overload Methods.DoStuff13(CultureInfo.CurrentCulture, this); Methods.DoStuff14(this); // Compliant, no alternative }
private void UpdateUIState() { MyFormat mf = _formatComboBox.SelectedItem as MyFormat; if (mf == null) { return; } if (mf.Format == DocumentFormat.Html) { _htmlBackgroundColorLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorValueLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorButton.Enabled = _htmlUseBackgroundColorCheckBox.Checked; } _altoXmlIndentationLabel.Enabled = _altoXmlFormattedCheckBox.Checked; _altoXmlIndentationTextBox.Enabled = _altoXmlFormattedCheckBox.Checked; }
private void _outputFileNameBrowseButton_Click(object sender, EventArgs e) { // Show the save file dialog using (SaveFileDialog dlg = new SaveFileDialog()) { // Get the selected format name and extension MyFormat mf = _formatComboBox.SelectedItem as MyFormat; string extension = DocumentWriter.GetFormatFileExtension(mf.Format); dlg.Filter = string.Format("{0} (*.{1})|*.{1}|All Files (*.*)|*.*", mf.FriendlyName, extension); dlg.DefaultExt = extension; if (dlg.ShowDialog(this) == DialogResult.OK) { _outputFileNameTextBox.Text = dlg.FileName; } } }
private void UpdateUIState() { _okButton.Enabled = (_outputFileNameTextBox.Text.Trim().Length > 0) && (_ldFileNameTextBox.Text.Trim().Length > 0); MyFormat mf = _formatComboBox.SelectedItem as MyFormat; if (mf == null) { return; } if (mf.Format == DocumentFormat.Html) { _htmlBackgroundColorLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorValueLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorButton.Enabled = _htmlUseBackgroundColorCheckBox.Checked; } _altoXmlIndentationLabel.Enabled = _altoXmlFormattedCheckBox.Checked; _altoXmlIndentationTextBox.Enabled = _altoXmlFormattedCheckBox.Checked; }
/// <summary>КОНСТРУКТОР для отчета</summary> public UserPole_Image(string pText, int pVarID, int Shablon, int pZoom, MyFormat pFormat) { InitializeComponent(); PROP_VarId = pVarID; PROP_Shablon = Shablon; MET_LoadDataSet(); PART_Label.Visibility = Visibility.Collapsed; PROP_Format = pFormat; if (PROP_Format.MET_If("xH")) { PRI_Height = (int)(MyMet.MET_ParseInt(PROP_Format.PROP_Value["xH"]) * 3.4); } if (PROP_Format.MET_If("xW")) { PRI_Width = (int)(MyMet.MET_ParseInt(PROP_Format.PROP_Value["xW"]) * 3.4); } PRI_Height = PRI_Height == 0 ? 230 * pZoom : PRI_Height; PRI_Width = PRI_Width == 0 ? 320 * pZoom : PRI_Width; PRI_Opacity = 0.6; PROP_Text = pText; }
public SaveDocumentDialog(IOcrDocument ocrDocument, DocumentFormat initialFormat, string initialFileName, bool isCustomFileName, string outputDir, bool viewDocument) { InitializeComponent(); _ocrDocument = ocrDocument; _outputDir = outputDir; // Get the formats // This is the order of importance, show these first then the rest as they come along DocumentFormat[] importantFormats = { DocumentFormat.Ltd, DocumentFormat.Pdf, DocumentFormat.Docx, DocumentFormat.Rtf, DocumentFormat.Text, DocumentFormat.Doc, DocumentFormat.Xls, DocumentFormat.Html }; List <DocumentFormat> formatsToAdd = new List <DocumentFormat>(); Array temp = Enum.GetValues(typeof(DocumentFormat)); List <DocumentFormat> allFormats = new List <DocumentFormat>(); foreach (DocumentFormat format in temp) { allFormats.Add(format); } // Add important once first: foreach (DocumentFormat format in importantFormats) { formatsToAdd.Add(format); allFormats.Remove(format); } // Add rest formatsToAdd.AddRange(allFormats); MyFormat pdfFormat = null; DocumentWriter docWriter = _ocrDocument.Engine.DocumentWriterInstance; IOcrDocumentManager ocrDocumentManager = _ocrDocument.Engine.DocumentManager; string[] engineSupportedFormatNames = ocrDocumentManager.GetSupportedEngineFormats(); foreach (DocumentFormat format in formatsToAdd) { bool addFormat = true; // If this is the "User" or Engines format, only add it if the OCR engine supports them if (format == DocumentFormat.User && engineSupportedFormatNames.Length == 0) { addFormat = false; } if (addFormat) { string friendlyName; if (format == DocumentFormat.User) { friendlyName = "Engine native"; } else { friendlyName = DocumentWriter.GetFormatFriendlyName(format); } MyFormat mf = new MyFormat(format, friendlyName); _formatComboBox.Items.Add(mf); if (mf.Format == initialFormat) { _formatComboBox.SelectedItem = mf; } else if (mf.Format == DocumentFormat.Pdf) { pdfFormat = mf; } } switch (format) { case DocumentFormat.User: // Update the User (Engine) options page { foreach (string engineFormatName in engineSupportedFormatNames) { MyEngineFormat mef = new MyEngineFormat( engineFormatName, ocrDocumentManager.GetEngineFormatFriendlyName(engineFormatName)); _userFormatNameComboBox.Items.Add(mef); if (mef.Format == ocrDocumentManager.EngineFormat) { _userFormatNameComboBox.SelectedItem = mef; } } if (_userFormatNameComboBox.SelectedItem == null && _userFormatNameComboBox.Items.Count > 0) { _userFormatNameComboBox.SelectedIndex = 0; } } break; case DocumentFormat.Pdf: // Update the PDF options page { PdfDocumentOptions pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; // Clone it in case we change it in the Advance PDF options dialog _pdfOptions = pdfOptions.Clone() as PdfDocumentOptions; Array a = Enum.GetValues(typeof(PdfDocumentType)); foreach (PdfDocumentType i in a) { // PDFA does NOT support Arabic characters so we are not adding it in case of Arabic OCR engine. if (i == PdfDocumentType.PdfA && _ocrDocument.Engine.EngineType == OcrEngineType.OmniPageArabic) { continue; } _pdfDocumentTypeComboBox.Items.Add(i); } _pdfDocumentTypeComboBox.SelectedItem = _pdfOptions.DocumentType; _pdfImageOverTextCheckBox.Checked = _pdfOptions.ImageOverText; _pdfLinearizedCheckBox.Checked = _pdfOptions.Linearized; if (string.IsNullOrEmpty(_pdfOptions.Creator)) { _pdfOptions.Creator = "LEADTOOLS PDFWriter"; } if (string.IsNullOrEmpty(_pdfOptions.Producer)) { _pdfOptions.Producer = "LEAD Technologies, Inc."; } } break; case DocumentFormat.Doc: // Update the DOC options page { DocDocumentOptions docOptions = docWriter.GetOptions(DocumentFormat.Doc) as DocDocumentOptions; _cbFramedDoc.Checked = (docOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Docx: // Update the DOCX options page { DocxDocumentOptions docxOptions = docWriter.GetOptions(DocumentFormat.Docx) as DocxDocumentOptions; _cbFramedDocX.Checked = (docxOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Rtf: // Update the RTF options page { RtfDocumentOptions rtfOptions = docWriter.GetOptions(DocumentFormat.Rtf) as RtfDocumentOptions; _cbFramedRtf.Checked = (rtfOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Html: // Update the HTML options page { HtmlDocumentOptions htmlOptions = docWriter.GetOptions(DocumentFormat.Html) as HtmlDocumentOptions; Array a = Enum.GetValues(typeof(DocumentFontEmbedMode)); foreach (DocumentFontEmbedMode i in a) { _htmlEmbedFontModeComboBox.Items.Add(i); } _htmlEmbedFontModeComboBox.SelectedItem = htmlOptions.FontEmbedMode; _htmlUseBackgroundColorCheckBox.Checked = htmlOptions.UseBackgroundColor; _htmlBackgroundColorValueLabel.BackColor = MainForm.ConvertColor(htmlOptions.BackgroundColor); _htmlBackgroundColorLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorValueLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorButton.Enabled = _htmlUseBackgroundColorCheckBox.Checked; } break; case DocumentFormat.Text: // Update the TEXT options page { TextDocumentOptions textOptions = docWriter.GetOptions(DocumentFormat.Text) as TextDocumentOptions; Array a = Enum.GetValues(typeof(TextDocumentType)); foreach (TextDocumentType i in a) { if (i == TextDocumentType.Ansi) { if (textOptions.DocumentType == TextDocumentType.Ansi) { textOptions.DocumentType = TextDocumentType.Unicode; } if (_ocrDocument.Engine.EngineType == OcrEngineType.OmniPageArabic) { continue; } } _textDocumentTypeComboBox.Items.Add(i); } _textDocumentTypeComboBox.SelectedItem = textOptions.DocumentType; _textAddPageNumberCheckBox.Checked = textOptions.AddPageNumber; _textAddPageBreakCheckBox.Checked = textOptions.AddPageBreak; _textFormattedCheckBox.Checked = textOptions.Formatted; } break; case DocumentFormat.AltoXml: // Update the ALTOXML options page { AltoXmlDocumentOptions altoXmlOptions = docWriter.GetOptions(DocumentFormat.AltoXml) as AltoXmlDocumentOptions; _altoXmlFileNameTextBox.Text = altoXmlOptions.FileName; _altoXmlSoftwareCreatorTextBox.Text = altoXmlOptions.SoftwareCreator; _altoXmlSoftwareNameTextBox.Text = altoXmlOptions.SoftwareName; _altoXmlApplicationDescriptionTextBox.Text = altoXmlOptions.ApplicationDescription; _altoXmlFormattedCheckBox.Checked = altoXmlOptions.Formatted; _altoXmlIndentationTextBox.Text = altoXmlOptions.Indentation; _altoXmlSort.Checked = altoXmlOptions.Sort; _altoXmlPlainText.Checked = altoXmlOptions.PlainText; _altoXmlShowGlyphInfo.Checked = altoXmlOptions.ShowGlyphInfo; _altoXmlShowGlyphVariants.Checked = altoXmlOptions.ShowGlyphVariants; Array a = Enum.GetValues(typeof(AltoXmlMeasurementUnit)); foreach (AltoXmlMeasurementUnit i in a) { _altoXmlMeasurementUnit.Items.Add(i); } _altoXmlMeasurementUnit.SelectedItem = altoXmlOptions.MeasurementUnit; } break; case DocumentFormat.Ltd: case DocumentFormat.Emf: case DocumentFormat.Xls: case DocumentFormat.Pub: case DocumentFormat.Mob: case DocumentFormat.Svg: default: // These formats have no options break; } } // Remove all the tab pages _optionsTabControl.TabPages.Clear(); // If no format is selected, default to PDF if (_formatComboBox.SelectedIndex == -1) { if (pdfFormat != null) { _formatComboBox.SelectedItem = pdfFormat; } else { _formatComboBox.SelectedIndex = -1; } } _viewDocumentCheckBox.Checked = viewDocument; _initialFileName = initialFileName; _isCustomFileName = isCustomFileName; if (!string.IsNullOrEmpty(_outputDir)) { MyFormat mf = _formatComboBox.SelectedItem as MyFormat; char[] trimChars = { '\\' }; _fileNameTextBox.Text = _outputDir.TrimEnd(trimChars) + "\\" + Path.GetFileName(initialFileName); if (!_isCustomFileName) { _fileNameTextBox.Text += "." + GetFileExtension(mf.Format); } } else { _fileNameTextBox.Text = initialFileName; } _formatComboBox_SelectedIndexChanged(this, EventArgs.Empty); UpdateUIState(); }
private void _formatComboBox_SelectedIndexChanged(object sender, EventArgs e) { MyFormat mf = _formatComboBox.SelectedItem as MyFormat; // Show only the options page corresponding to this format if (_optionsTabControl.TabPages.Count > 0) { _optionsTabControl.TabPages.Clear(); } switch (mf.Format) { case DocumentFormat.Emf: _optionsTabControl.TabPages.Add(_emfOptionsTabPage); break; case DocumentFormat.Pdf: _optionsTabControl.TabPages.Add(_pdfOptionsTabPage); break; case DocumentFormat.Doc: _optionsTabControl.TabPages.Add(_docOptionsTabPage); break; case DocumentFormat.Docx: _optionsTabControl.TabPages.Add(_docxOptionsTabPage); break; case DocumentFormat.Rtf: _optionsTabControl.TabPages.Add(_rtfOptionsTabPage); break; case DocumentFormat.Html: _optionsTabControl.TabPages.Add(_htmlOptionsTabPage); break; case DocumentFormat.Text: _optionsTabControl.TabPages.Add(_textOptionsTabPage); break; case DocumentFormat.Xps: _optionsTabControl.TabPages.Add(_xpsOptionsTabPage); break; case DocumentFormat.Xls: _optionsTabControl.TabPages.Add(_xlsOptionsTabPage); break; case DocumentFormat.Pub: _optionsTabControl.TabPages.Add(_ePubOptionsTabPage); break; case DocumentFormat.Mob: _optionsTabControl.TabPages.Add(_mobOptionsTabPage); break; case DocumentFormat.Svg: _optionsTabControl.TabPages.Add(_svgOptionsTabPage); break; case DocumentFormat.AltoXml: _optionsTabControl.TabPages.Add(_altoXmlOptionsTabPage); break; case DocumentFormat.Ltd: _optionsTabControl.TabPages.Add(_ltdOptionsTabPage); break; } _optionsTabControl.Visible = _optionsTabControl.TabPages.Count > 0; UpdateUIState(); if (SelectedFormatChanged != null) { SelectedFormatChanged(this, EventArgs.Empty); } }
private void _okButton_Click(object sender, EventArgs e) { DocumentWriter docWriter = _ocrDocument.Engine.DocumentWriterInstance; IOcrDocumentManager ocrDocumentManager = _ocrDocument.Engine.DocumentManager; // Save the options MyFormat mf = _formatComboBox.SelectedItem as MyFormat; DocumentOptions documentOptions; if (mf.Format != DocumentFormat.User) { documentOptions = docWriter.GetOptions(mf.Format); } else { documentOptions = null; } switch (mf.Format) { case DocumentFormat.User: // Update the User (Engine) options { MyEngineFormat mef = _userFormatNameComboBox.SelectedItem as MyEngineFormat; ocrDocumentManager.EngineFormat = mef.Format; } break; case DocumentFormat.Pdf: // Update the PDF options { PdfDocumentOptions pdfOptions = documentOptions as PdfDocumentOptions; pdfOptions.DocumentType = (PdfDocumentType)_pdfDocumentTypeComboBox.SelectedItem; pdfOptions.ImageOverText = _pdfImageOverTextCheckBox.Checked; pdfOptions.Linearized = _pdfLinearizedCheckBox.Checked; pdfOptions.PageRestriction = DocumentPageRestriction.Relaxed; // Description options pdfOptions.Title = _pdfOptions.Title; pdfOptions.Subject = _pdfOptions.Subject; pdfOptions.Keywords = _pdfOptions.Keywords; pdfOptions.Author = _pdfOptions.Author; pdfOptions.Creator = _pdfOptions.Creator; pdfOptions.Producer = _pdfOptions.Producer; // Fonts options pdfOptions.FontEmbedMode = _pdfOptions.FontEmbedMode; // Security options pdfOptions.Protected = _pdfOptions.Protected; if (pdfOptions.Protected) { pdfOptions.UserPassword = _pdfOptions.UserPassword; pdfOptions.OwnerPassword = _pdfOptions.OwnerPassword; pdfOptions.EncryptionMode = _pdfOptions.EncryptionMode; pdfOptions.PrintEnabled = _pdfOptions.PrintEnabled; pdfOptions.HighQualityPrintEnabled = _pdfOptions.HighQualityPrintEnabled; pdfOptions.CopyEnabled = _pdfOptions.CopyEnabled; pdfOptions.EditEnabled = _pdfOptions.EditEnabled; pdfOptions.AnnotationsEnabled = _pdfOptions.AnnotationsEnabled; pdfOptions.AssemblyEnabled = _pdfOptions.AssemblyEnabled; } // Compression options pdfOptions.OneBitImageCompression = _pdfOptions.OneBitImageCompression; pdfOptions.ColoredImageCompression = _pdfOptions.ColoredImageCompression; pdfOptions.QualityFactor = _pdfOptions.QualityFactor; pdfOptions.ImageOverTextSize = _pdfOptions.ImageOverTextSize; pdfOptions.ImageOverTextMode = _pdfOptions.ImageOverTextMode; // Initial View Options pdfOptions.PageModeType = _pdfOptions.PageModeType; pdfOptions.PageLayoutType = _pdfOptions.PageLayoutType; pdfOptions.PageFitType = _pdfOptions.PageFitType; pdfOptions.ZoomPercent = _pdfOptions.ZoomPercent; pdfOptions.InitialPageNumber = _pdfOptions.InitialPageNumber; pdfOptions.FitWindow = _pdfOptions.FitWindow; pdfOptions.CenterWindow = _pdfOptions.CenterWindow; pdfOptions.DisplayDocTitle = _pdfOptions.DisplayDocTitle; pdfOptions.HideMenubar = _pdfOptions.HideMenubar; pdfOptions.HideToolbar = _pdfOptions.HideToolbar; pdfOptions.HideWindowUI = _pdfOptions.HideWindowUI; } break; case DocumentFormat.Doc: // Update the DOC options { DocDocumentOptions docOptions = documentOptions as DocDocumentOptions; docOptions.TextMode = (_cbFramedDoc.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed; } break; case DocumentFormat.Docx: // Update the DOC options { DocxDocumentOptions docxOptions = documentOptions as DocxDocumentOptions; docxOptions.TextMode = (_cbFramedDocX.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed; } break; case DocumentFormat.Rtf: // Update the RTF options { RtfDocumentOptions rtfOptions = documentOptions as RtfDocumentOptions; rtfOptions.TextMode = (_cbFramedRtf.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed; } break; case DocumentFormat.Html: // Update the HTML options { HtmlDocumentOptions htmlOptions = documentOptions as HtmlDocumentOptions; htmlOptions.FontEmbedMode = (DocumentFontEmbedMode)_htmlEmbedFontModeComboBox.SelectedItem; htmlOptions.UseBackgroundColor = _htmlUseBackgroundColorCheckBox.Checked; htmlOptions.BackgroundColor = MainForm.ConvertColor(_htmlBackgroundColorValueLabel.BackColor); } break; case DocumentFormat.Text: // Update the TEXT options { TextDocumentOptions textOptions = documentOptions as TextDocumentOptions; textOptions.DocumentType = (TextDocumentType)_textDocumentTypeComboBox.SelectedItem; textOptions.AddPageNumber = _textAddPageNumberCheckBox.Checked; textOptions.AddPageBreak = _textAddPageBreakCheckBox.Checked; textOptions.Formatted = _textFormattedCheckBox.Checked; } break; case DocumentFormat.AltoXml: // Update the ALTOXML options { AltoXmlDocumentOptions altoXmlOptions = documentOptions as AltoXmlDocumentOptions; altoXmlOptions.FileName = _altoXmlFileNameTextBox.Text; altoXmlOptions.SoftwareCreator = _altoXmlSoftwareCreatorTextBox.Text; altoXmlOptions.SoftwareName = _altoXmlSoftwareNameTextBox.Text; altoXmlOptions.ApplicationDescription = _altoXmlApplicationDescriptionTextBox.Text; altoXmlOptions.Formatted = _altoXmlFormattedCheckBox.Checked; altoXmlOptions.Indentation = (altoXmlOptions.Formatted) ? _altoXmlIndentationTextBox.Text : ""; altoXmlOptions.Sort = _altoXmlSort.Checked; altoXmlOptions.PlainText = _altoXmlPlainText.Checked; altoXmlOptions.ShowGlyphInfo = _altoXmlShowGlyphInfo.Checked; altoXmlOptions.ShowGlyphVariants = _altoXmlShowGlyphVariants.Checked; altoXmlOptions.MeasurementUnit = (AltoXmlMeasurementUnit)_altoXmlMeasurementUnit.SelectedItem; } break; case DocumentFormat.Ltd: case DocumentFormat.Emf: case DocumentFormat.Xls: case DocumentFormat.Pub: case DocumentFormat.Mob: case DocumentFormat.Svg: default: // These formats have no options break; } if (documentOptions != null) { docWriter.SetOptions(mf.Format, documentOptions); } // Get the save paramters _selectedFileName = _fileNameTextBox.Text; _selectedFormat = mf.Format; _selectedViewDocument = _viewDocumentCheckBox.Checked; if (_isCustomFileName) { _outputDir = Path.GetDirectoryName(SelectedFileName); } }
private void _formatComboBox_SelectedIndexChanged(object sender, EventArgs e) { MyFormat mf = _formatComboBox.SelectedItem as MyFormat; // Update the extension of the file name // Update the current format options tab page string fileName = _fileNameTextBox.Text; string extension = GetFileExtension(mf.Format); if (!string.IsNullOrEmpty(fileName)) { if (fileName.Equals(_initialFileName) && !_isCustomFileName) { _fileNameTextBox.Text += "." + extension; } else { _fileNameTextBox.Text = Path.ChangeExtension(fileName, extension); } } // Show only the options page corresponding to this format if (_optionsTabControl.TabPages.Count > 0) { _optionsTabControl.TabPages.Clear(); } switch (mf.Format) { case DocumentFormat.Ltd: _optionsTabControl.TabPages.Add(_ldOptionsTabPage); break; case DocumentFormat.Emf: _optionsTabControl.TabPages.Add(_emfOptionsTabPage); break; case DocumentFormat.Pdf: _optionsTabControl.TabPages.Add(_pdfOptionsTabPage); break; case DocumentFormat.Doc: _optionsTabControl.TabPages.Add(_docOptionsTabPage); break; case DocumentFormat.Docx: _optionsTabControl.TabPages.Add(_docxOptionsTabPage); break; case DocumentFormat.Rtf: _optionsTabControl.TabPages.Add(_rtfOptionsTabPage); break; case DocumentFormat.Html: _optionsTabControl.TabPages.Add(_htmlOptionsTabPage); break; case DocumentFormat.Text: _optionsTabControl.TabPages.Add(_textOptionsTabPage); break; case DocumentFormat.Xps: _optionsTabControl.TabPages.Add(_xpsOptionsTabPage); break; case DocumentFormat.Xls: _optionsTabControl.TabPages.Add(_xlsOptionsTabPage); break; case DocumentFormat.User: _optionsTabControl.TabPages.Add(_userOptionsTabPage); break; case DocumentFormat.AltoXml: _optionsTabControl.TabPages.Add(_altoXmlOptionsTabPage); break; case DocumentFormat.Pub: _optionsTabControl.TabPages.Add(_ePubOptionsTabPage); break; case DocumentFormat.Mob: _optionsTabControl.TabPages.Add(_mobOptionsTabPage); break; case DocumentFormat.Svg: _optionsTabControl.TabPages.Add(_svgOptionsTabPage); break; } _optionsTabControl.Visible = _optionsTabControl.TabPages.Count > 0; UpdateUIState(); }
public void SetDocumentWriter(DocumentWriter docWriter) { // Get the last format, options and document file name selected by the user _docWriter = docWriter; Properties.Settings settings = new Properties.Settings(); DocumentFormat initialFormat = DocumentFormat.Pdf; if (!string.IsNullOrEmpty(settings.Format)) { try { initialFormat = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), settings.Format); } catch { } } if (!string.IsNullOrEmpty(settings.FormatOptionsXml)) { // Set the document writer options from the last one we saved try { byte[] buffer = Encoding.Unicode.GetBytes(settings.FormatOptionsXml); using (MemoryStream ms = new MemoryStream(buffer)) _docWriter.LoadOptions(ms); } catch { } } // Get the formats // This is the order of importance, show these first then the rest as they come along DocumentFormat[] importantFormats = { DocumentFormat.Pdf, DocumentFormat.Docx, DocumentFormat.Rtf, DocumentFormat.Text, DocumentFormat.Doc, DocumentFormat.Xls, DocumentFormat.Html }; List <DocumentFormat> formatsToAdd = new List <DocumentFormat>(); Array temp = Enum.GetValues(typeof(DocumentFormat)); List <DocumentFormat> allFormats = new List <DocumentFormat>(); foreach (DocumentFormat format in temp) { allFormats.Add(format); } // Add important once first: foreach (DocumentFormat format in importantFormats) { formatsToAdd.Add(format); allFormats.Remove(format); } // Add rest formatsToAdd.AddRange(allFormats); MyFormat pdfFormat = null; foreach (DocumentFormat format in formatsToAdd) { if (format != DocumentFormat.User) { string friendlyName = DocumentWriter.GetFormatFriendlyName(format); string extension = DocumentWriter.GetFormatFileExtension(format).ToUpper(); MyFormat mf = new MyFormat(format, friendlyName, extension); _formatComboBox.Items.Add(mf); if (mf.Format == initialFormat) { _formatComboBox.SelectedItem = mf; } else if (mf.Format == DocumentFormat.Pdf) { pdfFormat = mf; } switch (format) { case DocumentFormat.Pdf: // Update the PDF options page { PdfDocumentOptions pdfOptions = _docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; // Clone it in case we change it in the Advance PDF options dialog _pdfOptions = pdfOptions.Clone() as PdfDocumentOptions; Array a = Enum.GetValues(typeof(PdfDocumentType)); foreach (PdfDocumentType i in a) { _pdfDocumentTypeComboBox.Items.Add(i); } _pdfDocumentTypeComboBox.SelectedItem = _pdfOptions.DocumentType; _pdfImageOverTextCheckBox.Checked = _pdfOptions.ImageOverText; _pdfLinearizedCheckBox.Checked = _pdfOptions.Linearized; if (string.IsNullOrEmpty(_pdfOptions.Creator)) { _pdfOptions.Creator = "LEADTOOLS PDFWriter"; } if (string.IsNullOrEmpty(_pdfOptions.Producer)) { _pdfOptions.Producer = "LEAD Technologies, Inc."; } } break; case DocumentFormat.Doc: // Update the DOC options page { DocDocumentOptions docOptions = _docWriter.GetOptions(DocumentFormat.Doc) as DocDocumentOptions; _cbFramedDoc.Checked = (docOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Docx: // Update the DOCX options page { DocxDocumentOptions docxOptions = _docWriter.GetOptions(DocumentFormat.Docx) as DocxDocumentOptions; _cbFramedDocX.Checked = (docxOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Rtf: // Update the RTF options page { RtfDocumentOptions rtfOptions = _docWriter.GetOptions(DocumentFormat.Rtf) as RtfDocumentOptions; _cbFramedRtf.Checked = (rtfOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Html: // Update the HTML options page { HtmlDocumentOptions htmlOptions = _docWriter.GetOptions(DocumentFormat.Html) as HtmlDocumentOptions; Array a = Enum.GetValues(typeof(DocumentFontEmbedMode)); foreach (DocumentFontEmbedMode i in a) { _htmlEmbedFontModeComboBox.Items.Add(i); } _htmlEmbedFontModeComboBox.SelectedItem = htmlOptions.FontEmbedMode; _htmlUseBackgroundColorCheckBox.Checked = htmlOptions.UseBackgroundColor; _htmlBackgroundColorValueLabel.BackColor = ConvertColor(htmlOptions.BackgroundColor); _htmlBackgroundColorLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorValueLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorButton.Enabled = _htmlUseBackgroundColorCheckBox.Checked; } break; case DocumentFormat.Text: // Update the TEXT options page { TextDocumentOptions textOptions = _docWriter.GetOptions(DocumentFormat.Text) as TextDocumentOptions; Array a = Enum.GetValues(typeof(TextDocumentType)); foreach (TextDocumentType i in a) { _textDocumentTypeComboBox.Items.Add(i); } _textDocumentTypeComboBox.SelectedItem = textOptions.DocumentType; _textAddPageNumberCheckBox.Checked = textOptions.AddPageNumber; _textAddPageBreakCheckBox.Checked = textOptions.AddPageBreak; _textFormattedCheckBox.Checked = textOptions.Formatted; } break; case DocumentFormat.AltoXml: // Update the ALTOXML options page { AltoXmlDocumentOptions altoXmlOptions = _docWriter.GetOptions(DocumentFormat.AltoXml) as AltoXmlDocumentOptions; _altoXmlFileNameTextBox.Text = altoXmlOptions.FileName; _altoXmlSoftwareCreatorTextBox.Text = altoXmlOptions.SoftwareCreator; _altoXmlSoftwareNameTextBox.Text = altoXmlOptions.SoftwareName; _altoXmlApplicationDescriptionTextBox.Text = altoXmlOptions.ApplicationDescription; _altoXmlFormattedCheckBox.Checked = altoXmlOptions.Formatted; _altoXmlIndentationTextBox.Text = altoXmlOptions.Indentation; _altoXmlSort.Checked = altoXmlOptions.Sort; _altoXmlPlainText.Checked = altoXmlOptions.PlainText; _altoXmlShowGlyphInfo.Checked = altoXmlOptions.ShowGlyphInfo; _altoXmlShowGlyphVariants.Checked = altoXmlOptions.ShowGlyphVariants; Array a = Enum.GetValues(typeof(AltoXmlMeasurementUnit)); foreach (AltoXmlMeasurementUnit i in a) { _altoXmlMeasurementUnit.Items.Add(i); } _altoXmlMeasurementUnit.SelectedItem = altoXmlOptions.MeasurementUnit; } break; case DocumentFormat.Emf: case DocumentFormat.Xls: case DocumentFormat.Pub: case DocumentFormat.Mob: case DocumentFormat.Svg: default: // These formats have no options break; } } } // Remove all the tab pages _optionsTabControl.TabPages.Clear(); // If no format is selected, default to PDF if (_formatComboBox.SelectedIndex == -1) { if (pdfFormat != null) { _formatComboBox.SelectedItem = pdfFormat; } else { _formatComboBox.SelectedIndex = -1; } } _formatComboBox_SelectedIndexChanged(this, EventArgs.Empty); UpdateUIState(); }
/// <summary>МЕТОД Заполняем Поля</summary> protected override void MET_LoadPole() { // Пробегаемся по вопросам шаблона foreach (UserShablon _Shablon in PROP_Docum.PROP_Shablon) { try { MyFormat _Format = new MyFormat(_Shablon.PROP_xFormat); // формат // Если поле нужно проппустить, то следующее поле if (_Format.MET_If("hide") || _Format.MET_If("old")) { continue; } VirtualPole _Pole = MET_CreateUserPole(_Shablon.PROP_Type); // создаем поле, соответствующего типа _Pole.PROP_FormShablon = this; // ссылка на форму _Pole.PROP_Shablon = _Shablon.PROP_ID; // номер шаблона, как минимум нужен для Картинок _Pole.PROP_Description = _Shablon.PROP_Name; // вопрос _Pole.PROP_VarId = _Shablon.PROP_VarId; // номер индификатора VarId _Pole.PROP_Format = _Format; // формат поля _Pole.PROP_Necessarily = _Format.MET_If("nec"); // обязательное поле _Pole.IsEnabled = !_Format.MET_If("disab"); // запрет на редактирование _Pole.PROP_DefaultText = MET_ReplaceProp(_Shablon.PROP_ValueStart, PRO_NomerShablon, _Pole.PROP_VarId); // Значение ответа по умолчанию // Ответ if (PROP_StadNodes == eStadNodes.New || (PROP_StadNodes == eStadNodes.NewPerw && _Format.MET_If("nprev"))) { // Значения по умолчанию _Pole.PROP_Text = _Pole.PROP_DefaultText; } else { // Значения из протокола (либо eStadNodes.Old, либо eStadNodes.NewPerw) _Pole.PROP_Text = MyMet.MET_GetPole(_Pole.PROP_VarId, PRO_StrProtokol); } // Если новый протокол, то текст серый (значение по умолчанию) if (PROP_NewProtokol) { _Pole.PROP_ForegroundText = Brushes.Gray; } _Pole.Name = "elePoleShabl_" + _Pole.PROP_VarId; // имя поля // Lua if (!string.IsNullOrEmpty(_Shablon.PROP_xLua)) { _Pole.PROP_Lua = new UserLua_Standart(_Pole) { PROP_ChankText = _Shablon.PROP_xLua }; _Pole.PROP_Lua.MET_StartLua(); } PUB_HashPole.Add(_Pole.Name, _Pole); // записываем элемент в очередь // Указатель на принадлежность к разделу string _Maska = _Shablon.PROP_Maska; // Добавляем элемент в ... if (_Maska == "") { PRI_StackPanel.Children.Add(_Pole); // добавляем элемент на форму } else { ((VirtualPole)PUB_HashPole["elePoleShabl_" + _Maska]).MET_AddElement(_Pole); } // добавляем элемент в родительское поле _Pole.MET_Inicial(); // инициализация поля (если есть) } catch { // ignored } } Children.Add(PRI_StackPanel); // Ещё раз пробегаем по полям и запускаем Lua код foreach (DictionaryEntry _DiEnt in PUB_HashPole) { var _PoleLua = (VirtualPole)_DiEnt.Value; _PoleLua?.PROP_Lua?.MET_OnCreat(); } }
///<summary>КОНСТРУКТОР</summary> public VirtualPole() { ToolTipService.SetShowDuration(this, 30000); // Устанавливаем Время действия подсказки ToolTip 30 секунд PROP_Format = new MyFormat(); }
public ConvertLdDialog(IOcrDocument ocrDocument, DocumentWriter docWriter, DocumentFormat initialFormat, string initialLdFileName, bool viewDocument) { InitializeComponent(); _ocrDocument = ocrDocument; _docWriter = docWriter; // Get the formats // This is the order of importance, show these first then the rest as they come along DocumentFormat[] importantFormats = { DocumentFormat.Pdf, DocumentFormat.Docx, DocumentFormat.Rtf, DocumentFormat.Text, DocumentFormat.Doc, DocumentFormat.Xls, DocumentFormat.Html }; List <DocumentFormat> formatsToAdd = new List <DocumentFormat>(); Array temp = Enum.GetValues(typeof(DocumentFormat)); List <DocumentFormat> allFormats = new List <DocumentFormat>(); foreach (DocumentFormat format in temp) { allFormats.Add(format); } // Add important once first: foreach (DocumentFormat format in importantFormats) { formatsToAdd.Add(format); allFormats.Remove(format); } // Add rest formatsToAdd.AddRange(allFormats); MyFormat pdfFormat = null; foreach (DocumentFormat format in formatsToAdd) { bool addFormat = true; // If this is the "User" or Engines format, only add it if the OCR engine supports them if (format == DocumentFormat.User || format == DocumentFormat.Ltd) { addFormat = false; } if (addFormat) { string friendlyName = DocumentWriter.GetFormatFriendlyName(format); string extension = DocumentWriter.GetFormatFileExtension(format).ToUpper(); MyFormat mf = new MyFormat(format, friendlyName, extension); _formatComboBox.Items.Add(mf); if (mf.Format == initialFormat) { _formatComboBox.SelectedItem = mf; } else if (mf.Format == DocumentFormat.Pdf) { pdfFormat = mf; } switch (format) { case DocumentFormat.Pdf: // Update the PDF options page { PdfDocumentOptions pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; // Clone it in case we change it in the Advance PDF options dialog _pdfOptions = pdfOptions.Clone() as PdfDocumentOptions; Array a = Enum.GetValues(typeof(PdfDocumentType)); foreach (PdfDocumentType i in a) { _pdfDocumentTypeComboBox.Items.Add(i); } _pdfDocumentTypeComboBox.SelectedItem = _pdfOptions.DocumentType; _pdfImageOverTextCheckBox.Checked = _pdfOptions.ImageOverText; _pdfLinearizedCheckBox.Checked = _pdfOptions.Linearized; if (string.IsNullOrEmpty(_pdfOptions.Creator)) { _pdfOptions.Creator = "LEADTOOLS PDFWriter"; } if (string.IsNullOrEmpty(_pdfOptions.Producer)) { _pdfOptions.Producer = "LEAD Technologies, Inc."; } } break; case DocumentFormat.Doc: // Update the DOC options page { DocDocumentOptions docOptions = docWriter.GetOptions(DocumentFormat.Doc) as DocDocumentOptions; _cbFramedDoc.Checked = (docOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Docx: // Update the DOCX options page { DocxDocumentOptions docxOptions = docWriter.GetOptions(DocumentFormat.Docx) as DocxDocumentOptions; _cbFramedDocX.Checked = (docxOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Rtf: // Update the RTF options page { RtfDocumentOptions rtfOptions = docWriter.GetOptions(DocumentFormat.Rtf) as RtfDocumentOptions; _cbFramedRtf.Checked = (rtfOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Html: // Update the HTML options page { HtmlDocumentOptions htmlOptions = docWriter.GetOptions(DocumentFormat.Html) as HtmlDocumentOptions; Array a = Enum.GetValues(typeof(DocumentFontEmbedMode)); foreach (DocumentFontEmbedMode i in a) { _htmlEmbedFontModeComboBox.Items.Add(i); } _htmlEmbedFontModeComboBox.SelectedItem = htmlOptions.FontEmbedMode; _htmlUseBackgroundColorCheckBox.Checked = htmlOptions.UseBackgroundColor; _htmlBackgroundColorValueLabel.BackColor = MainForm.ConvertColor(htmlOptions.BackgroundColor); _htmlBackgroundColorLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorValueLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorButton.Enabled = _htmlUseBackgroundColorCheckBox.Checked; } break; case DocumentFormat.Text: // Update the TEXT options page { TextDocumentOptions textOptions = docWriter.GetOptions(DocumentFormat.Text) as TextDocumentOptions; Array a = Enum.GetValues(typeof(TextDocumentType)); foreach (TextDocumentType i in a) { _textDocumentTypeComboBox.Items.Add(i); } _textDocumentTypeComboBox.SelectedItem = textOptions.DocumentType; _textAddPageNumberCheckBox.Checked = textOptions.AddPageNumber; _textAddPageBreakCheckBox.Checked = textOptions.AddPageBreak; _textFormattedCheckBox.Checked = textOptions.Formatted; } break; case DocumentFormat.AltoXml: // Update the ALTOXML options page { AltoXmlDocumentOptions altoXmlOptions = docWriter.GetOptions(DocumentFormat.AltoXml) as AltoXmlDocumentOptions; _altoXmlFileNameTextBox.Text = altoXmlOptions.FileName; _altoXmlSoftwareCreatorTextBox.Text = altoXmlOptions.SoftwareCreator; _altoXmlSoftwareNameTextBox.Text = altoXmlOptions.SoftwareName; _altoXmlApplicationDescriptionTextBox.Text = altoXmlOptions.ApplicationDescription; _altoXmlFormattedCheckBox.Checked = altoXmlOptions.Formatted; _altoXmlIndentationTextBox.Text = altoXmlOptions.Indentation; _altoXmlSort.Checked = altoXmlOptions.Sort; _altoXmlPlainText.Checked = altoXmlOptions.PlainText; _altoXmlShowGlyphInfo.Checked = altoXmlOptions.ShowGlyphInfo; _altoXmlShowGlyphVariants.Checked = altoXmlOptions.ShowGlyphVariants; Array a = Enum.GetValues(typeof(AltoXmlMeasurementUnit)); foreach (AltoXmlMeasurementUnit i in a) { _altoXmlMeasurementUnit.Items.Add(i); } _altoXmlMeasurementUnit.SelectedItem = altoXmlOptions.MeasurementUnit; } break; case DocumentFormat.Emf: case DocumentFormat.Xls: case DocumentFormat.Pub: case DocumentFormat.Mob: case DocumentFormat.Svg: default: // These formats have no options break; } } } // Remove all the tab pages _optionsTabControl.TabPages.Clear(); // If no format is selected, default to PDF if (_formatComboBox.SelectedIndex == -1) { if (pdfFormat != null) { _formatComboBox.SelectedItem = pdfFormat; } else { _formatComboBox.SelectedIndex = -1; } } _viewDocumentCheckBox.Checked = viewDocument; _formatComboBox_SelectedIndexChanged(this, EventArgs.Empty); if (!string.IsNullOrEmpty(initialLdFileName)) { _ldFileNameTextBox.Text = initialLdFileName; UpdateOutputFileName(); } UpdateUIState(); }
internal MyStore(CommonAbstractStoreBehaviourTest outerInstance, Config config, PageCache pageCache, MyFormat format) : base(new File("store"), new File("idFile"), config, IdType.NODE, new DefaultIdGeneratorFactory(outerInstance.fs.Get()), pageCache, NullLogProvider.Instance, "T", format, format, "XYZ") { this._outerInstance = outerInstance; }
///<summary>КОНСТРУКТОР</summary> public VirtualPoleOtchet() { PROP_Format = new MyFormat(); }