This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
CustomLink.cs
118 lines (100 loc) · 4.75 KB
/
CustomLink.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraPrinting;
// ...
namespace CustomLink_ListView {
public class ListLink : Link {
private ListView listView = null;
public ListView ListViewControl {
get { return listView; }
set { listView = value; }
}
public ListLink(System.ComponentModel.IContainer container)
: base(container) {
}
public ListLink()
: base() {
}
public ListLink(PrintingSystem ps)
: base(ps) {
}
public override void CreateDocument(PrintingSystem ps) {
if (listView == null) return;
if (listView.Items.Count == 0) return;
BrickGraphics gr = ps.Graph;
base.CreateDocument(ps);
}
protected override void CreateMarginalHeader(BrickGraphics gr) {
gr.Modifier = BrickModifier.MarginalHeader;
string format = "Printed on {0:MMMM, dd}";
PageInfoBrick brick = gr.DrawPageInfo(PageInfo.DateTime, format, Color.Black,
new RectangleF(0, 0, 0, 20), BorderSide.None);
brick.Alignment = BrickAlignment.Far;
brick.AutoWidth = true;
}
protected override void CreateReportHeader(BrickGraphics gr) {
gr.Modifier = BrickModifier.ReportHeader;
TextBrick textBrick;
gr.BackColor = Color.White;
gr.StringFormat =
new BrickStringFormat(StringFormatFlags.NoWrap | StringFormatFlags.LineLimit);
gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Center);
Rectangle r = new Rectangle(0, 0, 200, 30);
gr.Font = new Font("Arial", 16);
textBrick = gr.DrawString("ListView Report", Color.Red, r, BorderSide.None);
textBrick.StringFormat.ChangeAlignment(StringAlignment.Center);
}
protected override void CreateDetailHeader(BrickGraphics gr) {
if (listView.View != View.Details)
return;
gr.Modifier = BrickModifier.DetailHeader;
gr.Font = listView.Font;
gr.BackColor = SystemColors.Control;
gr.ForeColor = SystemColors.ControlText;
gr.StringFormat = new BrickStringFormat(StringFormatFlags.NoWrap);
gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Near);
gr.DrawString("Name", gr.ForeColor, listView.Items[0].Bounds, BorderSide.All);
}
protected override void CreateDetail(BrickGraphics gr) {
gr.StringFormat =
new BrickStringFormat(StringFormatFlags.NoWrap | StringFormatFlags.LineLimit);
gr.StringFormat = gr.StringFormat.ChangeLineAlignment(StringAlignment.Near);
for (int i = 0; i < listView.Items.Count; i++) {
gr.Font = listView.Items[i].Font;
gr.BackColor = listView.Items[i].BackColor;
gr.ForeColor = listView.Items[i].ForeColor;
gr.DrawString(listView.Items[i].Text, gr.ForeColor, listView.Items[i].Bounds,
BorderSide.None);
}
}
protected override void CreateDetailFooter(BrickGraphics gr) {
gr.Modifier = BrickModifier.DetailFooter;
gr.Font = listView.Font;
gr.BackColor = SystemColors.Control;
gr.ForeColor = SystemColors.ControlText;
gr.StringFormat = new BrickStringFormat(StringFormatFlags.NoWrap);
gr.StringFormat = gr.StringFormat.ChangeAlignment(StringAlignment.Far);
gr.DrawString("Total Items: " + Convert.ToString(listView.Items.Count), gr.ForeColor,
new Rectangle(0, 0, 60 + listView.Items[0].Bounds.Width, listView.Items[0].Bounds.Height),
BorderSide.All);
}
protected override void CreateMarginalFooter(BrickGraphics gr) {
gr.Modifier = BrickModifier.MarginalFooter;
string format = "Page {0} of {1}";
PageInfoBrick brick = gr.DrawPageInfo(PageInfo.NumberOfTotal, format, Color.Black,
new RectangleF(0, 0, 0, 20), BorderSide.None);
brick.Alignment = BrickAlignment.Far;
brick.AutoWidth = true;
}
protected override void CreateReportFooter(BrickGraphics gr) {
gr.Modifier = BrickModifier.ReportFooter;
gr.StringFormat =
new BrickStringFormat(StringFormatFlags.NoWrap | StringFormatFlags.LineLimit);
gr.StringFormat = gr.StringFormat.ChangeLineAlignment(StringAlignment.Far);
gr.Font = listView.Font;
gr.DrawString("Created by John Smith", gr.ForeColor,
new Rectangle(0, 0, 200, 30), BorderSide.None);
}
}
}