-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.cs
746 lines (621 loc) · 23.7 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
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
#region #Usings
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
// ...
#endregion #Usings
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private enum BarCodeTypes {
Codabar, Code11, Code39, Code39Extended, Code93, Code93Extended, Code128, EAN8, EAN13,
GS1128, GS1DataBar, DataMatrix, DataMatrixGS1, Industrial2of5, IntelligentMail,
IntelligentMailPackage, Interleaved2of5, Matrix2of5, CodeMSI, PDF417, PostNet, QRCode, UPCA,
UPCE0, UPCE1, UPCSupplemental2, UPCSupplemental5, UPCShippingContainer
};
#region #DataSource
private class BarCode {
public BarCodeTypes Type { get; set; }
public string DisplayName { get; set; }
public BarCode(BarCodeTypes BarCodeType, string BarCodeName) {
Type = BarCodeType;
DisplayName = BarCodeName;
}
}
private List<BarCode> MakeBarCodesList() {
List<BarCode> list = new List<BarCode>();
list.Add(new BarCode(BarCodeTypes.Codabar, "Codabar"));
list.Add(new BarCode(BarCodeTypes.Code11, "Code 11 (USD-8)"));
list.Add(new BarCode(BarCodeTypes.Code39, "Code 39 (USD-3)"));
list.Add(new BarCode(BarCodeTypes.Code39Extended, "Code 39 Extended"));
list.Add(new BarCode(BarCodeTypes.Code93, "Code 93"));
list.Add(new BarCode(BarCodeTypes.Code93Extended, "Code 93 Extended"));
list.Add(new BarCode(BarCodeTypes.Code128, "Code 128"));
list.Add(new BarCode(BarCodeTypes.EAN8, "EAN 8"));
list.Add(new BarCode(BarCodeTypes.EAN13, "EAN 13"));
list.Add(new BarCode(BarCodeTypes.GS1128, "GS1-128 - EAN-128 (UCC)"));
list.Add(new BarCode(BarCodeTypes.GS1DataBar, "GS1 DataBar"));
list.Add(new BarCode(BarCodeTypes.DataMatrix, "Data Matrix (ECC200)"));
list.Add(new BarCode(BarCodeTypes.DataMatrixGS1, "Data Matrix (GS1)"));
list.Add(new BarCode(BarCodeTypes.Industrial2of5, "Industrial 2 of 5"));
list.Add(new BarCode(BarCodeTypes.IntelligentMail, "Intelligent Mail"));
list.Add(new BarCode(BarCodeTypes.IntelligentMailPackage, "Intelligent Mail Package"));
list.Add(new BarCode(BarCodeTypes.Interleaved2of5, "Interleaved 2 of 5"));
list.Add(new BarCode(BarCodeTypes.Matrix2of5, "Matrix 2 of 5"));
list.Add(new BarCode(BarCodeTypes.CodeMSI, "MSI/Plessey"));
list.Add(new BarCode(BarCodeTypes.PDF417, "PDF417"));
list.Add(new BarCode(BarCodeTypes.PostNet, "PostNet"));
list.Add(new BarCode(BarCodeTypes.QRCode, "QR Code"));
list.Add(new BarCode(BarCodeTypes.UPCA, "UPC-A"));
list.Add(new BarCode(BarCodeTypes.UPCE0, "UPC-E0"));
list.Add(new BarCode(BarCodeTypes.UPCE1, "UPC-E1"));
list.Add(new BarCode(BarCodeTypes.UPCSupplemental2, "UPC Supplemental 2"));
list.Add(new BarCode(BarCodeTypes.UPCShippingContainer, "UPC Shipping Container Symbol (ITF-14)"));
return list;
}
#endregion #DataSource
#region #Codabar
public XRBarCode CreateCodabarBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Codabar
barCode.Symbology = new CodabarGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 300;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((CodabarGenerator)barCode.Symbology).StartStopPair = CodabarStartStopPair.BN;
((CodabarGenerator)barCode.Symbology).WideNarrowRatio = 2.5F;
return barCode;
}
#endregion #Codabar
#region #Code11
public XRBarCode CreateCode11BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Code 11.
barCode.Symbology = new Code11Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
return barCode;
}
#endregion #Code11
#region #Code39
public XRBarCode CreateCode39BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Code 39.
barCode.Symbology = new Code39Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Code39Generator)barCode.Symbology).CalcCheckSum = false;
((Code39Generator)barCode.Symbology).WideNarrowRatio = 2.5F;
return barCode;
}
#endregion #Code39
#region #Code39Extended
public XRBarCode CreateCode39ExBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Code 39 Extended.
barCode.Symbology = new Code39ExtendedGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Code39ExtendedGenerator)barCode.Symbology).CalcCheckSum = false;
((Code39ExtendedGenerator)barCode.Symbology).WideNarrowRatio = 2.5F;
return barCode;
}
#endregion #Code39Extended
#region #Code93
public XRBarCode CreateCode93BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Code 93.
barCode.Symbology = new Code93Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Code93Generator)barCode.Symbology).CalcCheckSum = false;
return barCode;
}
#endregion #Code93
#region #Code93Extended
public XRBarCode CreateCode93ExBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Code 93 Extended.
barCode.Symbology = new Code93ExtendedGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Code93ExtendedGenerator)barCode.Symbology).CalcCheckSum = false;
return barCode;
}
#endregion #Code93Extended
#region #Code128
public XRBarCode CreateCode128BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Code 128.
barCode.Symbology = new Code128Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Code128Generator)barCode.Symbology).CharacterSet = Code128Charset.CharsetB;
return barCode;
}
#endregion #Code128
#region #EAN8
public XRBarCode CreateEAN8BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to EAN 8.
barCode.Symbology = new EAN8Generator();
// Adjust the barcode's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
return barCode;
}
#endregion #EAN8
#region #EAN13
public XRBarCode CreateEAN13BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to EAN 13.
barCode.Symbology = new EAN13Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 275;
barCode.Height = 200;
return barCode;
}
#endregion #EAN13
#region #GS1-128-EAN128
public XRBarCode CreateGS1128BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to EAN 128.
barCode.Symbology = new EAN128Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((EAN128Generator)barCode.Symbology).CharacterSet = Code128Charset.CharsetB;
return barCode;
}
#endregion #GS1-128-EAN128
#region #GS1-DataBar
public XRBarCode CreateDataBarGS1BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to GS1 DataBar.
barCode.Symbology = new DataBarGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 250;
barCode.Height = 160;
// Adjust the properties specific to the bar code type.
((DataBarGenerator)barCode.Symbology).FNC1Substitute = "#";
((DataBarGenerator)barCode.Symbology).SegmentsInRow = 4;
((DataBarGenerator)barCode.Symbology).Type = DataBarType.ExpandedStacked;
return barCode;
}
#endregion #GS1-DataBar
#region #DataMatrixECC200
public XRBarCode CreateDataMatrixBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to DataMatrix.
barCode.Symbology = new DataMatrixGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 150;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
//barcode.Module = 3;
// Adjust the properties specific to the bar code type.
((DataMatrixGenerator)barCode.Symbology).CompactionMode = DataMatrixCompactionMode.Text;
((DataMatrixGenerator)barCode.Symbology).MatrixSize = DataMatrixSize.MatrixAuto;
return barCode;
}
#endregion #DataMatrixECC200
#region #DataMatrixGS1
public XRBarCode CreateDataMatrixGS1BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Data Matrix GS1.
barCode.Symbology = new DataMatrixGS1Generator();
// Adjust the bar code's main properties.
barCode.AutoModule = true;
barCode.Text = BarCodeText;
barCode.ShowText = true;
barCode.Width = 200;
barCode.Height = 200;
// Adjust the properties specific to the bar code type.
// (Assigned below are the default values.)
((DataMatrixGS1Generator)barCode.Symbology).FNC1Substitute = "#";
((DataMatrixGS1Generator)barCode.Symbology).HumanReadableText = true;
((DataMatrixGS1Generator)barCode.Symbology).MatrixSize = DataMatrixSize.MatrixAuto;
return barCode;
}
#endregion #DataMatrixGS1
#region #Industrial2of5
public XRBarCode CreateIndustrial2of5BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Industrial 2 of 5.
barCode.Symbology = new Industrial2of5Generator();
// Adjust the main properties of the bar code.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Industrial2of5Generator)barCode.Symbology).CalcCheckSum = false;
((Industrial2of5Generator)barCode.Symbology).WideNarrowRatio = 3;
return barCode;
}
#endregion #Industrial2of5
#region #IntelligentMail
public XRBarCode CreateIntelligentMailBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Intelligent Mail.
barCode.Symbology = new IntelligentMailGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.ShowText = true;
barCode.WidthF = 300f;
barCode.HeightF = 50f;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
//barcode.Module = 3;
return barCode;
}
#endregion #IntelligentMail
#region #IntelligentMailPackage
public XRBarCode CreateIntelligentMailPackageBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Intelligent Mail Package.
barCode.Symbology = new IntelligentMailPackageGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.ShowText = false;
barCode.WidthF = 300;
barCode.HeightF = 150f;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
//barcode.Module = 3;
// Adjust the property specific to the bar code type.
// (Assigned below is the default value.)
((IntelligentMailPackageGenerator)barCode.Symbology).FNC1Substitute = "#";
return barCode;
}
#endregion #IntelligentMailPackage
#region #Interleaved2of5
public XRBarCode CreateInterleaved2of5BarCode(string BarCodeText) {
// Create a bar code controle.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Interleaved 2 of 5.
barCode.Symbology = new Interleaved2of5Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Interleaved2of5Generator)barCode.Symbology).CalcCheckSum = false;
((Interleaved2of5Generator)barCode.Symbology).WideNarrowRatio = 3;
return barCode;
}
#endregion #Interleaved2of5
#region #Matrix2of5
public XRBarCode CreateMatrix2of5BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Matrix 2 of 5.
barCode.Symbology = new Matrix2of5Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((Matrix2of5Generator)barCode.Symbology).CalcCheckSum = false;
((Matrix2of5Generator)barCode.Symbology).WideNarrowRatio = 3;
return barCode;
}
#endregion #Matrix2of5
#region #MSI-Plessey
public XRBarCode CreateCodeMSIBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to MSI.
barCode.Symbology = new CodeMSIGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((CodeMSIGenerator)barCode.Symbology).MSICheckSum = MSICheckSum.DoubleModulo10;
return barCode;
}
#endregion #MSI-Plessey
#region #PDF417
public XRBarCode CreatePDF417BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to PDF417.
barCode.Symbology = new PDF417Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 150;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
//barcode.Module = 3;
// Adjust the properties specific to the bar code type.
((PDF417Generator)barCode.Symbology).Columns = 1;
((PDF417Generator)barCode.Symbology).CompactionMode = PDF417CompactionMode.Text;
((PDF417Generator)barCode.Symbology).ErrorCorrectionLevel = ErrorCorrectionLevel.Level2;
((PDF417Generator)barCode.Symbology).Rows = 9;
((PDF417Generator)barCode.Symbology).TruncateSymbol = false;
((PDF417Generator)barCode.Symbology).YToXRatio = 3;
return barCode;
}
#endregion #PDF417
#region #PostNet
public XRBarCode CreatePostNetBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to PostNet.
barCode.Symbology = new PostNetGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
return barCode;
}
#endregion #PostNet
#region #QRCode
public XRBarCode CreateQRCodeBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to QRCode.
barCode.Symbology = new QRCodeGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 150;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
// barcode.Module = 3;
// Adjust the properties specific to the bar code type.
((QRCodeGenerator)barCode.Symbology).CompactionMode = QRCodeCompactionMode.AlphaNumeric;
((QRCodeGenerator)barCode.Symbology).ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
((QRCodeGenerator)barCode.Symbology).Version = QRCodeVersion.AutoVersion;
return barCode;
}
#endregion #QRCode
#region #UPC-A
public XRBarCode CreateUPCABarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to UPC-A.
barCode.Symbology = new UPCAGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 275;
barCode.Height = 200;
return barCode;
}
#endregion #UPC-A
#region #UPC-E0
public XRBarCode CreateUPCE0BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to UPC-E0.
barCode.Symbology = new UPCE0Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
return barCode;
}
#endregion #UPC-E0
#region #UPC-E1
public XRBarCode CreateUPCE1BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to UPC-E1.
barCode.Symbology = new UPCE1Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 100;
return barCode;
}
#endregion #UPC-E1
#region #UPCSupplemental2
public XRBarCode CreateUPCSupplemental2BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to UPC Supplemental 2.
barCode.Symbology = new UPCSupplemental2Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 100;
barCode.Height = 55;
return barCode;
}
#endregion #UPCSupplemental2
#region #UPCSupplemental5
public XRBarCode CreateUPCSupplemental5BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to UPC Supplemental 5.
barCode.Symbology = new UPCSupplemental5Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 150;
barCode.Height = 55;
return barCode;
}
#endregion #UPCSupplemental5
#region #UPCShippingContainer
public XRBarCode CreateITF14BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the barcode's type to ITF-14.
barCode.Symbology = new ITF14Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 350;
barCode.Height = 100;
// Adjust the properties specific to the bar code type.
((ITF14Generator)barCode.Symbology).CalcCheckSum = false;
((ITF14Generator)barCode.Symbology).WideNarrowRatio = 2.5f;
return barCode;
}
#endregion #UPCShippingContainer
#region #CreateBarCode
private XRBarCode CreateBarCode(BarCodeTypes Type) {
XRBarCode barCode = null;
switch (Type) {
case BarCodeTypes.Codabar:
barCode = CreateCodabarBarCode("0123-456789");
break;
case BarCodeTypes.Code11:
barCode = CreateCode11BarCode("0123-456789");
break;
case BarCodeTypes.Code39:
barCode = CreateCode39BarCode("01234-ABCD");
break;
case BarCodeTypes.Code39Extended:
barCode = CreateCode39ExBarCode("012-Abc");
break;
case BarCodeTypes.Code93:
barCode = CreateCode93BarCode("01234-ABCD");
break;
case BarCodeTypes.Code93Extended:
barCode = CreateCode93ExBarCode("012-Abc");
break;
case BarCodeTypes.Code128:
barCode = CreateCode128BarCode("01234-ABcd");
break;
case BarCodeTypes.EAN8:
barCode = CreateEAN8BarCode("01234567");
break;
case BarCodeTypes.EAN13:
barCode = CreateEAN13BarCode("0123456789");
break;
case BarCodeTypes.GS1128:
barCode = CreateGS1128BarCode("01234-Abcd");
break;
case BarCodeTypes.GS1DataBar:
barCode = CreateDataBarGS1BarCode("01906141410000153202000150");
break;
case BarCodeTypes.DataMatrix:
barCode = CreateDataMatrixBarCode("01234-ABCD");
break;
case BarCodeTypes.DataMatrixGS1:
barCode = CreateDataMatrixGS1BarCode("01234-ABCD");
break;
case BarCodeTypes.Industrial2of5:
barCode = CreateIndustrial2of5BarCode("0123456789");
break;
case BarCodeTypes.IntelligentMail:
barCode = CreateIntelligentMailBarCode("4408200000012345678991203");
break;
case BarCodeTypes.IntelligentMailPackage:
barCode = CreateIntelligentMailPackageBarCode("9212391234567812345671");
break;
case BarCodeTypes.Interleaved2of5:
barCode = CreateInterleaved2of5BarCode("0123456789");
break;
case BarCodeTypes.Matrix2of5:
barCode = CreateMatrix2of5BarCode("0123456789");
break;
case BarCodeTypes.CodeMSI:
barCode = CreateCodeMSIBarCode("0123456789");
break;
case BarCodeTypes.PDF417:
barCode = CreatePDF417BarCode("01234-ABCD");
break;
case BarCodeTypes.PostNet:
barCode = CreatePostNetBarCode("0123456789");
break;
case BarCodeTypes.QRCode:
barCode = CreateQRCodeBarCode("01234-ABCD");
break;
case BarCodeTypes.UPCA:
barCode = CreateUPCABarCode("00123456789");
break;
case BarCodeTypes.UPCE0:
barCode = CreateUPCE0BarCode("123");
break;
case BarCodeTypes.UPCE1:
barCode = CreateUPCE1BarCode("123");
break;
case BarCodeTypes.UPCSupplemental2:
barCode = CreateUPCSupplemental2BarCode("01");
break;
case BarCodeTypes.UPCSupplemental5:
barCode = CreateUPCSupplemental5BarCode("01234");
break;
case BarCodeTypes.UPCShippingContainer:
barCode = CreateITF14BarCode("1234567890123");
break;
}
return barCode;
}
#endregion #CreateBarCode
#region #PublishReport
private void button1_Click(object sender, EventArgs e) {
// Create a report and handle its BeforPrint event.
XtraReport report = new XtraReport();
report.BeforePrint += report_BeforePrint;
// Show the report's preview.
report.ShowPreview();
}
#endregion #PublishReport
#region #AddBarCode
private void report_BeforePrint(object sender, PrintEventArgs e) {
// Create a bar code control.
XRBarCode barCode = CreateBarCode((BarCodeTypes)comboBox1.SelectedValue);
// Create a Detail band and add the bar code to it.
((XtraReport)sender).Bands.Add(new DetailBand());
((XtraReport)sender).Bands[BandKind.Detail].Controls.Add(barCode);
}
#endregion #AddBarCode
#region #PopulateComboBox
private void Form1_Load(object sender, EventArgs e) {
List<BarCode> data = MakeBarCodesList();
comboBox1.DataSource = data;
comboBox1.DisplayMember = "DisplayName";
comboBox1.ValueMember = "Type";
}
#endregion #PopulateComboBox
}
}