public static void Run() { //ExStart:AddParentComments // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Slides_Presentations_Comments(); using (Presentation pres = new Presentation()) { // Add comment ICommentAuthor author1 = pres.CommentAuthors.AddAuthor("Author_1", "A.A."); IComment comment1 = author1.Comments.AddComment("comment1", pres.Slides[0], new PointF(10, 10), DateTime.Now); // Add reply for comment1 ICommentAuthor author2 = pres.CommentAuthors.AddAuthor("Autror_2", "B.B."); IComment reply1 = author2.Comments.AddComment("reply 1 for comment 1", pres.Slides[0], new PointF(10, 10), DateTime.Now); reply1.ParentComment = comment1; // Add reply for comment1 IComment reply2 = author2.Comments.AddComment("reply 2 for comment 1", pres.Slides[0], new PointF(10, 10), DateTime.Now); reply2.ParentComment = comment1; // Add reply to reply IComment subReply = author1.Comments.AddComment("subreply 3 for reply 2", pres.Slides[0], new PointF(10, 10), DateTime.Now); subReply.ParentComment = reply2; IComment comment2 = author2.Comments.AddComment("comment 2", pres.Slides[0], new PointF(10, 10), DateTime.Now); IComment comment3 = author2.Comments.AddComment("comment 3", pres.Slides[0], new PointF(10, 10), DateTime.Now); IComment reply3 = author1.Comments.AddComment("reply 4 for comment 3", pres.Slides[0], new PointF(10, 10), DateTime.Now); reply3.ParentComment = comment3; // Display hierarchy on console ISlide slide = pres.Slides[0]; var comments = slide.GetSlideComments(null); for (int i = 0; i < comments.Length; i++) { IComment comment = comments[i]; while (comment.ParentComment != null) { Console.Write("\t"); comment = comment.ParentComment; } Console.Write("{0} : {1}", comments[i].Author.Name, comments[i].Text); Console.WriteLine(); } pres.Save(dataDir + "parent_comment.pptx", SaveFormat.Pptx); // Remove comment1 and all its replies comment1.Remove(); pres.Save(dataDir + "remove_comment.pptx", SaveFormat.Pptx); } //ExEnd:AddParentComments }
public static void Run() { //ExStart:AddSlideComments // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Slides_Presentations_Comments(); // ExStart:AddSlideComments // Instantiate Presentation class using (Presentation presentation = new Presentation()) { // Adding Empty slide presentation.Slides.AddEmptySlide(presentation.LayoutSlides[0]); // Adding Author ICommentAuthor author = presentation.CommentAuthors.AddAuthor("Jawad", "MF"); // Position of comments PointF point = new PointF(); point.X = 0.2f; point.Y = 0.2f; // Adding slide comment for an author on slide 1 author.Comments.AddComment("Hello Jawad, this is slide comment", presentation.Slides[0], point, DateTime.Now); // Adding slide comment for an author on slide 1 author.Comments.AddComment("Hello Jawad, this is second slide comment", presentation.Slides[1], point, DateTime.Now); // Accessing ISlide 1 ISlide slide = presentation.Slides[0]; // if null is passed as an argument then it will bring comments from all authors on selected slide IComment[] Comments = slide.GetSlideComments(author); // Accessin the comment at index 0 for slide 1 String str = Comments[0].Text; presentation.Save(dataDir + "Comments_out.pptx", SaveFormat.Pptx); if (Comments.GetLength(0) > 0) { // ExEnd:AddSlideComments // Select comments collection of Author at index 0 ICommentCollection commentCollection = Comments[0].Author.Comments; String Comment = commentCollection[0].Text; } } //ExEnd:AddSlideComments }