This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
60 lines (51 loc) · 2.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
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
#Region "#usings"
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.XtraRichEdit.Layout.Export
Imports System.Drawing.Drawing2D
#End Region ' #usings
Namespace CustomMarks
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
richEditControl1.LoadDocument("Search.rtf")
End Sub
#Region "#custommark"
Private Sub btn_Mark_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_Mark.Click
Dim doc As Document = richEditControl1.Document
Dim m As CustomMark = doc.CustomMarks.Create(doc.Selection.Start, Color.DarkOrange)
End Sub
Private Sub richEditControl1_CustomMarkDraw(ByVal sender As Object, ByVal e As RichEditCustomMarkDrawEventArgs) Handles richEditControl1.CustomMarkDraw
For Each info As CustomMarkVisualInfo In e.VisualInfoCollection
Dim doc As Document = richEditControl1.Document
Dim mark As CustomMark = doc.CustomMarks.GetByVisualInfo(info)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Dim curColor As Color = CType(info.UserData, Color)
If mark.Position < doc.Selection.Start Then
curColor = Color.Green
End If
Using p As New Pen(curColor, 3)
p.StartCap = LineCap.Flat
p.EndCap = LineCap.ArrowAnchor
e.Graphics.DrawLine(p, New Point(0, info.Bounds.Y), info.Bounds.Location)
End Using
Next info
End Sub
#End Region ' #custommark
Private Sub btn_DeleteMarks_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_DeleteMarks.Click
Dim doc As Document = richEditControl1.Document
Dim i As Integer = 0
Do While i < doc.CustomMarks.Count
doc.CustomMarks.Remove(doc.CustomMarks(i))
Loop
End Sub
End Class
End Namespace