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
        }
Пример #3
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            //Create a PPT document and load file
            Presentation presentation = new Presentation();

            presentation.LoadFromFile(@"..\..\..\..\..\..\Data\AddComment.pptx");

            //Comment author
            ICommentAuthor author = presentation.CommentAuthors.AddAuthor("E-iceblue", "comment:");

            //Add comment
            presentation.Slides[0].AddComment(author, "Add comment", new System.Drawing.PointF(18, 25), DateTime.Now);

            //Save the document
            presentation.SaveToFile("AddComment.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("AddComment.pptx");
        }
Пример #4
0
 // Remove all the comments in the slides by a certain author.
 public static void DeleteCommentsByAuthorInPresentation(string fileName, string author)
 {
     if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(author))
     {
         throw new ArgumentNullException("File name or author name is NULL!");
     }
     //Instantiate a PresentationEx object that represents a PPTX file
     using (Presentation pres = new Presentation(fileName))
     {
         ICommentAuthor[] authors    = pres.CommentAuthors.FindByName(author);
         ICommentAuthor   thisAuthor = authors[0];
         for (int i = thisAuthor.Comments.Count - 1; i >= 0; i--)
         {
             thisAuthor.Comments.RemoveAt(i);
         }
         pres.Save(fileName, Aspose.Slides.Export.SaveFormat.Pptx);
     }
 }
Пример #5
0
        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\..\Sample Files\";
            string FileName = FilePath + "Add a comment to a slide.pptx";

            using (Presentation pres = new Presentation())
            {
                //Adding Empty slide
                pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);

                //Adding Autthor
                ICommentAuthor author = pres.CommentAuthors.AddAuthor("Zeeshan", "MZ");

                //Position of comments

                PointF point = new PointF();
                point.X = 1;
                point.Y = 1;

                //Adding slide comment for an author on slide
                author.Comments.AddComment("Hello Zeeshan, this is slide comment", pres.Slides[0], point, DateTime.Now);
                pres.Save(FileName, Aspose.Slides.Export.SaveFormat.Pptx);
            }
        }