-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
49 lines (40 loc) · 1.58 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
45
46
47
48
49
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
// ...
namespace DifferentWatermarks {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
// Create a report and assign a watermark to it.
XtraReport1 report = new XtraReport1();
report.Watermark.CopyFrom(CreateTextWatermark("Common Watermark"));
report.CreateDocument();
// Add a custom watermark to the second page.
Page myPage = report.Pages[1];
myPage.AssignWatermark(CreateTextWatermark("Second Page"));
// Remove a watermark from the third page.
myPage = report.Pages[2];
myPage.AssignWatermark(new PageWatermark());
// Show the Print Preview.
report.ShowPreviewDialog();
}
// Create a watermark with the specified text.
private Watermark CreateTextWatermark(string text) {
Watermark textWatermark = new Watermark();
textWatermark.Text = text;
textWatermark.TextDirection = DirectionMode.ForwardDiagonal;
textWatermark.Font = new DXFont(textWatermark.Font.Name, 40);
textWatermark.ForeColor = Color.DodgerBlue;
textWatermark.TextTransparency = 150;
textWatermark.ShowBehind = false;
return textWatermark;
}
}
}