This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
57 lines (50 loc) · 2 KB
/
MainWindow.xaml.cs
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
using System;
using System.Windows;
using DevExpress.XtraRichEdit.API.Native;
namespace FieldsExample {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void btnAddField_Click(object sender, RoutedEventArgs e) {
Document document = richEditControl1.Document;
document.Fields.Create(document.CaretPosition, "DATE");
}
private void btnUpdateField_Click(object sender, RoutedEventArgs e) {
if (richEditControl1.Document.Fields.Count > 0)
richEditControl1.Document.Fields.Update();
}
private void btnShowFieldCode_Click(object sender, RoutedEventArgs e) {
if (richEditControl1.Document.Fields.Count > 0)
foreach (Field _f in richEditControl1.Document.Fields){
_f.ShowCodes = true;
}
}
private void btnShowFieldResult_Click(object sender, RoutedEventArgs e) {
if (richEditControl1.Document.Fields.Count > 0)
foreach (Field _f in richEditControl1.Document.Fields){
_f.ShowCodes = false;
}
}
private void btnModifyFieldCode_Click(object sender, RoutedEventArgs e) {
if (richEditControl1.Document.Fields.Count <= 0)
return;
#region #coderange
Document document = richEditControl1.Document;
string fieldCode = document.GetText(document.Fields[0].CodeRange);
if (!fieldCode.Contains("\\@")) {
DocumentPosition position = document.Fields[0].CodeRange.End;
document.InsertText(position, @"\@ ""MMMM""");
document.Fields[0].ShowCodes = true;
}
#endregion #coderange
}
private void btnCreateFieldFromSelection_Click(object sender, RoutedEventArgs e) {
Document document = richEditControl1.Document;
document.Fields.Create(document.Selection);
}
}
}