VintaSoft Imaging .NET SDK v9.1 for .NET
Vintasoft.Imaging.Annotation.Comments Namespace / AnnotationComment Class
Members Example



In This Topic
    AnnotationComment Class
    In This Topic
    Provides a comment that stores data in Vintasoft.Imaging.Annotation.AnnotationData.
    Object Model
    AnnotationComment ClassAnnotationData ClassComment ClassCommentCollection ClassCommentCollection Class
    Syntax
    'Declaration
     
    <SerializableAttribute()>
    Public Class AnnotationComment 
       Inherits Comment
    [Serializable()]
    public class AnnotationComment : Comment 
    [Serializable()]
    public __gc class AnnotationComment : public Comment 
    [Serializable()]
    public ref class AnnotationComment : public Comment 
    Example
    This example shows how to print comments to the annotations of TIFF file.
    ''' <summary>
    ''' Demonstrates how to prints comments of specified TIFF file.
    ''' </summary>
    Public Class AnnotationCommentExample
                
    	''' <summary>
    	''' Prints comments of specified TIFF file.
    	''' </summary>
    	''' <param name="filename">The TIFF filename.</param>
    	Public Shared Sub PrintComments(filename As String)
    		' create an image collection
    		Using images As New Vintasoft.Imaging.ImageCollection()
    			' add TIFF file to the image collection
    			images.Add(filename)
                
    			' create annotation data controller
    			Using annotationDataController As New Vintasoft.Imaging.Annotation.AnnotationDataController(images)
    				' print all comments
    				PrintComments(annotationDataController)
    			End Using
                
    			' clear and dispose images
    			images.ClearAndDisposeItems()
    		End Using
    	End Sub
                
    	''' <summary>
    	''' Prints comments from specified annotation data controller.
    	''' </summary>
    	''' <param name="annotationDataController">The annotation data controller.</param>
    	Public Shared Sub PrintComments(annotationDataController As Vintasoft.Imaging.Annotation.AnnotationDataControllerBase)
    		' create an annotation comment controller
    		Using annotationCommentController As New Vintasoft.Imaging.Annotation.Comments.AnnotationCommentController(annotationDataController)
    			' print all comment of image collection
    			PrintComments(annotationCommentController)
    		End Using
    	End Sub
                
    	''' <summary>
    	''' Prints comments from specified comment controller.
    	''' </summary>
    	''' <param name="commentController">The comment controller.</param>
    	Public Shared Sub PrintComments(commentController As Vintasoft.Imaging.Annotation.Comments.ImageCollectionCommentController)
    		' for each image
    		For i As Integer = 0 To commentController.Images.Count - 1
    			Dim image As Vintasoft.Imaging.VintasoftImage = commentController.Images(i)
                
    			' get comments, which are associated with image
    			Dim comments As Vintasoft.Imaging.Annotation.Comments.CommentCollection = commentController.GetComments(image)
    			' if comments are found
    			If comments IsNot Nothing AndAlso comments.Count > 0 Then
    				System.Console.WriteLine(String.Format("Page {0}:", i + 1))
                
    				' for each comment
    				For Each comment As Vintasoft.Imaging.Annotation.Comments.Comment In comments
    					' print comment
    					PrintComment(comment, 0)
    				Next
    			End If
    		Next
    	End Sub
                
    	''' <summary>
    	''' Prints the comment.
    	''' </summary>
    	''' <param name="comment">The comment.</param>
    	''' <param name="replyLevel">The reply level.</param>
    	Private Shared Sub PrintComment(comment As Vintasoft.Imaging.Annotation.Comments.Comment, replyLevel As Integer)
    		' print comment
    		System.Console.Write(String.Empty.PadLeft(replyLevel * 4))
    		System.Console.WriteLine(String.Format("[{0}] {1}: {2} ({3})", comment.Type, comment.UserName, comment.Text, comment.ModifyDate))
                
    		' if comment has replies
    		If comment.Replies IsNot Nothing Then
    			' print replies
    			For Each reply As Vintasoft.Imaging.Annotation.Comments.Comment In comment.Replies
    				PrintComment(reply, replyLevel + 1)
    			Next
    		End If
    	End Sub
                
    End Class
    /// <summary>
    /// Demonstrates how to prints comments of specified TIFF file.
    /// </summary>
    public class AnnotationCommentExample
    {
                
        /// <summary>
        /// Prints comments of specified TIFF file.
        /// </summary>
        /// <param name="filename">The TIFF filename.</param>
        public static void PrintComments(string filename)
        {
            // create an image collection
            using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
            {
                // add TIFF file to the image collection
                images.Add(filename);
                
                // create annotation data controller
                using (Vintasoft.Imaging.Annotation.AnnotationDataController annotationDataController =
                    new Vintasoft.Imaging.Annotation.AnnotationDataController(images))
                {
                    // print all comments
                    PrintComments(annotationDataController);
                }
                
                // clear and dispose images
                images.ClearAndDisposeItems();
            }
        }
                
        /// <summary>
        /// Prints comments from specified annotation data controller.
        /// </summary>
        /// <param name="annotationDataController">The annotation data controller.</param>
        public static void PrintComments(Vintasoft.Imaging.Annotation.AnnotationDataControllerBase annotationDataController)
        {
            // create an annotation comment controller
            using (Vintasoft.Imaging.Annotation.Comments.AnnotationCommentController annotationCommentController =
                new Vintasoft.Imaging.Annotation.Comments.AnnotationCommentController(annotationDataController))
            {
                // print all comment of image collection
                PrintComments(annotationCommentController);
            }
        }
                
        /// <summary>
        /// Prints comments from specified comment controller.
        /// </summary>
        /// <param name="commentController">The comment controller.</param>
        public static void PrintComments(Vintasoft.Imaging.Annotation.Comments.ImageCollectionCommentController commentController)
        {
            // for each image
            for (int i = 0; i < commentController.Images.Count; i++)
            {
                Vintasoft.Imaging.VintasoftImage image = commentController.Images[i];
                
                // get comments, which are associated with image
                Vintasoft.Imaging.Annotation.Comments.CommentCollection comments = commentController.GetComments(image);
                // if comments are found
                if (comments != null && comments.Count > 0)
                {
                    System.Console.WriteLine(string.Format("Page {0}:", i + 1));
                
                    // for each comment
                    foreach (Vintasoft.Imaging.Annotation.Comments.Comment comment in comments)
                    {
                        // print comment
                        PrintComment(comment, 0);
                    }
                }
            }
        }
                
        /// <summary>
        /// Prints the comment.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <param name="replyLevel">The reply level.</param>
        private static void PrintComment(Vintasoft.Imaging.Annotation.Comments.Comment comment, int replyLevel)
        {
            // print comment
            System.Console.Write(string.Empty.PadLeft(replyLevel * 4));
            System.Console.WriteLine(string.Format("[{0}] {1}: {2} ({3})", comment.Type, comment.UserName, comment.Text, comment.ModifyDate));
                
            // if comment has replies
            if (comment.Replies != null)
            {
                // print replies
                foreach (Vintasoft.Imaging.Annotation.Comments.Comment reply in comment.Replies)
                    PrintComment(reply, replyLevel + 1);
            }
        }
                
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Annotation.Comments.Comment
          Vintasoft.Imaging.Annotation.Comments.AnnotationComment

    Requirements

    Target Platforms: .NET 5 Preview 7; .NET Core 3.1; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also