-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
63 lines (57 loc) · 2 KB
/
Form1.vb
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
Imports DevExpress.XtraRichEdit.API.Native
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Windows.Forms
Namespace DocumentIteratorExample
Partial Public Class Form1
Inherits DevExpress.XtraBars.Ribbon.RibbonForm
Public Sub New()
InitializeComponent()
ribbonControl1.SelectedPage = pageIterator
End Sub
Private Sub btnIteratorRun_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnIteratorRun.ItemClick
' #Region "#runvisitor"
Dim visitor As New MyVisitor()
Dim iterator As New DocumentIterator(richEditControl1.Document, True)
Do While iterator.MoveNext()
iterator.Current.Accept(visitor)
Loop
memoEdit1.Text = visitor.Text
' #End Region ' #runvisitor
End Sub
End Class
#Region "#myvisitorclass"
Public Class MyVisitor
Inherits DocumentVisitorBase
Private ReadOnly buffer_Renamed As StringBuilder
Public Sub New()
Me.buffer_Renamed = New StringBuilder()
End Sub
Protected ReadOnly Property Buffer() As StringBuilder
Get
Return buffer_Renamed
End Get
End Property
Public ReadOnly Property Text() As String
Get
Return ToString()
End Get
End Property
Public Overrides Sub Visit(ByVal text As DocumentText)
Dim prefix As String = If(text.TextProperties.FontBold, "**", "")
Buffer.Append(prefix)
Buffer.Append(text.Text)
Buffer.Append(prefix)
End Sub
Public Overrides Sub Visit(ByVal paragraphEnd As DocumentParagraphEnd)
Buffer.AppendLine()
End Sub
End Class
#End Region ' #myvisitorclass
End Namespace