コード例 #1
0
        private void EditComment()
        {
            #region #EditCommentContent
            Document document = richEditControl.Document;

            int commentCount = document.Comments.Count;
            if (commentCount > 0)
            {
                //The target comment is the first one
                Comment comment = document.Comments[0];
                if (comment != null)
                {
                    //Open the comment for modification
                    SubDocument commentDocument = comment.BeginUpdate();

                    //Add text to the comment range
                    commentDocument.InsertText(commentDocument.CreatePosition(0),
                                               "J. Taylor, Enabling Voice - over - IP and RAID with sofa,  in Proceedings of NOSSDAV, Oct. 1994.\r\n" +
                                               @"R.Tarjan, S.Shenker, J.Gray, A.Einstein, Q.Thomas, and X.Sato, ""Deconstructing operating systems with flanchedripper"", in Proceedings of INFOCOM, Mar. 2000.");

                    //End the comment update
                    comment.EndUpdate(commentDocument);
                }
            }
            #endregion #EditCommentContent
        }
コード例 #2
0
        static void SelectCellsAndSplit(Document document)
        {
            #region #SelectCellsAndSplit
            document.LoadDocument("Documents//SelectionCollection.docx", DocumentFormat.OpenXml);
            Table            rootTable  = document.Tables[0];
            DocumentPosition position10 = rootTable.Rows[0].Cells[1].Range.Start;
            DocumentPosition position11 = rootTable.Rows[3].LastCell.Range.End;

            DocumentRange range1 = document.CreateRange(position10, position11.ToInt() - position10.ToInt());
            document.Selections.Add(range1);

            Comment     comment    = document.Comments.Create(document.Selection, "");
            SubDocument commentDoc = comment.BeginUpdate();
            commentDoc.AppendText(String.Format("\r\nSelectionCollection \r\ncontains {0} item(s).", document.Selections.Count));
            comment.EndUpdate(commentDoc);
            #endregion #SelectCellsAndSplit
        }
コード例 #3
0
        private void InsertNestedComment()
        {
            #region #NestedComment
            Document document = richEditControl.Document;


            if (document.Comments.Count > 0)
            {
                //Create a new comment nested to the second comment in the collection
                Comment nestedComment = document.Comments.Create("Brian Zetc", DateTime.Now, document.Comments[1]);

                //Add text to the newly created comment
                SubDocument   nestedCommentDocument = nestedComment.BeginUpdate();
                DocumentRange textRange             = nestedCommentDocument.InsertText(nestedCommentDocument.CreatePosition(0),
                                                                                       "Suffix trees are comprehensively reviewed in Wikipedia");
                nestedComment.EndUpdate(nestedCommentDocument);
            }
            #endregion #NestedComment
        }
 void EditCommentContent(RichEditDocumentServer server)
 {
     #region #EditCommentContent
     Document document = server.Document;
     document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
     int commentCount = document.Comments.Count;
     if (commentCount > 0)
     {
         Comment comment = document.Comments[document.Comments.Count - 1];
         if (comment != null)
         {
             SubDocument commentDocument = comment.BeginUpdate();
             commentDocument.InsertText(commentDocument.CreatePosition(0), "some text");
             commentDocument.Tables.Create(commentDocument.CreatePosition(9), 5, 4);
             comment.EndUpdate(commentDocument);
         }
     }
     #endregion #EditCommentContent
 }
コード例 #5
0
        static void SelectAndMerge(Document document)
        {
            #region #SelectAndMerge
            document.LoadDocument("Documents//SelectionCollection.docx", DocumentFormat.OpenXml);
            DocumentRange range1 = document.CreateRange(document.Range.Start, 12);
            DocumentRange range2 = document.CreateRange(document.Range.Start.ToInt() + 12, 9);
            DocumentRange range3 = document.CreateRange(document.Range.Start.ToInt() + 21, 3);

            List <DocumentRange> ranges = new List <DocumentRange>()
            {
                range1, range2
            };
            document.Selections.Add(ranges);

            Comment     comment    = document.Comments.Create(document.Selection, "");
            SubDocument commentDoc = comment.BeginUpdate();
            commentDoc.AppendText(String.Format("\r\nSelectionCollection \r\ncontains {0} item(s).", document.Selections.Count));
            comment.EndUpdate(commentDoc);
            #endregion #SelectAndMerge
        }