-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathXRSwissQRBill.cs
345 lines (305 loc) · 17.4 KB
/
XRSwissQRBill.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
using System.ComponentModel;
using System.Drawing;
using DevExpress.Utils.Serializing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Expressions;
using DevExpress.Utils.Design;
using DevExpress.XtraReports.UserDesigner;
using DevExpress.XtraPrinting.BarCode;
using System.Linq;
using System.Diagnostics;
using System;
using DevExpress.Utils;
using DevExpress.Drawing;
namespace DevExpress.XtraReports.CustomControls.SwissQRBill {
[ToolboxItem(true)]
[ToolboxSvgImage("DevExpress.XtraReports.CustomControls.SwissQRBill.Resources.SwissQRBillToolboxSvgImage.svg,DevExpress.XtraReports.CustomControls.SwissQRBill")]
[XRDesigner("DevExpress.XtraReports.CustomControls.Design.SwissQRBill.XRSwissQRBillDesigner, DevExpress.XtraReports.CustomControls.Design")]
[Designer("DevExpress.XtraReports.CustomControls.Design.SwissQRBill._XRSwissQRBillDesigner, DevExpress.XtraReports.CustomControls.Design")]
[XRToolboxSubcategory(0, 7)]
[DefaultBindableProperty(nameof(StringData))]
#if NET452
[ToolboxBitmap("DevExpress.XtraReports.CustomControls.SwissQRBill.Resources.SwissQRBillToolboxImage.bmp,DevExpress.XtraReports.CustomControls.SwissQRBill")]
#endif
public partial class XRSwissQRBill : XRControl {
public static readonly SizeF InitSizeF = new SizeF(845, 458);
QRBillDataItem qrBillDataItem = new QRBillDataItem();
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string Text { get => base.Text; set => base.Text = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string TextFormatString { get => base.TextFormatString; set => base.TextFormatString = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string XlsxFormatString { get => base.XlsxFormatString; set => base.XlsxFormatString = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override bool WordWrap { get => base.WordWrap; set => base.WordWrap = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override bool KeepTogether { get => base.KeepTogether; set => base.KeepTogether = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override HorizontalAnchorStyles AnchorHorizontal { get => base.AnchorHorizontal; set => base.AnchorHorizontal = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override VerticalAnchorStyles AnchorVertical { get => base.AnchorVertical; set => base.AnchorVertical = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override bool CanPublish { get => base.CanPublish; set => base.CanPublish = value; }
//Apperance
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Color BackColor { get => base.BackColor; set => base.BackColor = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Color BorderColor { get => base.BorderColor; set => base.BorderColor = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override BorderDashStyle BorderDashStyle { get => base.BorderDashStyle; set => base.BorderDashStyle = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override float BorderWidth { get => base.BorderWidth; set => base.BorderWidth = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override BorderSide Borders { get => base.Borders; set => base.Borders = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override DXFont Font { get => base.Font; set => base.Font = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Color ForeColor { get => base.ForeColor; set => base.ForeColor = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override PaddingInfo Padding { get => base.Padding; set => base.Padding = value; }
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override StylePriority StylePriority => base.StylePriority;
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override XRControlStyles Styles => base.Styles;
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override TextAlignment TextAlignment { get => base.TextAlignment; set => base.TextAlignment = value; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event BindingEventHandler EvaluateBinding { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event PrintOnPageEventHandler PrintOnPage { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event PreviewMouseEventHandler PreviewMouseMove { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event PreviewMouseEventHandler PreviewMouseDown { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event PreviewMouseEventHandler PreviewMouseUp { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event PreviewMouseEventHandler PreviewClick { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event PreviewMouseEventHandler PreviewDoubleClick { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event DrawEventHandler Draw { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event HtmlEventHandler HtmlItemCreated { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event EventHandler TextChanged { add { } remove { } }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override event UI.ChangeEventHandler SizeChanged { add { } remove { } }
[DXDescription("Swiss QR Bill Scripts description"),
DisplayName("Swiss QR Bill Scripts"),
Category("Behavior"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
XtraSerializableProperty(XtraSerializationVisibility.Content)]
public new XRSwissQRBillScripts Scripts { get { return (XRSwissQRBillScripts)fEventScripts; } }
[DisplayName("Bill Kind")]
[Description("Bill Kind description")]
[Category("Data")]
[XtraSerializableProperty]
[RefreshProperties(RefreshProperties.All)]
[DefaultValue(QRBillKind.PaymentAndReceipt)]
public QRBillKind BillKind { get; set; } = QRBillKind.PaymentAndReceipt;
public override RectangleF BoundsF {
get { return AdaptBounds(base.BoundsF); }
set { base.BoundsF = value; }
}
RectangleF AdaptBounds(RectangleF rect) {
if(RootReport != null) {
rect.Size = GraphicsUnitConverter.Convert(GetActualSize(), GraphicsDpi.Millimeter, Dpi);
}
return rect;
}
[DisplayName("String Data")]
[Description("String Data description")]
[Category("Data")]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[Editor(ControlConstants.MultilineStringEditor, ControlConstants.UITypeEditor)]
public string StringData {
get { return qrBillDataItem.QRCodeData; }
set { qrBillDataItem.QRCodeData = value; }
}
bool ShouldSerializeStringData() => false;
[DisplayName("Bill Options")]
[Description("Bill Options description")]
[Category("Data")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
public BillOptions BillOptions { get; } = new BillOptions();
[DisplayName("Creditor Information")]
[Description("Creditor Information description")]
[Category("Data")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
public Address CreditorInformation { get { return qrBillDataItem.CreditorInformation; } }
[DisplayName("Creditor IBAN")]
[Description("Creditor IBAN description")]
[Category("Data")]
[XtraSerializableProperty]
public string CreditorIBAN {
get { return qrBillDataItem.CreditorAccountNumber.Number; }
set { qrBillDataItem.CreditorAccountNumber.Number = value; }
}
[DisplayName("Reference")]
[Description("Reference description")]
[Category("Data")]
[XtraSerializableProperty]
public string Reference {
get { return qrBillDataItem.Reference.Number; }
set { qrBillDataItem.Reference.Number = value; }
}
[DisplayName("Debtor Information")]
[Description("Debtor Information description")]
[Category("Data")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
public Address DebtorInformation { get { return qrBillDataItem.DebtorInformation; } }
[DisplayName("Amount")]
[Description("Amount description")]
[Category("Data")]
[DefaultValue(null)]
[XtraSerializableProperty]
public double? Amount {
get { return qrBillDataItem.Amount; }
set { qrBillDataItem.Amount = value; }
}
[DisplayName("Currency")]
[Description("Currency description")]
[Category("Data")]
[DefaultValue(Currency.CHF)]
[XtraSerializableProperty]
public Currency Currency {
get { return qrBillDataItem.Currency; }
set { qrBillDataItem.Currency = value; }
}
[DisplayName("Additional Information")]
[Description("Additional Information description")]
[Category("Data")]
[DefaultValue("")]
[XtraSerializableProperty]
public string AdditionalInformation {
get { return qrBillDataItem.AdditionalInformation; }
set { qrBillDataItem.AdditionalInformation = value; }
}
[DisplayName("Structured Information")]
[Description("Structured Information description")]
[Category("Data")]
[DefaultValue("")]
[XtraSerializableProperty]
public string StructuredInformation {
get { return qrBillDataItem.StructuredInformation; }
set { qrBillDataItem.StructuredInformation = value; }
}
[DisplayName("Alternative Procedures")]
[Description("Alternative Procedures description")]
[Category("Data")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
public AlternativeProcedures AlternativeProcedures {
get { return qrBillDataItem.AlternativeProcedures; }
}
static XRSwissQRBill() {
ExpressionBindingDescriptor.SetPropertyDescription(typeof(XRSwissQRBill), nameof(StringData), new ExpressionBindingDescription(new string[] { "BeforePrint" }, 1000, new string[0]));
ValidateIncludeQuietZone();
}
static void ValidateIncludeQuietZone() {
var includeQuietZoneProperty = typeof(QRCodeGenerator).GetProperties().FirstOrDefault(a => a.Name == "IncludeQuietZone");
if(includeQuietZoneProperty == null)
Debug.Fail("IncludeQuietZone property is not available. The control may not draw correctly");
}
public XRSwissQRBill() {
}
protected override XRControlScripts CreateScripts() {
return new XRSwissQRBillScripts(this);
}
protected override int DefaultHeight => ConvertFromMMToDpi(Constants.PaymentAndReceiptBounds.Height, GraphicsDpi.HundredthsOfAnInch);
protected override int DefaultWidth => ConvertFromMMToDpi(Constants.PaymentAndReceiptBounds.Width, GraphicsDpi.HundredthsOfAnInch);
int ConvertFromMMToDpi(float mmValue, float targetDpi) {
return (int)GraphicsUnitConverter.Convert(mmValue, GraphicsDpi.Millimeter, targetDpi);
}
SizeF GetActualSize() {
RectangleF actualRect = BillKind == QRBillKind.PaymentOnly ? Constants.PaymentBounds : Constants.PaymentAndReceiptBounds;
if(BillOptions.IntegratedMode)
actualRect.Height += Constants.IntegratedModeOffset;
return actualRect.Size;
}
protected override VisualBrick CreateBrick(VisualBrick[] childrenBricks) {
return new SwissQRBillBrick(this);
}
protected override void PutStateToBrick(VisualBrick brick, PrintingSystemBase ps) {
base.PutStateToBrick(brick, ps);
SwissQRBillBrick swissQRBillBrick = brick as SwissQRBillBrick;
swissQRBillBrick.BillKind = BillKind;
swissQRBillBrick.BillOptions.Assign(BillOptions);
swissQRBillBrick.GenerateContent(qrBillDataItem);
foreach(var innerBrick in swissQRBillBrick.Bricks) {
InitializeInnerBrick(innerBrick, ps);
}
}
void InitializeInnerBrick(Brick brick, PrintingSystemBase ps) {
foreach(var innerBrick in brick.Bricks) {
InitializeInnerBrick(innerBrick, ps);
}
brick.Initialize(ps, brick.Rect);
}
protected override void GetStateFromBrick(VisualBrick brick) {
base.GetStateFromBrick(brick);
}
}
}