public void RemoveCommentReplies() { //ExStart //ExFor:Comment.RemoveAllReplies //ExFor:Comment.RemoveReply(Comment) //ExFor:CommentCollection.Item(Int32) //ExSummary:Shows how to remove comment replies. Document doc = new Document(); Comment comment = new Comment(doc, "John Doe", "J.D.", DateTime.Now); comment.SetText("My comment."); doc.FirstSection.Body.FirstParagraph.AppendChild(comment); comment.AddReply("Joe Bloggs", "J.B.", DateTime.Now, "New reply"); comment.AddReply("Joe Bloggs", "J.B.", DateTime.Now, "Another reply"); Assert.AreEqual(2, comment.Replies.Count()); // Below are two ways of removing replies from a comment. // 1 - Use the "RemoveReply" method to remove replies from a comment individually: comment.RemoveReply(comment.Replies[0]); Assert.AreEqual(1, comment.Replies.Count()); // 2 - Use the "RemoveAllReplies" method to remove all replies from a comment at once: comment.RemoveAllReplies(); Assert.AreEqual(0, comment.Replies.Count()); //ExEnd }
public void RemoveCommentReplies() { //ExStart //ExFor:Comment.RemoveAllReplies //ExFor:Comment.RemoveReply(Comment) //ExFor:CommentCollection.Item(Int32) //ExSummary:Shows how to remove comment replies. Document doc = new Document(); Comment comment = new Comment(doc, "John Doe", "J.D.", DateTime.Now); comment.SetText("My comment."); doc.FirstSection.Body.FirstParagraph.AppendChild(comment); comment.AddReply("Joe Bloggs", "J.B.", DateTime.Now, "New reply"); comment.AddReply("Joe Bloggs", "J.B.", DateTime.Now, "Another reply"); Assert.AreEqual(2, comment.Replies.Count()); // We can remove replies from a comment individually. comment.RemoveReply(comment.Replies[0]); Assert.AreEqual(1, comment.Replies.Count()); // We can also remove all of a comment's replies at once with this method. comment.RemoveAllReplies(); Assert.AreEqual(0, comment.Replies.Count()); //ExEnd }
[Test] //ExSkip public void CreateCommentsAndPrintAllInfo() { Document doc = new Document(); Comment newComment = new Comment(doc) { Author = "VDeryushev", Initial = "VD", DateTime = DateTime.Now }; newComment.SetText("Comment regarding text."); // Add text to the document, warp it in a comment range, and then add your comment. Paragraph para = doc.FirstSection.Body.FirstParagraph; para.AppendChild(new CommentRangeStart(doc, newComment.Id)); para.AppendChild(new Run(doc, "Commented text.")); para.AppendChild(new CommentRangeEnd(doc, newComment.Id)); para.AppendChild(newComment); // Add two replies to the comment. newComment.AddReply("John Doe", "JD", DateTime.Now, "New reply."); newComment.AddReply("John Doe", "JD", DateTime.Now, "Another reply."); PrintAllCommentInfo(doc.GetChildNodes(NodeType.Comment, true)); }
public void AddCommentWithReply() { //ExStart //ExFor:Comment //ExFor:Comment.SetText(String) //ExFor:Comment.Replies //ExFor:Comment.AddReply(String, String, DateTime, String) //ExSummary:Shows how to add a comment with a reply to a document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); //Create new comment Comment newComment = new Comment(doc, "John Doe", "J.D.", DateTime.Now); newComment.SetText("My comment."); //Add this comment to a document node builder.CurrentParagraph.AppendChild(newComment); //Add comment reply newComment.AddReply("John Doe", "JD", new DateTime(2017, 9, 25, 12, 15, 0), "New reply"); //ExEnd MemoryStream dstStream = new MemoryStream(); doc.Save(dstStream, SaveFormat.Docx); Comment docComment = (Comment)doc.GetChild(NodeType.Comment, 0, true); Assert.AreEqual(1, docComment.Count); Assert.AreEqual(1, newComment.Replies.Count); Assert.AreEqual("\u0005My comment.\r", docComment.GetText()); Assert.AreEqual("\u0005New reply\r", docComment.Replies[0].GetText()); }
[Test] //ExSkip public void CreateCommentsAndPrintAllInfo() { Document doc = new Document(); doc.RemoveAllChildren(); Section sect = (Section)doc.AppendChild(new Section(doc)); Body body = (Body)sect.AppendChild(new Body(doc)); // Create a commented text with several comment replies for (int i = 0; i <= 10; i++) { Comment newComment = CreateComment(doc, "VDeryushev", "VD", DateTime.Now, "My test comment " + i); Paragraph para = (Paragraph)body.AppendChild(new Paragraph(doc)); para.AppendChild(new CommentRangeStart(doc, newComment.Id)); para.AppendChild(new Run(doc, "Commented text " + i)); para.AppendChild(new CommentRangeEnd(doc, newComment.Id)); para.AppendChild(newComment); for (int y = 0; y <= 2; y++) { newComment.AddReply("John Doe", "JD", DateTime.Now, "New reply " + y); } } // Look at information of our comments PrintAllCommentInfo(ExtractComments(doc)); }
public void AddRemoveCommentReply() { //ExStart:AddRemoveCommentReply Document doc = new Document(MyDir + "Comments.docx"); Comment comment = (Comment)doc.GetChild(NodeType.Comment, 0, true); comment.RemoveReply(comment.Replies[0]); comment.AddReply("John Doe", "JD", new DateTime(2017, 9, 25, 12, 15, 0), "New reply"); doc.Save(ArtifactsDir + "WorkingWithComments.AddRemoveCommentReply.docx"); //ExEnd:AddRemoveCommentReply }
public void AddCommentWithReply() { //ExStart //ExFor:Comment //ExFor:Comment.SetText(String) //ExFor:Comment.AddReply(String, String, DateTime, String) //ExSummary:Shows how to add a comment to a document, and then reply to it. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Comment comment = new Comment(doc, "John Doe", "J.D.", DateTime.Now); comment.SetText("My comment."); // Place the comment at a node in the document's body. // This comment will show up at the location of its paragraph, // outside the right side margin of the page, and with a dotted line connecting it to its paragraph. builder.CurrentParagraph.AppendChild(comment); // Add a reply, which will show up under its parent comment. comment.AddReply("Joe Bloggs", "J.B.", DateTime.Now, "New reply"); // Comments and replies are both Comment nodes. Assert.AreEqual(2, doc.GetChildNodes(NodeType.Comment, true).Count); // Comments that do not reply to other comments are "top-level", and have no ancestor. Assert.Null(comment.Ancestor); // Replies have an ancestor top-level comment. Assert.AreEqual(comment, comment.Replies[0].Ancestor); doc.Save(ArtifactsDir + "Comment.AddCommentWithReply.docx"); //ExEnd doc = new Document(ArtifactsDir + "Comment.AddCommentWithReply.docx"); Comment docComment = (Comment)doc.GetChild(NodeType.Comment, 0, true); Assert.AreEqual(1, docComment.Count); Assert.AreEqual(1, comment.Replies.Count); Assert.AreEqual("\u0005My comment.\r", docComment.GetText()); Assert.AreEqual("\u0005New reply\r", docComment.Replies[0].GetText()); }
static void AddRemoveCommentReply(string dataDir) { // ExStart:AddRemoveCommentReply Document doc = new Document(dataDir + "TestFile.doc"); Comment comment = (Comment)doc.GetChild(NodeType.Comment, 0, true); //Remove the reply comment.RemoveReply(comment.Replies[0]); //Add a reply to comment comment.AddReply("John Doe", "JD", new DateTime(2017, 9, 25, 12, 15, 0), "New reply"); dataDir = dataDir + "TestFile_Out.doc"; // Save the document to disk. doc.Save(dataDir); // ExEnd:AddRemoveCommentReply Console.WriteLine("\nComment's reply is removed successfully.\nFile saved at " + dataDir); }
public void AddCommentReply(CommentReply reply, int commentId, int courseModuleId) { Comment c = GetById(courseModuleId).GetComment(commentId); c.AddReply(reply); }