-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
44 lines (37 loc) · 1.63 KB
/
Form1.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
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.Office.Utils;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
namespace RichEditWatermark {
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1() {
InitializeComponent();
richEditControl1.Text = StringSample.SampleText;
richEditControl1.ActiveView.ZoomFactor = .5f;
}
private void btnTextWatermark_Click(object sender, EventArgs e) {
Section section = richEditControl1.Document.Sections[0];
TextWatermarkOptions options = new TextWatermarkOptions()
{
FontFamily = "Comic Sans MS",
FontSize = 32,
Color = Color.Red,
Layout = WatermarkLayout.Diagonal
};
richEditControl1.Document.WatermarkManager.SetText(section, HeaderFooterType.Primary, "DevExpress XtraRichEdit", options);
}
private void btnImageWatermark_Click(object sender, EventArgs e) {
// Define image watermark options.
var imageWatermarkOptions = new ImageWatermarkOptions
{ Washout = false };
var firstSection = richEditControl1.Document.Sections[0];
// Add an image watermark to the first page header.
firstSection.DifferentFirstPage = true;
richEditControl1.Document.WatermarkManager.SetImage(firstSection, HeaderFooterType.First,
Image.FromFile(System.IO.Directory.GetCurrentDirectory() + @"\..\..\preview.png"), imageWatermarkOptions);
}
}
}