-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCommentsActions.vb
More file actions
117 lines (105 loc) · 6.43 KB
/
CommentsActions.vb
File metadata and controls
117 lines (105 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.XtraRichEdit
Imports System.Diagnostics
Namespace RichEditDocumentServerAPIExample.CodeExamples
Public Class CommentsActions
Public Shared CreateCommentAction As System.Action(Of DevExpress.XtraRichEdit.RichEditDocumentServer) = AddressOf RichEditDocumentServerAPIExample.CodeExamples.CommentsActions.CreateComment
Public Shared CreateNestedCommentAction As System.Action(Of DevExpress.XtraRichEdit.RichEditDocumentServer) = AddressOf RichEditDocumentServerAPIExample.CodeExamples.CommentsActions.CreateNestedComment
Public Shared DeleteCommentAction As System.Action(Of DevExpress.XtraRichEdit.RichEditDocumentServer) = AddressOf RichEditDocumentServerAPIExample.CodeExamples.CommentsActions.DeleteComment
Public Shared EditCommentPropertiesAction As System.Action(Of DevExpress.XtraRichEdit.RichEditDocumentServer) = AddressOf RichEditDocumentServerAPIExample.CodeExamples.CommentsActions.EditCommentProperties
Public Shared EditCommentContentAction As System.Action(Of DevExpress.XtraRichEdit.RichEditDocumentServer) = AddressOf RichEditDocumentServerAPIExample.CodeExamples.CommentsActions.EditCommentContent
Private Shared Sub CreateComment(ByVal wordProcessor As DevExpress.XtraRichEdit.RichEditDocumentServer)
#Region "#CreateComment"
' Load a document from a file.
wordProcessor.LoadDocument("Documents\Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
' Access a document.
Dim document As DevExpress.XtraRichEdit.API.Native.Document = wordProcessor.Document
If document.Paragraphs.Count > 2 Then
' Access the range of the third paragraph.
Dim docRange As DevExpress.XtraRichEdit.API.Native.DocumentRange = document.Paragraphs(CInt((2))).Range
' Specify the comment's author name.
Dim commentAuthor As String = "Johnson Alphonso D"
' Create a comment.
document.Comments.Create(docRange, commentAuthor, System.DateTime.Now)
End If
#End Region ' #CreateComment
End Sub
Private Shared Sub CreateNestedComment(ByVal wordProcessor As DevExpress.XtraRichEdit.RichEditDocumentServer)
#Region "#CreateNestedComment"
' Load a document from a file.
wordProcessor.LoadDocument("Documents\Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
' Access a document.
Dim document As DevExpress.XtraRichEdit.API.Native.Document = wordProcessor.Document
If document.Comments.Count > 1 Then
' Create a new comment nested in the parent comment.
Dim newComment As DevExpress.XtraRichEdit.API.Native.Comment = document.Comments.Create("Vicars Anny", document.Comments(1))
newComment.[Date] = System.DateTime.Now
Dim commentDocument As SubDocument = newComment.BeginUpdate()
commentDocument.InsertText(commentDocument.Range.Start, "I agree")
newComment.EndUpdate(commentDocument)
End If
#End Region ' #CreateNestedComment
End Sub
Private Shared Sub DeleteComment(ByVal wordProcessor As DevExpress.XtraRichEdit.RichEditDocumentServer)
#Region "#DeleteComment"
' Load a document from a file.
wordProcessor.LoadDocument("Documents\Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
' Access a document.
Dim document As DevExpress.XtraRichEdit.API.Native.Document = wordProcessor.Document
If document.Comments.Count > 0 Then
' Delete the first comment.
document.Comments.Remove(document.Comments(0))
End If
#End Region ' #DeleteComment
End Sub
Private Shared Sub EditCommentProperties(ByVal wordProcessor As DevExpress.XtraRichEdit.RichEditDocumentServer)
#Region "#EditCommentProperties"
' Load a document from a file.
wordProcessor.LoadDocument("Documents\Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
' Access a document.
Dim document As DevExpress.XtraRichEdit.API.Native.Document = wordProcessor.Document
Dim commentCount As Integer = document.Comments.Count
If commentCount > 0 Then
' Start to edit the document.
document.BeginUpdate()
' Access a comment and edit its properties.
Dim comment As DevExpress.XtraRichEdit.API.Native.Comment = document.Comments(document.Comments.Count - 1)
comment.Name = "New Name"
comment.[Date] = System.DateTime.Now
comment.Author = "New Author"
' Finalize to edit the document.
document.EndUpdate()
End If
#End Region ' #EditCommentProperties
End Sub
Private Shared Sub EditCommentContent(ByVal wordProcessor As DevExpress.XtraRichEdit.RichEditDocumentServer)
#Region "#EditCommentContent"
' Load a document from a file.
wordProcessor.LoadDocument("Documents\Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
' Access a document.
Dim document As DevExpress.XtraRichEdit.API.Native.Document = wordProcessor.Document
Dim commentCount As Integer = document.Comments.Count
If commentCount > 0 Then
' Access a comment.
Dim comment As DevExpress.XtraRichEdit.API.Native.Comment = document.Comments(document.Comments.Count - 1)
If comment IsNot Nothing Then
' Start to edit the comment.
Dim commentDocument As DevExpress.XtraRichEdit.API.Native.SubDocument = comment.BeginUpdate()
' Insert a text to the comment.
commentDocument.Paragraphs.Insert(commentDocument.Range.Start)
commentDocument.InsertText(commentDocument.Range.Start, "some text")
' Insert a table to the comment.
commentDocument.Tables.Create(commentDocument.Range.End, 5, 4)
' Finalize to edit the comment.
comment.EndUpdate(commentDocument)
End If
End If
#End Region ' #EditCommentContent
End Sub
End Class
End Namespace