/// <summary> /// Selects the Office document. /// </summary> public static Stream SelectOfficeDocument() { #if !REMOVE_OFFICE_PLUGIN // if image is selected if (_openDocumentDialog.ShowDialog() == DialogResult.OK) { string documentFilename = _openDocumentDialog.FileName; if (File.Exists(documentFilename)) { // if selected file is TXT file if (Path.GetExtension(documentFilename).ToLowerInvariant() == ".txt") { // convert TXT file to a DOCX document return(ConvertTxtFileToDocxDocument(documentFilename)); } // open document return(File.OpenRead(documentFilename)); } // use empty document return(DemosResourcesManager.GetResourceAsStream("EmptyDocument.docx")); } #endif return(null); }
/// <summary> /// Returns the visual tool icon of specified name. /// </summary> /// <param name="iconName">The visual tool icon name.</param> /// <returns> /// The visual tool icon. /// </returns> private static Image GetIcon(string iconName) { string iconPath = string.Format("DemosCommonCode.Imaging.VisualToolsToolStrip.VisualTools.ImageProcessingVisualTools.Resources.{0}", iconName); return(DemosResourcesManager.GetResourceAsBitmap(iconPath)); }
/// <summary> /// Converts the text file to a DOCX document. /// </summary> /// <param name="txtFilename">The text filename.</param> /// <returns>Stream that contains converted DOCX document.</returns> public static Stream ConvertTxtFileToDocxDocument(string txtFilename) { #if !REMOVE_OFFICE_PLUGIN // get "EmptyDocument.docx" resource using (Stream documentStream = DemosResourcesManager.GetResourceAsStream("EmptyDocument.docx")) { if (documentStream == null) { throw new Exception("TXT to DOCX conversion error: Resource 'EmptyDocument.docx' is not found in demo application."); } MemoryStream tempStream = new MemoryStream(); // create DOCX editor for "EmptyDocument.docx" using (DocxDocumentEditor editor = new DocxDocumentEditor(documentStream)) { // set document text to a TXT file editor.Body.Text = File.ReadAllText(txtFilename); // save document editor.Save(tempStream); } return(tempStream); } #endif return(null); }
/// <summary> /// Adds the annotation with comment. /// </summary> public void AddNewComment() { // get comment annotation image VintasoftImage image = DemosResourcesManager.GetResourceAsImage( "DemosCommonCode.Annotation.Comments.AnnotationCommentBuilder.CommentIcon.png"); // create comment annotation data EmbeddedImageAnnotationData annotationData = new EmbeddedImageAnnotationData(image); Resolution resolution = _annotationVisualTool.ImageViewer.Image.Resolution; annotationData.Size = new SizeF( (float)UnitOfMeasureConverter.ConvertToDeviceIndependentPixels(image.Width, UnitOfMeasure.Pixels, resolution.Horizontal), (float)UnitOfMeasureConverter.ConvertToDeviceIndependentPixels(image.Height, UnitOfMeasure.Pixels, resolution.Vertical)); annotationData.Border = false; // create comment annotationData.Comment = new AnnotationComment(Color.Yellow, Environment.UserName); annotationData.Comment.Type = "Comment"; // build annotation _annotationVisualTool.AnnotationBuildingFinished += AnnotationVisualTool_AnnotationBuildingFinished; RectangleAnnotationView view = (RectangleAnnotationView)_annotationVisualTool.AddAndBuildAnnotation(annotationData); view.Builder = new RectangularObjectMoveBuilder(view, annotationData.Size); }
/// <summary> /// Initializes a new instance of the <see cref="BarcodeWriterTool"/> class. /// </summary> public BarcodeWriterTool() { #if !REMOVE_BARCODE_SDK _writer = new BarcodeWriter(); _writer.Settings.Changed += new EventHandler(Settings_Changed); _writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgra32; #endif base.Cursor = System.Windows.Forms.Cursors.Cross; base.ActionCursor = base.Cursor; RectangularObjectTransformer transformer = new RectangularObjectTransformer(this); transformer.HideInteractionPointsWhenMoving = true; TransformController = transformer; // create the "Refresh barcode" button _refreshBarcodeButton = new InteractionButton(this); _refreshBarcodeButton.Image = DemosResourcesManager.GetResourceAsImage( @"DemosCommonCode.Imaging.VisualTools.BarcodeWriterTool.Resources.RefreshBarcodeImage.png"); // create the "Draw barcode" button _drawBarcodeButton = new InteractionButton(this); _drawBarcodeButton.Image = DemosResourcesManager.GetResourceAsImage( @"DemosCommonCode.Imaging.VisualTools.BarcodeWriterTool.Resources.DrawBarcodeImage.png"); // create the panel with buttons _controlButtonsPanel = new InteractionButtonsPanel(this, _refreshBarcodeButton, _drawBarcodeButton); _controlButtonsPanel.Interaction += new EventHandler <InteractionEventArgs>(ControlButtonsPanel_Interaction); }
/// <summary> /// Initializes a new instance of the <see cref="NHunspellSpellCheckEngine"/> class. /// </summary> /// <param name="language">The language.</param> /// <exception cref="System.ArgumentNullException">Thrown if /// <i>language</i> is <b>null</b> or <b>empty</b>.</exception> public NHunspellSpellCheckEngine(string language) { // if language is not correct if (string.IsNullOrEmpty(language)) { throw new ArgumentNullException(); } // save languages _languages = new string[] { language }; string affixFileDataPath = language + ".aff"; // load affix data byte[] affixFileData = DemosResourcesManager.GetExternalResourceAsBytes(affixFileDataPath); string dictionaryFileDataPath = language + ".dic"; // load dictionary data byte[] dictionaryFileData = DemosResourcesManager.GetExternalResourceAsBytes(dictionaryFileDataPath); // create engine _hunspell = new NHunspell.Hunspell(affixFileData, dictionaryFileData); // load available symbols of language InitializeAvailableSymbols(language); // load custom words dictionary LoadCustomWordsDictionary(); }
/// <summary> /// Handles the Click event of ImportButton object. /// </summary> private void importButton_Click(object sender, EventArgs e) { using (Stream numberingTemplateStream = DemosResourcesManager.GetResourceAsStream(externalNumerationsComboBox.Text + ".docx")) { using (DocxDocumentEditor numberingTemplateDocumentEditor = new DocxDocumentEditor(numberingTemplateStream)) { DocxDocumentNumbering importedNumbering = _documentEditor.Numbering.Import( numberingTemplateDocumentEditor, numberingTemplateDocumentEditor.Numbering.Items[0]); numerationDefinitionsListBox.Items.Add(importedNumbering); numerationDefinitionsListBox.SelectedItem = importedNumbering; } } }
/// <summary> /// Initializes a new instance of the <see cref="VisualToolsToolStrip"/> class. /// </summary> public VisualToolsToolStrip() : base() { InitializeComponent(); Enabled = false; // Add "None" action Image icon = DemosResourcesManager.GetResourceAsBitmap( "DemosCommonCode.Imaging.VisualToolsToolStrip.Resources.None.png"); _noneVisualToolAction = new NoneAction("None", "None", icon); AddAction(_noneVisualToolAction); _actionStatusLabel.DisplayStyle = ToolStripItemDisplayStyle.Text; }
/// <summary> /// Initializes a new instance of the <see cref="BarcodeReaderTool"/> class. /// </summary> public BarcodeReaderTool() { #if !REMOVE_BARCODE_SDK _reader = new BarcodeReader(); _reader.Progress += new EventHandler <BarcodeReaderProgressEventArgs>(Reader_Progress); #endif base.Cursor = System.Windows.Forms.Cursors.Cross; RectangularObjectTransformer transformer = new RectangularObjectTransformer(this); transformer.HideInteractionPointsWhenMoving = true; TransformController = transformer; TransformController.Interaction += new EventHandler <InteractionEventArgs>(TransformController_Interaction); ActionCursor = new Cursor(DemosResourcesManager.GetResourceAsStream( @"DemosCommonCode.Imaging.VisualTools.BarcodeReaderTool.Resources.BarcodeScanner.cur")); TransformController.MoveArea.Cursor = ActionCursor; }
/// <summary> /// Selects the Chart resource. /// </summary> public static Stream SelectChartResource() { string[] chartResourceNames = DemosResourcesManager.FindResourceNames("Chart_"); // if collection of chart images is not created if (_chartImages == null) { // create collection of chart images _chartImages = new ImageCollection(); _chartImages.LayoutSettingsRequest += ChartImages_LayoutSettingsRequest; foreach (string chartResourceName in chartResourceNames) { _chartImages.Add(DemosResourcesManager.GetResourceAsStream(chartResourceName), true); } } if (_chartImages.Count == 0) { throw new Exception("Chart resources was not found."); } // create "Select image" form SelectImageForm selectImageForm = new SelectImageForm(_chartImages); selectImageForm.Size = new Size(900, 550); selectImageForm.ImagePreviewViewer.ThumbnailSize = new Size(200, 200); selectImageForm.ImagePreviewViewer.ThumbnailFlowStyle = ThumbnailFlowStyle.WrappedRows; selectImageForm.ImagePreviewViewer.SelectedThumbnailAppearance.BorderColor = Color.Black; selectImageForm.ImagePreviewViewer.FocusedThumbnailAppearance = selectImageForm.ImagePreviewViewer.SelectedThumbnailAppearance; selectImageForm.Text = "Select a chart"; selectImageForm.TopMost = true; if (selectImageForm.ShowDialog() != DialogResult.OK) { return(null); } string selectedChartResourceName = chartResourceNames[selectImageForm.SelectedImageIndex]; return(DemosResourcesManager.GetResourceAsStream(selectedChartResourceName)); }