Commenting the Document

Parts of a document can be commented. An end-user can select a piece of text and open a comment input control through the context menu to type the comment's text. When the input control is closed, either through a mouse click or through the Enter key, the comment is added to the document and the commented text is highlighted on the screen with a color depending on the user, the default color for the current user is red. The comment's context menu also offers entries to change, remove and reply to a comment. All comments in a document are available in a CommentCollection which can be obtained through the TextControl.Comments or WPF.TextControl.Comments properties. The collection consists of CommentedText objects which describe the commented piece of text and the comment itself. Programmatically, a comment can be added to the document with the collection's Add methods, which either open the comment input control or add a prepared CommentedText object. Each comment has a creation time and is related to a user. When a new comment is inserted, the current user is associated with it. The current user is the first in the list of users set with the TextControl.UserNames property. When the list of users is empty, the UserName is set to an empty string which is interpreted as an unknown user. Comments can have replies which are also contained as CommentedText objects in the CommentCollection. Replies are associated with the same piece of text, but can be related to another user and can have another creation time. The relationship is available through the CommentedText.Replies and CommentedText.RepliedComment properties. When the original comment is removed from the document all of its replies are also removed. Events occur, when a comment is created (CommentCreated), deleted (CommentDeleted) or the text of the comment is changed (CommentChanged). Further events occur, when the current input position has been moved to a position that belongs to a commented piece of text (CommentedTextEntered) or when the current input position has left it (CommentedTextLeft). Comments are saved and can be reloaded with the TextControl text format (.tx), the Rich Text Format (.rtf) and the Microsoft Word formats (.doc, .docx). A sidebar content layout is provided to show, select and edit the comments of the document through a sidebar. It can be used either by connecting a sidebar with one of the two RibbonProofingTab properties CommentsSidebar and CommentsHorizontalSidebar, or by setting its ContentLayout property to the Comments enumeration and binding the sidebar with the corresponding TextControl.

Classes

Class Description
TXTextControl.CommentCollection Contains all comments in the main text or another part of a document.
TXTextControl.CommentEventArgs The CommentEventArgs class provides data for the CommentCreated, CommentDeleted, CommentedTextEntered, CommentedTextLeft, CommentChanged and CommentStateChanged events.
TXTextControl.CommentedText A CommentedText object represents a commented piece of text.

Constructors

Constructor Description
TXTextControl.CommentedText Initializes a new instance of the CommentedText class.

Enumerations

Enumeration Description
TXTextControl.CommentCollection.AddResult Specifies the result when a comment has been added to the document.

Events

Event Description
TXTextControl.ServerTextControl.CommentCreated Occurs when a piece of text has been commented.
TXTextControl.ServerTextControl.CommentDeleted Occurs when a comment has been removed from the document.
TXTextControl.TextControl.CommentChanged Occurs when the text of a comment has been altered.
TXTextControl.TextControl.CommentCreated Occurs when a piece of text has been commented.
TXTextControl.TextControl.CommentDeleted Occurs when a comment has been removed from the document.
TXTextControl.TextControl.CommentedTextEntered Occurs when the current input position has been moved to a position that belongs to a commented piece of text.
TXTextControl.TextControl.CommentedTextLeft Occurs when the current input position has left a commented piece of text.
TXTextControl.TextControl.CommentStateChanged Occurs when the state of a comment alters from active to inactive or vice versa.

Methods

Method Description
TXTextControl.CommentCollection.Add Adds a new comment to the document.
TXTextControl.CommentCollection.CopyTo Copies the elements of the collection to an array, starting at a particular index.
TXTextControl.CommentCollection.GetEnumerator Returns an enumerator that can be used to iterate through the collection.
TXTextControl.CommentCollection.GetItem Gets a particular item from the collection.
TXTextControl.CommentCollection.Remove Removes a CommentedText from the collection.
TXTextControl.CommentedText.EditComment Opens a comment input control to edit the comment's text.
TXTextControl.CommentedText.ReplyToComment Opens a comment input control to reply to this comment.
TXTextControl.CommentedText.Save Saves the commented text with the specified format.
TXTextControl.CommentedText.ScrollTo Sets the current input position to the first position of the commented text and scrolls it into the visible part of the document.
TXTextControl.CommentedText.Select Selects the commented part of the document.
TXTextControl.ServerTextControl.OnCommentCreated Raises the CommentCreated event.
TXTextControl.ServerTextControl.OnCommentDeleted Raises the CommentDeleted event.
TXTextControl.TextControl.OnCommentChanged Raises the CommentChanged event.
TXTextControl.TextControl.OnCommentCreated Raises the CommentCreated event.
TXTextControl.TextControl.OnCommentDeleted Raises the CommentDeleted event.
TXTextControl.TextControl.OnCommentedTextEntered Raises the CommentedTextEntered event.
TXTextControl.TextControl.OnCommentedTextLeft Raises the CommentedTextLeft event.
TXTextControl.TextControl.OnCommentStateChanged Raises the CommentStateChanged event.

Properties

Property Description
TXTextControl.CommentCollection.Count Gets the number of elements contained in the collection.
TXTextControl.CommentCollection.IsSynchronized Returns true if the collection is designed to be thread safe, otherwise, it returns false.
TXTextControl.CommentCollection.Item Gets the comment with the specified number from the collection.
TXTextControl.CommentCollection.SyncRoot Gets an object that can be used to synchronize access to the collection.
TXTextControl.CommentEventArgs.CommentedText Gets an object that represents the commented text.
TXTextControl.CommentedText.Active Gets or sets a value specifying whether the comment is currently active or not.
TXTextControl.CommentedText.Comment Gets or sets a string which is the comment.
TXTextControl.CommentedText.CreationTime Gets the date and time when the comment has been inserted.
TXTextControl.CommentedText.DefaultHighlightColor Gets the default highlight color for the commented text.
TXTextControl.CommentedText.HighlightColor Gets or sets the highlight color for the commented text.
TXTextControl.CommentedText.HighlightMode Gets or sets a value indicating whether the commented text is highlighted.
TXTextControl.CommentedText.ID Gets or sets a user-defined identifier.
TXTextControl.CommentedText.Length Gets the number of commented characters.
TXTextControl.CommentedText.Number Gets the comment's number.
TXTextControl.CommentedText.RepliedComment Gets the comment for which this comment is a reply.
TXTextControl.CommentedText.Replies Gets all replies of this comment or null if there are no replies.
TXTextControl.CommentedText.Start Gets the index (one-based) of the first commented character.
TXTextControl.CommentedText.Text Gets the commented text.
TXTextControl.CommentedText.UserName Gets the name of the user who has commented the document.
TXTextControl.ServerTextControl.Comments Gets a collection of all comments.
TXTextControl.TextControl.CommentHighlightMode Gets or sets a value indicating whether all the commented texts in the document are highlighted.
TXTextControl.TextControl.Comments Gets a collection of all comments contained in the text part with the input focus.