public ExportDialog(IAnnotationPackageProvider annotationPackageProvider) { this._annotationPackageProvider = annotationPackageProvider; this.InitializeComponent(); this.labelDownloadProgress.Visible = false; this._config = this._annotationPackageProvider.GetAnnotationConfigAsync().GetAwaiter().GetResult(); var tags = this._config.Tags; tags.Insert(0, new AnnotationPackageTag { Value = "All" }); this.dataGridViewTags.DataSource = tags; this.dataGridViewObjectClasses.DataSource = this._config.ObjectClasses.Select(o => new ObjectClassExtended { Id = o.Id, Name = o.Name, Selected = true }).ToList(); // Set export providers var objects = InterfaceHelper.GetImplementations <IAnnotationExportProvider>(); this.comboBoxExportProvider.DataSource = objects; this.comboBoxExportProvider.DisplayMember = "Name"; // Make data grid views not create their own columns this.dataGridViewTags.AutoGenerateColumns = false; this.dataGridViewResult.AutoGenerateColumns = false; }
/// <summary> /// Assigns/sets document access rights /// </summary> public static void AssignAccessRights() { try { //ExStart:AssignAccessRight // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage. var document = documentRepository.GetDocument("Document.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf"); // Set document access rights annotator.SetDocumentAccessRights(documentId, AnnotationReviewerRights.All); //ExEnd:AssignAccessRight } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
public Main() { this._annotationPackageProvider = new AmazonAnnotationPackageProvider(); this._annotationConfig = this._annotationPackageProvider.GetAnnotationConfigAsync().GetAwaiter().GetResult(); if (this._annotationConfig == null) { this._annotationConfig = new AnnotationConfig(); using (var configurationForm = new ConfigurationForm()) { configurationForm.Setup(this._annotationConfig); configurationForm.ShowDialog(); } } this.InitializeComponent(); this.downloadControl.Dock = DockStyle.Fill; this.annotationPackageListControl.Setup(this._annotationPackageProvider); this.autoplaceAnnotationsToolStripMenuItem.Checked = true; this.annotationDrawControl.AutoplaceAnnotations = true; this.annotationDrawControl.SetObjectClasses(this._annotationConfig.ObjectClasses); this.annotationDrawControl.ShowLabels = true; this.showLabelsToolStripMenuItem.Checked = true; }
/// <summary> /// Picks the annotations from document.pdf and exports them to sample.pdf /// </summary> public static void ExportAnnotationInFile() { try { //ExStart:ExportAnnotationInFile // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get file stream Stream manifestResourceStream = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); List <AnnotationInfo> annotations = new List <AnnotationInfo>(); Stream stream = annotator.ExportAnnotationsToDocument(manifestResourceStream, annotations, DocumentType.Pdf); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.pdf"), FileMode.Create)) { byte[] buffer = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:ExportAnnotationInFile } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Creates a document data object in the storage /// </summary> public static void CreateDocument() { try { //ExStart:CreateDocument // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage. var document = documentRepository.GetDocument("sample.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("sample.pdf"); Console.WriteLine("Document ID : " + documentId); //ExEnd:CreateDocument } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Removes all annotations in Images document /// </summary> public static void RemoveAllAnnotationsFromDocument() { try { //ExStart:RemoveAllAnnotationsFromDocument // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); // Get output file stream Stream result = annotator.RemoveAnnotationStream(inputFile, DocumentType.Images); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.png"), FileMode.Create)) { byte[] buffer = new byte[result.Length]; result.Seek(0, SeekOrigin.Begin); result.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:RemoveAllAnnotationsFromDocument } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Gets annotations from the storage file /// </summary> /// <returns>Returns a list of annotations</returns> public static ListAnnotationsResult GetAllDocumentAnnotation() { try { //ExStart:GetAllAnnotation // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage. var document = documentRepository.GetDocument("Document.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf"); // Get annotation from storage ListAnnotationsResult result = annotator.GetAnnotations(documentId); return(result); //ExEnd:GetAllAnnotation } catch (System.Exception exp) { Console.WriteLine(exp.Message); return(null); } }
/// <summary> /// Get Image Representation of Pages for PDF /// </summary> public static void GetImageRepresentationOfPagesForPDF() { try { //ExStart:GetImageRepresentationOfPagesForPDF // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); List <PageImage> images = annotator.GetPages(inputFile, new ImageOptions { WithoutAnnotations = true }); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.png"), FileMode.Create)) { byte[] buffer = new byte[images[0].Stream.Length]; images[0].Stream.Seek(0, SeekOrigin.Begin); images[0].Stream.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:GetImageRepresentationOfPagesForPDF } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
public TagSelectionDialog(AnnotationConfig config, List <AnnotationPackageTag> selectedTags) { this.InitializeComponent(); this._config = config; this._selectedTags = selectedTags; }
private static AnnotationResources GetAnnotationResources(AnnotationConfig annotationConfig) { var genomeAssembly = GenomeAssemblyHelper.Convert(annotationConfig.genomeAssembly); string cachePathPrefix = LambdaUrlHelper.GetCacheFolder().UrlCombine(genomeAssembly.ToString()).UrlCombine(LambdaUrlHelper.DefaultCacheSource); string nirvanaS3Ref = LambdaUrlHelper.GetRefUrl(genomeAssembly); string saManifestUrl = LambdaUtilities.GetManifestUrl(annotationConfig.supplementaryAnnotations ?? "latest", genomeAssembly); var metrics = new PerformanceMetrics(); var annotationResources = new AnnotationResources(nirvanaS3Ref, cachePathPrefix, saManifestUrl == null? null: new List <string> { saManifestUrl }, annotationConfig.customAnnotations, annotationConfig.customStrUrl, false, false, false, metrics); using (var tabixStream = PersistentStreamUtils.GetReadStream(annotationConfig.tabixUrl)) { annotationResources.InputStartVirtualPosition = GetTabixVirtualPosition(annotationConfig.annotationRange, tabixStream, annotationResources.SequenceProvider.RefNameToChromosome); } Logger.WriteLine($"Tabix position :{annotationResources.InputStartVirtualPosition}"); return(annotationResources); }
//ExEnd:GetConfiguration //ExStart:GetImageRepresentation /// <summary> /// Gets image representation of document /// </summary> /// <param name="CommonUtilities.filePath">Source file path</param> public static void GetImageRepresentation(string filePath) { try { Stream document = new FileStream(MapSourceFilePath(filePath), FileMode.Open); AnnotationConfig cfg = GetConfiguration(); AnnotationImageHandler annotationHandler = new AnnotationImageHandler(cfg); List <PageImage> images = annotationHandler.GetPages(document, new ImageOptions()); // Save result stream to file. using (FileStream fileStream = new FileStream(MapDestinationFilePath("image.png"), FileMode.Create)) { byte[] buffer = new byte[images[0].Stream.Length]; images[0].Stream.Seek(0, SeekOrigin.Begin); images[0].Stream.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
//ExEnd:GetImageRepresentation //ExStart:GetTextCoordinatesInImage /// <summary> /// Gets text coordinates in image representation of document /// </summary> /// <param name="CommonUtilities.filePath">Source file path</param> public static void GetTextCoordinates(string filePath) { try { // Set configuration AnnotationConfig cfg = GetConfiguration(); // Initialize annotator AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); try { annotator.CreateDocument(filePath); } catch { } var documentInfoContainer = annotator.GetDocumentInfo(filePath); // Go through all pages foreach (PageData pageData in documentInfoContainer.Pages) { Console.WriteLine("Page number: " + pageData.Number); //Go through all page rows for (int i = 0; i < pageData.Rows.Count; i++) { RowData rowData = pageData.Rows[i]; // Write data to console Console.WriteLine("Row: " + (i + 1)); Console.WriteLine("Text: " + rowData.Text); Console.WriteLine("Text width: " + rowData.LineWidth); Console.WriteLine("Text height: " + rowData.LineHeight); Console.WriteLine("Distance from left: " + rowData.LineLeft); Console.WriteLine("Distance from top: " + rowData.LineTop); // Get words string[] words = rowData.Text.Split(' '); // Go through all word coordinates for (int j = 0; j < words.Length; j++) { int coordinateIndex = j == 0 ? 0 : j + 1; // Write data to console Console.WriteLine(string.Empty); Console.WriteLine("Word:'" + words[j] + "'"); Console.WriteLine("Word distance from left: " + rowData.TextCoordinates[coordinateIndex]); Console.WriteLine("Word width: " + rowData.TextCoordinates[coordinateIndex + 1]); Console.WriteLine(string.Empty); } Console.ReadKey(); } } } catch (System.Exception exp) { Console.WriteLine(exp.Message); } //ExEnd:GetTextCoordinatesInImage }
/// <summary> /// Adds reply to the annotation, edits reply, creates child reply /// </summary> public static void AddAnnotationReply() { try { //ExStart:AddAnnotationReply // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage var document = documentRepository.GetDocument("Document.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf"); // Create annotation object AnnotationInfo pointAnnotation = new AnnotationInfo { AnnotationPosition = new Point(852.0, 81.0), Box = new Rectangle(212f, 81f, 142f, 0.0f), Type = AnnotationType.Point, PageNumber = 0, CreatorName = "Anonym", DocumentGuid = documentId }; // Add annotation to storage var createPointAnnotationResult = annotator.CreateAnnotation(pointAnnotation); // Add simple reply to created annotation var addSimpleReplyResult = annotator.CreateAnnotationReply(createPointAnnotationResult.Id, "first question"); // Edit created reply var editReplyResult = annotator.EditAnnotationReply(addSimpleReplyResult.ReplyGuid, "changed question"); // Create child reply. This reply will be linked to previously created reply. var addChildReplyResult = annotator.CreateAnnotationReply(createPointAnnotationResult.Id, "answer", addSimpleReplyResult.ReplyGuid); // Delete annotation reply by guid var deleteReplyResult = annotator.DeleteAnnotationReply(addChildReplyResult.ReplyGuid); // Delete all replies from annotation annotator.DeleteAnnotationReplies(createPointAnnotationResult.Id); // List of replies after deleting all replies var listRepliesResultAfterDeleteAll = annotator.ListAnnotationReplies(createPointAnnotationResult.Id); //ExEnd:AddAnnotationReply } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Updates the text in the annotation /// </summary> public static void EditTextFieldAnnotation() { try { //ExStart:EditTextFieldAnnotation // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage. var document = documentRepository.GetDocument("Document.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf"); // Create annotation object AnnotationInfo textFieldAnnotation = new AnnotationInfo { AnnotationPosition = new Point(852.0, 201.0), FieldText = "text in the box", FontFamily = "Arial", FontSize = 10, Box = new Rectangle(66f, 201f, 64f, 37f), PageNumber = 0, Type = AnnotationType.TextField, CreatorName = "Anonym", DocumentGuid = documentId }; //Add annotation to storage CreateAnnotationResult createTextFieldAnnotationResult = annotator.CreateAnnotation(textFieldAnnotation); // Update text in the annotation SaveAnnotationTextResult saveTextFieldResult = annotator.SaveTextField( createTextFieldAnnotationResult.Id, new TextFieldInfo { FieldText = "new text", FontFamily = "Colibri", FontSize = 12 }); // Set text field color SaveAnnotationTextResult saveTextFieldColorResult = annotator.SetTextFieldColor (createTextFieldAnnotationResult.Id, 16753920); //ExEnd:EditTextFieldAnnotation } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
public static AnnotationImageHandler createAnnotationImageHandler() { AnnotationConfig cfg = new AnnotationConfig(); cfg.StoragePath = getStoragePath(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); return(annotator); }
public Main() { this.StartPosition = FormStartPosition.CenterScreen; try { this._annotationPackageProvider = new AmazonAnnotationPackageProvider(); } catch (TaskCanceledException) { MessageBox.Show("The local database took too long to respond.\n\n" + "Make sure your config is correctly setup. Are MinIO and your local DynamoDB running?\n\n" + "Refer to the README.md for further information on how to correctly setup a local database.", "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Load += (s, e) => this.Close(); return; } this._annotationConfig = this._annotationPackageProvider.GetAnnotationConfigAsync().GetAwaiter().GetResult(); if (this._annotationConfig == null) { this._annotationConfig = new AnnotationConfig(); using (var configurationDialog = new ConfigurationDialog()) { configurationDialog.Setup(this._annotationConfig); var dialogResult = configurationDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { this._annotationPackageProvider.SetAnnotationConfigAsync(this._annotationConfig); } else { this.Load += (s, e) => this.Close(); return; } } } this.InitializeComponent(); this.Text = $"Alturos Image Annotation {Application.ProductVersion}"; this.downloadControl.Dock = DockStyle.Fill; this.annotationPackageListControl.Setup(this._annotationPackageProvider); this.annotationImageListControl.Setup(this._annotationPackageProvider); this.autoplaceAnnotationsToolStripMenuItem.Checked = true; this.annotationDrawControl.AutoplaceAnnotations = true; this.annotationDrawControl.SetObjectClasses(this._annotationConfig.ObjectClasses); this.annotationDrawControl.SetLabelsVisible(false); this.tagEditControl.SetConfig(this._annotationConfig); }
public ExportDialog(IAnnotationPackageProvider annotationPackageProvider) { this._annotationPackageProvider = annotationPackageProvider; this.InitializeComponent(); this._config = this._annotationPackageProvider.GetAnnotationConfigAsync().GetAwaiter().GetResult(); this.dataGridViewTags.DataSource = this._config.Tags; this.dataGridViewTags.AutoGenerateColumns = false; this.dataGridViewResult.AutoGenerateColumns = false; }
public void Setup(AnnotationConfig config) { this._config = config; this._bindingSourceObjectClasses = new BindingSource(); this._bindingSourceObjectClasses.DataSource = config.ObjectClasses; this.dataGridViewObjectClasses.DataSource = this._bindingSourceObjectClasses; this._bindingSourceTags = new BindingSource(); this._bindingSourceTags.DataSource = config.Tags; this.dataGridViewTags.DataSource = this._bindingSourceTags; }
/// <summary> /// Get Password Protected Documents /// </summary> public static FileContainer GetPasswordProtectedDocuments(Stream protectedDocument, String password) { //ExStart:GetPasswordProtectedDocuments AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); FileContainer convertedDocument = annotator.GetPdfFile(protectedDocument, password); return(convertedDocument); //ExEnd:GetPasswordProtectedDocuments }
/// <summary> /// Removes annotations /// </summary> public static void RemoveAnnotation() { try { //ExStart:RemoveAnnotation // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage. var document = documentRepository.GetDocument("Document.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf"); // Create annotation object AnnotationInfo pointAnnotation = new AnnotationInfo { AnnotationPosition = new Point(852.0, 81.0), Box = new Rectangle(212f, 81f, 142f, 0.0f), Type = AnnotationType.Point, PageNumber = 0, CreatorName = "Anonym", DocumentGuid = documentId }; // Get all annotations from storage ListAnnotationsResult listAnnotationsResult = annotator.GetAnnotations(documentId); // Get annotation var annotation = annotator.GetAnnotation(listAnnotationsResult.Annotations[0].Guid); // Delete single annotation var deleteAnnotationResult = annotator.DeleteAnnotation(annotation.Id); //Delete all annotations annotator.DeleteAnnotations(documentId); //ExEnd:RemoveAnnotation } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Resizes the existing annotations /// </summary> public static void ResizeAnnotationResult() { try { //ExStart:ResizeAnnotationResult // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler(); if (!Directory.Exists(cfg.StoragePath)) { Directory.CreateDirectory(cfg.StoragePath); } // Create document data object in storage. var document = documentRepository.GetDocument("Document.pdf"); long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf"); // Create annotation object AnnotationInfo areaAnnotation = new AnnotationInfo { AnnotationPosition = new Point(852.0, 271.7), BackgroundColor = 3355443, Box = new Rectangle(466f, 271f, 69f, 62f), PageNumber = 0, PenColor = 3355443, Type = AnnotationType.Area, CreatorName = "Anonym", DocumentGuid = documentId }; //Add annotation to storage CreateAnnotationResult createAreaAnnotationResult = annotator.CreateAnnotation(areaAnnotation); //Resize annotation ResizeAnnotationResult resizeResult = annotator.ResizeAnnotation(createAreaAnnotationResult.Id, new AnnotationSizeInfo { Height = 80, Width = 60 }); //ExEnd:ResizeAnnotationResult } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Adds Watermark annotation in Diagrams /// </summary> public static void AddWatermarkAnnotationInDiagrams() { try { //ExStart:AddWatermarkAnnotationInDiagrams // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); // Initialize list of AnnotationInfo List <AnnotationInfo> annotations = new List <AnnotationInfo>(); // Initialize watermark annotation AnnotationInfo watermarkAnnnotation = new AnnotationInfo() { Box = new Rectangle(165.41f, 192.24f, 177.8f, 38.29f), CreatedOn = DateTime.Now, FieldText = "Watermark text", FontColor = 16711680, FontFamily = "Microsoft Sans Serif", FontSize = 17, Opacity = 0.3, Type = AnnotationType.Watermark, }; // Add annotation to list annotations.Add(watermarkAnnnotation); // Get output file stream Stream result = annotator.ExportAnnotationsToDocument(inputFile, annotations); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.vsdx"), FileMode.Create)) { byte[] buffer = new byte[result.Length]; result.Seek(0, SeekOrigin.Begin); result.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:AddWatermarkAnnotationInDiagrams } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Constructor /// </summary> public AnnotationApiController() { GlobalConfiguration = new Common.Config.GlobalConfiguration(); // create annotation directories DirectoryUtils = new DirectoryUtils(GlobalConfiguration.Annotation); // create annotation application configuration AnnotationConfig config = new AnnotationConfig(); // set storage path config.StoragePath = DirectoryUtils.FilesDirectory.GetPath(); // set directory to store annotted documents GlobalConfiguration.Annotation.OutputDirectory = DirectoryUtils.OutputDirectory.GetPath(); // initialize Annotation instance for the Image mode AnnotationImageHandler = new AnnotationImageHandler(config); }
/// <summary> /// Adds Distance annotation in Diagrams /// </summary> public static void AddDistanceAnnotationInDiagrams() { try { //ExStart:AddDistanceAnnotationInDiagrams // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); // Initialize list of AnnotationInfo List <AnnotationInfo> annotations = new List <AnnotationInfo>(); // Initialize distance annotation AnnotationInfo distanceAnnnotation = new AnnotationInfo { Box = new Rectangle((float)248.73202514648438, (float)287.85653686523438, (float)115.9178466796875, (float)25.143020629882812), CreatedOn = DateTime.Now, Opacity = 0.3, PageNumber = 0, SvgPath = "M248.73201877934272,295.5439436619718 l115.28309859154929,-4.192112676056338", Type = AnnotationType.Distance, }; // Add annotation to list annotations.Add(distanceAnnnotation); // Get output file stream Stream result = annotator.ExportAnnotationsToDocument(inputFile, annotations); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.vsdx"), FileMode.Create)) { byte[] buffer = new byte[result.Length]; result.Seek(0, SeekOrigin.Begin); result.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:AddDistanceAnnotationInDiagrams } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
public HttpResponseMessage loadFileTree(AnnotationPostedDataEntity fileTreeRequest) { string relDirPath = fileTreeRequest.path; // get file list from storage path FileTreeOptions fileListOptions = new FileTreeOptions(relDirPath); // get temp directory name string tempDirectoryName = new AnnotationConfig().TempFolderName; try { FileTreeContainer fileListContainer = AnnotationImageHandler.LoadFileTree(fileListOptions); List <FileDescriptionEntity> fileList = new List <FileDescriptionEntity>(); // parse files/folders list foreach (FileDescription fd in fileListContainer.FileTree) { FileDescriptionEntity fileDescription = new FileDescriptionEntity(); fileDescription.guid = fd.Guid; // check if current file/folder is temp directory or is hidden FileInfo fileInfo = new FileInfo(fileDescription.guid); if (tempDirectoryName.ToLower().Equals(fileDescription.guid) || fileInfo.Attributes.HasFlag(FileAttributes.Hidden)) { // ignore current file and skip to next one continue; } else { // set file/folder name fileDescription.name = fd.Name; } // set file type fileDescription.docType = fd.DocumentType; // set is directory true/false fileDescription.isDirectory = fd.IsDirectory; // set file size fileDescription.size = fd.Size; // add object to array list fileList.Add(fileDescription); } return(Request.CreateResponse(HttpStatusCode.OK, fileList)); } catch (System.Exception ex) { // set exception message return(Request.CreateResponse(HttpStatusCode.OK, new Resources().GenerateException(ex))); } }
//ExEnd:SetMeteredLicense //ExStart:GetConfiguration /// <summary> /// Sets annotation configuration /// </summary> /// <returns>Returns AnnotationConfig object</returns> public static AnnotationConfig GetConfiguration() { try { AnnotationConfig cfg = new AnnotationConfig(); //Set storage path cfg.StoragePath = StorageFolderPath; return(cfg); } catch (System.Exception exp) { Console.WriteLine(exp.Message); return(null); } }
/// <summary> /// Adds TextField annotation in Diagrams /// </summary> public static void AddTextFieldAnnotationInDiagrams() { try { //ExStart:AddTextFieldAnnotationInDiagrams // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); // Initialize list of AnnotationInfo List <AnnotationInfo> annotations = new List <AnnotationInfo>(); // Initialize textfield annotation AnnotationInfo textFieldAnnotation = new AnnotationInfo { CreatedOn = DateTime.Now, Type = AnnotationType.TextField, Box = new Rectangle(162.87f, 267.5f, 91.8f, 42.45f), BackgroundColor = -15988609, FieldText = "Annotation Text" }; // Add annotation to list annotations.Add(textFieldAnnotation); // Get output file stream Stream result = annotator.ExportAnnotationsToDocument(inputFile, annotations); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.vsdx"), FileMode.Create)) { byte[] buffer = new byte[result.Length]; result.Seek(0, SeekOrigin.Begin); result.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:AddTextFieldAnnotationInDiagrams } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Adds Point annotation in Diagrams /// </summary> public static void AddPointAnnotationInDiagrams() { try { //ExStart:AddPointAnnotationInDiagrams // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); // Initialize list of AnnotationInfo List <AnnotationInfo> annotations = new List <AnnotationInfo>(); // Initialize point annotation AnnotationInfo pointAnnnotation = new AnnotationInfo() { Box = new Rectangle(150.32f, 99.22f, 0, 0), CreatedOn = DateTime.Now, PageNumber = 0, Type = AnnotationType.Point, }; // Add annotation to list annotations.Add(pointAnnnotation); // Get output file stream Stream result = annotator.ExportAnnotationsToDocument(inputFile, annotations); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.vsdx"), FileMode.Create)) { byte[] buffer = new byte[result.Length]; result.Seek(0, SeekOrigin.Begin); result.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:AddPointAnnotationInDiagrams } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Adds Polyline annotation in Diagrams /// </summary> public static void AddPolylineAnnotationInDiagrams() { try { //ExStart:AddPolylineAnnotationInDiagrams // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); // Initialize list of AnnotationInfo List <AnnotationInfo> annotations = new List <AnnotationInfo>(); // Initialize polyline annotation AnnotationInfo polylineAnnotation = new AnnotationInfo { CreatedOn = DateTime.Now, Type = AnnotationType.Polyline, Box = new Rectangle(206.3f, 106.61f, 456.04f, 307.97f), SvgPath = "M436.293427230047,148.06338028169014l0,-0.9870892018779343l-0.9870892018779343,-0.9870892018779343l-1.9741784037558685,-0.9870892018779343l-0.9870892018779343,0l-0.9870892018779343,-0.9870892018779343l-1.9741784037558685,-0.9870892018779343l-0.9870892018779343,0l-1.9741784037558685,-0.9870892018779343l-1.9741784037558685,0l-4.935446009389671,-1.9741784037558685l-1.9741784037558685,0l-1.9741784037558685,-0.9870892018779343l-1.9741784037558685,0l-1.9741784037558685,-0.9870892018779343l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-1.9741784037558685,0l-3.948356807511737,0l-2.961267605633803,0l-3.948356807511737,0l-4.935446009389671,0l-3.948356807511737,0.9870892018779343l-4.935446009389671,0.9870892018779343l-6.90962441314554,0l-3.948356807511737,0.9870892018779343l-3.948356807511737,0l-2.961267605633803,1.9741784037558685l-3.948356807511737,0.9870892018779343l-6.90962441314554,1.9741784037558685l-6.90962441314554,0.9870892018779343l-12.832159624413146,2.961267605633803l-6.90962441314554,1.9741784037558685l-5.922535211267606,0.9870892018779343l-5.922535211267606,1.9741784037558685l-5.922535211267606,1.9741784037558685l-5.922535211267606,0.9870892018779343l-4.935446009389671,1.9741784037558685l-5.922535211267606,1.9741784037558685l-5.922535211267606,1.9741784037558685l-4.935446009389671,1.9741784037558685l-5.922535211267606,2.961267605633803l-5.922535211267606,3.948356807511737l-5.922535211267606,3.948356807511737l-4.935446009389671,3.948356807511737l-5.922535211267606,3.948356807511737l-5.922535211267606,3.948356807511737l-3.948356807511737,5.922535211267606l- 3.948356807511737,4.935446009389671l-3.948356807511737,5.922535211267606l-3.948356807511737,6.90962441314554l-3.948356807511737,7.896713615023474l-0.9870892018779343,6.90962441314554l-1.9741784037558685,7.896713615023474l-1.9741784037558685,6.90962441314554l-0.9870892018779343,7.896713615023474l0,12.832159624413146l0,7.896713615023474l0,7.896713615023474l0.9870892018779343,7.896713615023474l1.9741784037558685,5.922535211267606l2.961267605633803,5.922535211267606l0.9870892018779343,5.922535211267606l2.961267605633803,6.90962441314554l3.948356807511737,5.922535211267606l4.935446009389671,4.935446009389671l3.948356807511737,5.922535211267606l3.948356807511737,5.922535211267606l3.948356807511737,5.922535211267606l5.922535211267606,5.922535211267606l5.922535211267606,5.922535211267606l5.922535211267606,5.922535211267606l6.90962441314554,5.922535211267606l7.896713615023474,5.922535211267606l7.896713615023474,5.922535211267606l17.767605633802816,8.883802816901408l11.845070422535212,3.948356807511737l11.845070422535212,4.935446009389671l23.690140845070424,8.883802816901408l41.45774647887324,6.90962441314554l31.586854460093896,3.948356807511737l16.780516431924884,0l16.780516431924884,1.9741784037558685l16.780516431924884,0l16.780516431924884,0l16.780516431924884,0l16.780516431924884,0l16.780516431924884,-1.9741784037558685l14.806338028169014,-1.9741784037558685l14.806338028169014,-1.9741784037558685l12.832159624413146,-1.9741784037558685l10.857981220657276,-2.961267605633803l10.857981220657276,-2.961267605633803l8.883802816901408,-4.935446009389671l8.883802816901408,-4.935446009389671l6.90962441314554,-6.90962441314554l6.90962441314554,-6.90962441314554l8.883802816901408,-16.780516431924884l4.935446009389671,-7.896713615023474l3.948356807511737,-8.883802816901408l4.935446009389671,-7.896713615023474l4.935446009389671,-7.896713615023474l3.948356807511737,-13.81924882629108l1.9741784037558685,-18.754694835680752l0,-7.896713615023474l0,-12.832159624413146l-1.9741784037558685,-15.793427230046948l-1.9741784037558685,-15.793427230046948l-4.935446009389671,-15.793427230046948l-8.883802816901408,-15.793427230046948l-12.832159624413146,-23.690140845070424l-10.857981220657276,-10.857981220657276l-5.922535211267606,-3.948356807511737l-12.832159624413146,-8.883802816901408l-9.870892018779342,-8.883802816901408l-5.922535211267606,-3.948356807511737l-12.832159624413146,-5.922535211267606l-15.793427230046948,-8.883802816901408l-13.81924882629108,-4.935446009389671l-11.845070422535212,-2.961267605633803l-11.845070422535212,-3.948356807511737l-11.845070422535212,-3.948356807511737l-5.922535211267606,-1.9741784037558685l-11.845070422535212,-2.961267605633803l-11.845070422535212,-1.9741784037558685l-5.922535211267606,-0.9870892018779343l-10.857981220657276,-1.9741784037558685l-10.857981220657276,-2.961267605633803l-9.870892018779342,0l-0.9870892018779343,0l-0.9870892018779343,0l-0.9870892018779343,0l-0.9870892018779343,0l0,-0.9870892018779343l1.9741784037558685,0", }; // Add annotation to list annotations.Add(polylineAnnotation); // Get output file stream Stream result = annotator.ExportAnnotationsToDocument(inputFile, annotations); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.vsdx"), FileMode.Create)) { byte[] buffer = new byte[result.Length]; result.Seek(0, SeekOrigin.Begin); result.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:AddPolylineAnnotationInDiagrams } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
/// <summary> /// Adds Resource Redaction annotation in Diagrams /// </summary> public static void AddResourceRedactionAnnotationInDiagrams() { try { //ExStart:AddResourceRedactionAnnotationInDiagrams // Create instance of annotator. AnnotationConfig cfg = CommonUtilities.GetConfiguration(); AnnotationImageHandler annotator = new AnnotationImageHandler(cfg); // Get input file stream Stream inputFile = new FileStream(CommonUtilities.MapSourceFilePath(CommonUtilities.filePath), FileMode.Open, FileAccess.ReadWrite); // Initialize list of AnnotationInfo List <AnnotationInfo> annotations = new List <AnnotationInfo>(); // Initialize resource reduction annotation AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo { Type = AnnotationType.ResourcesRedaction, Box = new Rectangle(200, 114.5f, 282.3f, 103.7f), }; // Add annotation to list annotations.Add(resourceRedactionAnnotation); // Get output file stream Stream result = annotator.ExportAnnotationsToDocument(inputFile, annotations); // Save result stream to file. using (FileStream fileStream = new FileStream(CommonUtilities.MapDestinationFilePath("Annotated.vsdx"), FileMode.Create)) { byte[] buffer = new byte[result.Length]; result.Seek(0, SeekOrigin.Begin); result.Read(buffer, 0, buffer.Length); fileStream.Write(buffer, 0, buffer.Length); fileStream.Close(); } //ExEnd:AddResourceRedactionAnnotationInDiagrams } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }