This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
/
Form1.cs
104 lines (79 loc) · 3.79 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
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
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraPrinting;
// ...
namespace MeasureString {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void btn_MeasureString1_Click(object sender, EventArgs e) {
VisualBrick visBrick;
BrickGraphics brickGraph = printingSystem1.Graph;
string s = "Developer Express Inc.";
// Determine the visual dimensions of the string
SizeF sz = brickGraph.MeasureString(s);
// Start the report generation
printingSystem1.Begin();
// Specify a page area
brickGraph.Modifier = BrickModifier.Detail;
// Create a rectangle of the calculated size plus the border dimensions
RectangleF rect = new RectangleF(new PointF(0, 0), sz);
rect = brickGraph.DefaultBrickStyle.InflateBorderWidth(rect, GraphicsDpi.Pixel);
rect.Offset(-rect.X, -rect.Y);
// Add a brick to the report
visBrick = brickGraph.DrawString(s, Color.Black, rect, BorderSide.All);
// Finish the report generation
printingSystem1.End();
// Preview the report
printingSystem1.PreviewFormEx.Show();
}
private void btn_MeasureString2_Click(object sender, EventArgs e) {
VisualBrick visBrick;
BrickGraphics brickGraph = printingSystem1.Graph;
string s = "Developer Express Inc.";
// Measure the string, specifying the maximum width
SizeF sz = brickGraph.MeasureString(s, 75);
// Start the report generation
printingSystem1.Begin();
// Specify a page area
brickGraph.Modifier = BrickModifier.Detail;
// Create a rectangle of the calculated size plus the border dimensions
RectangleF rect = new RectangleF(new PointF(0, 0), sz);
rect = brickGraph.DefaultBrickStyle.InflateBorderWidth(rect, GraphicsDpi.Pixel);
rect.Offset(-rect.X, -rect.Y);
// Add a text brick to the report
visBrick = brickGraph.DrawString(s, Color.Black, rect, BorderSide.All);
// Finish the report generation
printingSystem1.End();
// Preview the report
printingSystem1.PreviewFormEx.Show();
}
private void btn_MeasureString3_Click(object sender, EventArgs e) {
VisualBrick visBrick;
BrickGraphics brickGraph = printingSystem1.Graph;
string s = "Developer Express Inc.";
// Specify the vertical alignment
StringFormat sFormat = new StringFormat(StringFormatFlags.DirectionVertical);
// Measure the string with the specified format and maximum width
SizeF sz = brickGraph.MeasureString(s, 75, sFormat);
// Start the report generation
printingSystem1.Begin();
// Specify a page area
brickGraph.Modifier = BrickModifier.Detail;
// Set default vertical alignment for the text in bricks.
brickGraph.DefaultBrickStyle.StringFormat = new BrickStringFormat(sFormat);
// Create a rectangle of the calculated size plus the border dimensions
RectangleF rect = new RectangleF(new PointF(0, 0), sz);
rect = brickGraph.DefaultBrickStyle.InflateBorderWidth(rect, GraphicsDpi.Pixel);
rect.Offset(-rect.X, -rect.Y);
// Add a text brick to the report
visBrick = brickGraph.DrawString(s, Color.Black, rect, BorderSide.All);
// Finish the report generation
printingSystem1.End();
// Preview the report
printingSystem1.PreviewFormEx.Show();
}
}
}