C#打印机操作类

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
using System; 
using System.Collections.Generic; 
using System.Text; 
   
namespace MacPrinter 
    public class ZPL_Command 
    
   
        /// (^EF)<summary> 
        /// 清除设定 (已包含起始结束命令) 
        /// </summary> 
        /// <returns></returns> 
        public string _CmdEraseSetup() 
        
            string st = "^XA^EF^FS^XZ"
            return st.ToUpper(); 
        
   
        /// <summary> 
        ///(^XA) ZPL命令开始 
        /// </summary> 
        /// <returns></returns> 
        public string _CmdStart() 
        
            return "^XA".ToUpper(); 
        
   
        /// <summary> 
        ///(^XZ)  ZPL命令结尾 
        /// </summary> 
        /// <returns></returns> 
        public string _CmdEnd() 
        
            return "^XZ".ToUpper(); 
        
   
        /// <summary> 
        /// (^FS)一个字段的结束(结束一行命令) 
        /// </summary> 
        /// <returns></returns> 
        public string _CmdLineEnd() 
        
            return "^FS".ToUpper(); 
        
   
        /// <summary> 
        ///(^A)字体设定{^Af,o,h,w} 
        /// </summary> 
        /// <param name="DesiredFont">(f)需要选择的字体默认为O(A-Z,1-9)</param> 
        /// <param name="FontOrientation">(o)字体是否旋转默认N(R旋转90°,I旋转180°,B旋转270°,)</param> 
        /// <param name="FontHeight">(h)设定字体高度以点计算默认为15(10-1500)</param> 
        /// <param name="FontWidth">(w)设定字体宽度以点计算默认为12(10-1500)</param> 
        /// <returns></returns> 
        public string _SetFont(string DesiredFont, string FontOrientation, int FontHeight, int FontWidth) 
        
            string _a = string.Format("^A{0}{1},{2},{3}", DesiredFont, FontOrientation, FontHeight, FontWidth); 
            return _a.ToUpper(); 
        
   
        /// <summary> 
        /// (^A)字体设定{^Af,o,h,w} 
        /// </summary> 
        /// <param name="DesiredFont">(f)需要选择的字体默认为O(A-Z,1-9)</param> 
        /// <param name="FontHeight">(h)设定字体高度以点计算默认为15(10-1500)</param> 
        /// <param name="FontWidth">(w)设定字体宽度以点计算默认为12(10-1500)</param> 
        /// <returns></returns> 
        public string _SetFont(string DesiredFont, int FontHeight, int FontWidth) 
        
            return this._SetFont(DesiredFont, "N", FontHeight, FontWidth); 
        
   
        /// <summary> 
        /// (^A@)调用字体名字设定字体{^A@o,h,w,n} 
        /// </summary> 
        /// <param name="FontOrientation">字体是否旋转默认N(R旋转90°,I旋转180°,B旋转270°,)</param> 
        /// <param name="FontHeight">设定字体高度以点计算默认为15(10-1500)</param> 
        /// <param name="FontWidth">设定字体宽度以点计算默认为12(10-1500)</param> 
        /// <param name="FontName">Font Name(Cyrillic.FNT)</param> 
        /// <returns></returns> 
        public string _SetFont(string FontOrientation, int FontHeight, int FontWidth, string FontName) 
        
            return string.Format("^A@{0},{1},{2},{3}", FontOrientation, FontHeight, FontWidth, FontName); 
        
   
        /// <summary> 
        /// (^B1o,e,h,f,g) 
        /// </summary> 
        /// <returns></returns> 
        public string _SetCode11() 
        
            return ""
        
   
        /// <summary> 
        /// (^B3)Code39码(^B3o,e,h,f,g) 
        /// </summary> 
        /// <param name="Orientation">Orientation: 
        ///Default value: Current ^FW setting 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees;</param> 
        /// <param name="e">Mod-43 Check Digit: 
        ///Default value: N = No; 
        ///Other value: Y = Yes</param> 
        /// <param name="Height">Bar Code Height: 
        /// Default value: Value set by ^BY ; 
        ///Other values: 1 dot to 9999 dots 
        /// </param> 
        /// <param name="f">Print Interpretation Line 
        ///Default value: Y = Yes; 
        ///Other value: N = No</param> 
        /// <param name="g">Print Interpretation Line Above Code 
        ///Default value: N = No ; 
        ///Other value: Y = Yes</param> 
        /// <returns></returns> 
        public string _SetCode39(string Orientation, string e, int Height, string f, string g) 
        
            return string.Format("^B3{0},{1},{2},{3},{4}", Orientation, e, Height, f, g).ToUpper(); 
        
   
        /// <summary> 
        /// (^B4)Code49码(^B4o,h,f,m) 
        /// </summary> 
        /// <param name="Orientation"> 
        /// Orientation 
        ///Default value: Current ^FW value 
        ///(^FW defaults to N = Normal at power-up); 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees;</param> 
        /// <param name="Height">Height Multiplier of Individual Rows 
        ///Defined: This number, multiplied by the module,; 
        ///equals the height of the individual rows in dots.; 
        ///Default value: Value set by ^BY; 
        ///Other values: 1 to height of label.; 
        ///NOTE: 1 is not a recommended value.</param> 
        /// <param name="f">Print Interpretation Line 
        ///Default value: N = No line printed. 
        ///Other values: 
        ///A = Print interpretation line above code.; 
        ///B = Print interpretation line below code.</param> 
        /// <param name="m">Starting Mode 
        ///Default value: A = Automatic Mode. Printer determines 
        ///starting mode by analyzing field data.; 
        ///Other values: 
        ///0 = Regular Alphanumeric Mode; 
        ///1 = Multiple Read Alphanumeric; 
        ///2 = Regular Numeric Mode; 
        ///3 = Group Alphanumeric Mode; 
        ///4 = Regular Alphanumeric Shift 1; 
        ///5 = Regular Alphanumeric Shift 2;</param> 
        /// <returns></returns> 
        public string _SetCode49(string Orientation, int Height, string f, string m) 
        
            return string.Format("^B4{0},{1},{2},{3}", Orientation, Height, f, m).ToUpper(); 
   
        
   
        /// <summary> 
        /// (^B7)PDF417 Bar Code(^B7o,h,s,c,r,t) 
        /// </summary> 
        /// <param name="o">Orientation Default value: Current ^FW value 
        /// 
        ///(^FW defaults to N = Normal at power-up); 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees;</param> 
        /// <param name="h">Bar Code Height for Individual Rows 
        ///(This number, multiplied by the module, equals the 
        ///height of the individual rows in dots.) 
        ///Default value: Value set by ^BY; 
        ///Other values: 1 dot to height of label.; 
        ///NOTE: 1 is not a recommended value.</param> 
        /// <param name="s">Security Level 
        ///Determines the number of error detection and correction 
        ///code words to be generated for the symbol. 
        ///Default level provides only error detection (no correction). 
        ///Increasing the security level adds increasing 
        ///levels of error correction. (Increases symbol size.) 
        ///Default value: 0 = Error detection only; 
        ///Other values: 1 to 8.; 
        ///Error detection plus correction.</param> 
        /// <param name="c" >Number of Data Columns to Encode 
        ///User can specify number of codeword columns giving 
        ///control over the width of the symbol.; 
        ///Default value: 1:2 row/column aspect ratio.; 
        ///Other values: 1 to 30;</param> 
        /// <param name="r">Number of Rows to Encode 
        ///User can specify number of symbol rows giving control 
        ///over the height of the symbol.; 
        ///Default value: 1:2 row/column aspect ratio.; 
        ///Other values: 3 to 90;; 
        ///Example: With no row or column values entered, 72 
        ///codewords would be encoded into a symbol of 6 columns 
        ///and 12 rows. (Depending on codewords, aspect ratio 
        ///will not always be exact.)</param> 
        /// <param name="t">Truncate Right Row Indicators and Stop Pattern 
        ///Default value: N = No truncation 
        ///Print right row indicators and stop pattern. 
        ///Other value: Y = Yes perform truncation.</param> 
        /// <returns></returns> 
        public string _SetCodeBDF417(string o, int h, int s, int c, int r, string t) 
        
            return string.Format("^B7{0},{1},{2},{3},{4},{5}", o, h, s, c, r, t).ToUpper(); 
        
   
        // 
        // 
        /// <summary> 
        /// (^B8)EAN-8 Bar Code(^B8o,h,f,g) 
        /// </summary> 
        /// <param name="o">Orientation 
        ///Default value: Current ^FW value 
        ///(^FW defaults to N = Normal at power-up); 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees;</param> 
        /// <param name="h">Bar Code Height 
        ///Default value: Value set by ^BY; 
        ///Other values: 1 dot to 9999 dots</param> 
        /// <param name="f">Print Interpretation Line 
        ///Default value: Y = Yes; 
        ///Other value: N = No</param> 
        /// <param name="g">Print Interpretation Line Above Code 
        ///Default value: N = No; 
        ///Other value: Y = Yes</param> 
        /// <returns></returns> 
        public string _SetCodeEAN8(string o, int h, string f, string g) 
        
            return string.Format("^B8{0},{1},{2},{3}", o, h, f, g).ToUpper(); 
        
   
        /// <summary> 
        /// (^B9)UPC-E Bar Code(^B9o,h,f,g,e) 
        /// </summary> 
        /// <param name="o">Orientation 
        ///Default value: Current ^FW setting; 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees</param> 
        /// <param name="h">Bar Code Height 
        ///Default value: Value set by ^BY; 
        ///Other values: 1 dot to 9999 dots</param> 
        /// <param name="f">Print Interpretation Line 
        ///Default value: Y = Yes; 
        ///Other value: N = No</param> 
        /// <param name="g">Print Interpretation Line Above Code 
        ///Default value: N = No; 
        ///Other value: Y = Yes</param> 
        /// <param name="e">Print Check Digit 
        ///Default value: Y = Yes,; 
        ///Other value: N = No</param> 
        /// <returns></returns> 
        public string _SetCodeUPC_E(string o, int h, string f, string g, string e) 
        
            return string.Format("^B9{0},{1},{2},{3},{4}", o, h, f, g, e).ToUpper(); 
        
   
        /// <summary> 
        /// (^BA)Code 93 Bar Code(^BAo,h,f,g,e) 
        /// </summary> 
        /// <param name="o">Orientation 
        ///Default value: Current ^FW setting; 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees</param> 
        /// <param name="h">Bar Code Height 
        ///Default value: Value set by ^BY; 
        ///Other values: 1 dot to 9999 dots</param> 
        /// <param name="f">Print Interpretation Line 
        ///Default value: Y = Yes; 
        ///Other value: N = No</param> 
        /// <param name="g">Print Interpretation Line Above Code 
        ///Default value: N = No; 
        ///Other value: Y = Yes</param> 
        /// <param name="e">Print Check Digit 
        ///Default value: Y = Yes,; 
        ///Other value: N = No</param> 
        /// <returns></returns> 
        public string _SetCode93(string o, int h, string f, string g, string e) 
        
            return string.Format("^BA{0},{1},{2},{3},{4}", o, h, f, g, e).ToUpper(); 
        
   
        /// <summary> 
        /// (^BC)Code 128 Bar Code(Subsets A, B, and C)(^BCo,h,f,g,e,m) 
        /// </summary> 
        /// <param name="o">Orientation 
        ///Default value: Current ^FW setting; 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees</param> 
        /// <param name="h">Bar Code Height 
        ///Default value: Value set by ^BY; 
        ///Other values: 1 dot to 9999 dots</param> 
        /// <param name="f">Print Interpretation Line 
        ///Default value: Y = Yes 
        ///Other value: N = No</param> 
        /// <param name="g">Print Interpretation Line Above Code 
        ///Default value: N = No; 
        ///Other value: Y = Yes</param> 
        /// <param name="e">UCC Check Digit 
        ///Default value: N = No;; 
        ///Other value: Y = Yes</param> 
        /// <param name="m">Mode 
        ///Default value: N = No mode selected;; 
        ///Other value: U = UCC Case Mode;; 
        ///(^FD or ^SN statement must contain 19 
        ///numeric digits (it can also contain valid alpha 
        ///characters). Subset C using FNC1 values is 
        ///automatically selected.</param> 
        /// <returns></returns> 
        public string _SetCode128(string o, int h, string f, string g, string e, string m) 
        
            return string.Format("^BC{0},{1},{2},{3},{4},{5}", o, h, f, g, e, m); 
        
   
        /// <summary> 
        /// (^BC)Code 128 Bar Code(Subsets A, B, and C)(^BCo,h,f,g,e,m) 
        /// </summary> 
        /// <param name="o">Orientation 
        ///Default value: Current ^FW setting; 
        ///Other values: 
        ///N = Normal; 
        ///R = Rotated, 90 degrees clockwise; 
        ///I = Inverted, 180 degrees; 
        ///B = Read from Bottom Up, 270 degrees</param> 
        /// <param name="h">Bar Code Height 
        ///Default value: Value set by ^BY; 
        ///Other values: 1 dot to 9999 dots</param> 
        /// <param name="f">Print Interpretation Line 
        ///Default value: Y = Yes 
        ///Other value: N = No</param> 
        /// <param name="g">Print Interpretation Line Above Code 
        ///Default value: N = No; 
        ///Other value: Y = Yes</param> 
        /// <param name="e">UCC Check Digit 
        ///Default value: N = No;; 
        ///Other value: Y = Yes</param> 
        /// <returns></returns> 
        public string _SetCode128(string o, int h, string f, string g, string e) 
        
            return string.Format("^BC{0},{1},{2},{3},{4}", o, h, f, g, e); 
   
        
   
        /// <summary> 
        /// (^BY)  Change Bar Code Default Parameters(条码字段默认参数设置,用来改变窄元素(窄条或窄空)的宽度模块) 
        /// </summary> 
        /// <param name="w">模块(窄条)宽 (开机初始化值:2点 可接受的数值:1-10点) Module (Narrow Bar) Width (Initial power -up value: 2 dots ,Acceptable values: 1-10 dots)</param> 
        /// <param name="r">宽条与窄条的比例 (开机初始化值:3.0 可接受的数值:2.0到3.0,0.1的增量(对固定比例的条码无效))Wide Bar to Narrow Bar Width Ratio(Initial power-up ratio: 3.0 ,Acceptable ratios: From 2.0 to 3.0 in .1 increments.)</param> 
        /// <param name="h">条码高度 开机初始化值:10点可接受的数值:1点到标签高度(Height of Bars(Initial Power-up value: 10 dots, Acceptable values: 1 dot to height of label)</param> 
        /// <returns></returns> 
        public string _changeBarCodeDefault(int w, int r, int h) 
        
            string _by = string.Format("^BY{0},{1},{2}", w, r, h); 
            return _by.ToUpper(); 
        
   
        /// <summary> 
        /// (^BY)  Change Bar Code Default Parameters(条码字段默认参数设置,用来改变窄元素(窄条或窄空)的宽度模块) 
        /// </summary> 
        /// <param name="w">模块(窄条)宽 (开机初始化值:2点 可接受的数值:1-10点) Module (Narrow Bar) Width (Initial power -up value: 2 dots ,Acceptable values: 1-10 dots)</param> 
        /// <param name="r">宽条与窄条的比例 (开机初始化值:3.0 可接受的数值:2.0到3.0,0.1的增量(对固定比例的条码无效))Wide Bar to Narrow Bar Width Ratio(Initial power-up ratio: 3.0 ,Acceptable ratios: From 2.0 to 3.0 in .1 increments.)</param> 
        /// <returns></returns> 
        public string _changeBarCodeDefault(int w, string r) 
        
            string _by = string.Format("^BY{0},{1}", w, r); 
            return _by.ToUpper(); 
        
   
        /// <summary> 
        /// (^LR) Reverse Print All Fields 
        /// </summary> 
        /// <param name="reverse">(y)是否以黑底白字打印{Y or N}</param> 
        /// <returns></returns> 
        public string _SetLableReverse(string reverse) 
        
            return string.Format("^LR{0}", reverse); 
        
   
        /// <summary> 
        /// (^LL)设定Lable长度 
        /// </summary> 
        /// <param name="iLength">Number of Dots Along Y-Axis{Default value:1225 for Stripe ; 1244 for Xi printers}</param> 
        /// <returns></returns> 
        public string _SetLableLength(int iLength) 
        
            return string.Format("^LL{0}", iLength); 
        
   
        /// <summary> 
        /// (^LS)移动Lable 
        /// </summary> 
        /// <param name="shiftValue">Shift Left Value of dots(Acceptable values: 0 to 9999 dots)</param> 
        /// <returns></returns> 
        public string _SetLableShift(int shiftValue) 
        
            return string.Format("^LS{0}", shiftValue); 
        
   
        /// <summary> 
        /// (^LH) 设置Lable起点以及顶端距离(以点计算),如超出范围将抛出错误 
        /// </summary> 
        /// <param name="x">起点的X位置</param> 
        /// <param name="y">起点的Y位置</param> 
        /// <param name="width">实际Lable纸张的宽度(以点计算)</param> 
        /// <param name="height">实际Lable纸张的宽度(以点计算)</param> 
        /// <returns></returns> 
        public string _SetLableHomeAndTop(int x, int y, int width, int height) 
        
            if (y < width && x < height) 
            
                string _lh_lt = string.Format("^LH{0},{1}^LT{1}", x, y); 
   
                return _lh_lt.ToUpper(); 
            
            else 
            
                throw new Exception("超出范围"); 
            
   
        
   
        /// <summary> 
        /// (^LH)设定Lable的起点 
        /// </summary> 
        /// <param name="x">起点的X位置</param> 
        /// <param name="y">起点的Y位置</param> 
        /// <param name="width">实际Lable纸张的宽度(以点计算)</param> 
        /// <param name="height">实际Lable纸张的宽度(以点计算)</param> 
        /// <returns></returns> 
        public string _SetLableHome(int x, int y) 
        
            return string.Format("^LH{0},{1}", x, y); 
        
   
        /// <summary> 
        ///(^LT) Lable距离顶端边的距离(以点计算) 
        /// </summary> 
        /// <param name="iTop"></param> 
        /// <returns></returns> 
        public string _SetLableTop(int iTop) 
        
            return string.Format("^LT{0}", iTop); 
        
   
        /// <summary> 
        /// (^DF)下载字体 
        /// </summary> 
        /// <param name="FileName">字体文件名称包含扩展名(STOREFMT.ZPL)</param> 
        /// <returns></returns> 
        public string _SetDownLoadFont(string FileName) 
        
            string _df = string.Format("^DF{0}", FileName); 
            return _df.ToUpper(); 
        
   
        /// <summary> 
        ///(^MD) 设定打印字体容度 
        /// </summary> 
        /// <param name="darknessVale">容度值默认15(-30至+30)</param> 
        /// <returns></returns> 
        public string _SetMediaDarkness(int darknessVale) 
        
            string _md = string.Format("^MD{0}", darknessVale); 
            return _md.ToUpper(); 
        
   
        /// <summary> 
        /// (^ML) Maximum Label Length 
        /// </summary> 
        /// <param name="iLength">Maximum Label Length in Dot Rows(Default value:Last permanently saved value)</param> 
        /// <returns></returns> 
        public string _SetMaxLableLength(int iLength) 
        
            return string.Format("^ML{0}", iLength); 
        
   
        /// <summary> 
        /// (^MM)Print Mode 
        /// </summary> 
        /// <param name="strDesiredMode"> 
        /// Desired Mode 
        /// Default value: 
        ///T = Tear Off ;  
        ///Other Values: 
        ///P = Peel Off (not available on S-300 printers) 
        ///R = Rewind (Instruction ignored if parameter 
        ///missing or incorrect.) 
        ///A = Applicator 
        /// </param> 
        /// <param name="strPrePeelSelect">Pre-Peel Select(Y or N)</param> 
        /// <returns></returns> 
        public string _SetPrintMode(string strDesiredMode, string strPrePeelSelect) 
        
            return string.Format("^MM{0},{1}", strDesiredMode, strPrePeelSelect); 
        
   
        /// <summary> 
        /// (^MN) Set Media Tracking 
        /// </summary> 
        /// <param name="strTrack">Media Being Used 
        ///N = Continuous Media ; 
        ///Y = Non-Continuous Media Web Sensing</param> 
        /// <returns></returns> 
        public string _SetMedieTracking(string strTrack) 
        
            return string.Format("^MN{0}", strTrack); 
        
   
        /// <summary> 
        /// (^MU)Set Mode Units 
        /// </summary> 
        /// <param name="unitsType">units type 
        /// Default: D = Dots 
        ///I = Inches 
        ///M = Millimeters</param> 
        /// <returns></returns> 
        public string _SetModeUnits(string unitsType) 
        
            return string.Format("^MU{0}", unitsType); 
        
   
   
        /// <summary> 
        ///(^PR _^PW) 设定打印速度以及打印的宽度 
        /// </summary> 
        /// <param name="PrintSpeed">打印速度值默认3(A or 2 50.8 mm/sec,B or 3 76.2 mm/sec,C or 4 101.6 mm/sec,5 127 mm/sec,D or 6 152.4 mm/sec,E or 8 203.2 mm/sec.)</param> 
        /// <param name="SlewSpeed">Default value: Speed D(A or 2 50.8 mm/sec,B or 3 76.2 mm/sec,C or 4 101.6 mm/sec,5 127 mm/sec,D or 6 152.4 mm/sec,E or 8 203.2 mm/sec)</param> 
        /// <param name="BackfeedSpeed">Default value: Speed D(A or 2 50.8 mm/sec,B or 3 76.2 mm/sec,C or 4 101.6 mm/sec,5 127 mm/sec,D or 6 152.4 mm/sec,E or 8 203.2 mm/sec)</param> 
        /// <param name="PrintWidth">打印宽度(根据Lable纸而定)</param> 
        /// <returns></returns> 
        public string _SetPrintRateAndWidth(int PrintSpeed, int SlewSpeed, int BackfeedSpeed, int PrintWidth) 
        
            string _pr_pw = string.Format("^PR{0},{1},{2}^PW{3}", PrintSpeed, SlewSpeed, BackfeedSpeed, PrintWidth); 
            return _pr_pw.ToUpper(); 
        
   
        /// <summary> 
        ///(^PR) 设定打印速度以及打印的宽度 
        /// </summary> 
        /// <param name="PrintSpeed">打印速度值默认3(A or 2 50.8 mm/sec,B or 3 76.2 mm/sec,C or 4 101.6 mm/sec,5 127 mm/sec,D or 6 152.4 mm/sec,E or 8 203.2 mm/sec.)</param> 
        /// <param name="SlewSpeed">Default value: Speed D(A or 2 50.8 mm/sec,B or 3 76.2 mm/sec,C or 4 101.6 mm/sec,5 127 mm/sec,D or 6 152.4 mm/sec,E or 8 203.2 mm/sec)</param> 
        /// <param name="BackfeedSpeed">Default value: Speed D(A or 2 50.8 mm/sec,B or 3 76.2 mm/sec,C or 4 101.6 mm/sec,5 127 mm/sec,D or 6 152.4 mm/sec,E or 8 203.2 mm/sec)</param> 
        /// <returns></returns> 
        public string _SetPrintRate(int PrintSpeed, int SlewSpeed, int BackfeedSpeed) 
        
            return string.Format("^PR{0},{1},{2}", PrintSpeed, SlewSpeed, BackfeedSpeed); 
        
   
   
        /// <summary> 
        /// (^PR)设置打印速度 
        /// </summary> 
        /// <param name="PrintSpeed">打印速度: 
        /// Print Speed 
        ///Default value: Speed A 
        ///Acceptable values : 
        ///A or 2 50.8 mm/sec. (2 inches/sec.) 
        ///B or 3 76.2 mm/sec. (3 inches/sec.) 
        ///C or 4 101.6 mm/sec. (4 inches/sec.) 
        ///5 127 mm/sec. (5 inches/sec.) 
        ///D or 6 152.4 mm/sec. (6 inches/sec.) 
        ///E or 8 203.2 mm/sec. (8 inches/sec.) 
        /// </param> 
        /// <returns></returns> 
        public string _SetPrintRate(int PrintSpeed) 
        
            return string.Format("^PR{0}", PrintSpeed); 
        
   
        /// <summary> 
        /// (^PW)设置打印范围(宽度) 
        /// </summary> 
        /// <param name="printWidth">打印宽度</param> 
        /// <returns></returns> 
        public string _SetPrintWidth(int printWidth) 
        
            return string.Format("^PW{0}", printWidth); 
        
   
        /// <summary> 
        ///  (^PR_^PW) 设定打印速度以及打印的宽度 
        /// </summary> 
        /// <param name="PrintSpeed">打印速度值默认3(A or 2 50.8 mm/sec,B or 3 76.2 mm/sec,C or 4 101.6 mm/sec,5 127 mm/sec,D or 6 152.4 mm/sec,E or 8 203.2 mm/sec.)</param> 
        /// <param name="PrintWidth">打印宽度(根据Lable纸而定)</param> 
        /// <returns></returns> 
        public string _SetPrintRateAndWidth(int PrintSpeed, int PrintWidth) 
        
            return this._SetPrintRateAndWidth(PrintSpeed, 6, 6, PrintWidth); 
        
   
        /// <summary> 
        /// (^PR_^PW) 设定打印的宽度打印速度使用默认值 
        /// </summary> 
        /// <param name="PrintWidth"></param> 
        /// <returns></returns> 
        public string _SetPrintRateAndWidth(int PrintWidth) 
        
            return this._SetPrintRateAndWidth(3, 6, 6, PrintWidth); 
        
   
        /// <summary> 
        /// (^FO)设置字段的位置,相对于由^LH命令指定的标签原点 
        /// </summary> 
        /// <param name="x">Number of Dots along X-axis(Default value: = 0,Acceptable values: 0 - 9999)</param> 
        /// <param name="y">Number of Dots along Y-axis(Default value: = 0,Acceptable values: 0 - 9999)</param> 
        /// <returns></returns> 
        public string _SetFieldOrigin(int x, int y) 
        
            string _fo = string.Format("^FO{0},{1}", x, y); 
            return _fo.ToUpper(); 
        
   
        /// <summary> 
        /// Code 128 Bar Code (^BC) 
        /// </summary> 
        /// <param name="o">字体方向  //[N = 正常 (Normal), R = 顺时针旋转90度(Roated), I = 顺时针旋转180度(Inverted), B = 顺时针旋转270度 (Bottom)]</param> 
        /// <param name="h">条码高度 // [默认值:由^BY设置 其他值:1到9999点]</param> 
        /// <param name="f">打印注释行  //[ 默认值: Y = 打印(Yes)其他值:N = 不打印(No]</param> 
        /// <param name="g">将注释行打印在条码上方  //[ 默认值: N = 不打印在条码上方其他值: Y = 打印在条码上方]</param> 
        /// <param name="e"> 打印UCC校验位  // 默认值:Y = 打印(Yes)其他值:N = 不打印(No)</param> 
        /// <param name="m">= 模式  //默认值:N = 不选择模式, 其他值:U = UCC匹配模式></param> 
        /// <returns></returns> 
        public string _BCCode128(string o, int h, string f, string g, string e, string m) 
        
            string _bc = string.Format("^BC{0},{1},{2},{3},{4},{5}", o, h, f, g, e, m); 
            return _bc.ToUpper(); 
        
   
        /// <summary> 
        /// Code 128 Bar Code(^BC) 
        /// </summary> 
        /// <param name="o">字体方向  //[N = 正常 (Normal), R = 顺时针旋转90度(Roated), I = 顺时针旋转180度(Inverted), B = 顺时针旋转270度 (Bottom)]</param> 
        /// <param name="h">条码高度 // [默认值:由^BY设置 其他值:1到9999点]</param> 
        /// <param name="f">打印注释行  //[ 默认值: Y = 打印(Yes)其他值:N = 不打印(No]</param> 
        /// <param name="g">将注释行打印在条码上方  //[ 默认值: N = 不打印在条码上方其他值: Y = 打印在条码上方]</param> 
        /// <param name="e"> 打印UCC校验位  // 默认值:Y = 打印(Yes)其他值:N = 不打印(No)</param> 
        /// <returns></returns> 
        public string _BCCode128(string o, int h, string f, string g, string e) 
        
            return this._BCCode128(o, h, f, g, e, "N").ToUpper(); 
        
   
        /// <summary> 
        /// (^FD) 字段数据 
        /// </summary> 
        /// <param name="data">打印的数据(字段数据串最多3072字符)</param> 
        /// <returns></returns> 
        public string _SetFieldData(string data) 
        
            string _fd = string.Format("^FD{0}", data); 
            return _fd; 
        
   
        /// <summary> 
        /// (^FH) 字段的十六进制表示(指令允许你在^FD语句里直接输入任何十六进制值。^FH指令必须在每个^FD指令前才能用)在^FD语句里,十六进制标识必须在每个十六进制值前加入(_)。缺省的十六进制标识是下划线(_)。这指令可以用在任何有数据段的指令里,(如^FD,^FV(段变量),和^SN(串行数据) 
        /// </summary> 
        /// <returns></returns> 
        public string _FieldHex() 
        
            return "^FH".ToUpper(); 
        
   
        /// <summary> 
        ///  (^SN) 连续数据指令 
        /// </summary> 
        /// <param name="StartingValue">起始值</param> 
        /// <param name="IncrementValue">增加/减少值</param> 
        /// <param name="LeadingZeros">如需要加引导零. 缺省值:N=不 ;其它值:Y=是</param> 
        /// <returns></returns> 
        public string _SetSerializationData(string StartingValue, int IncrementValue, string LeadingZeros) 
        
            string _sn = string.Format("^SN{0},{1},{2}", StartingValue, IncrementValue, LeadingZeros.ToUpper()); 
            return _sn; 
        
   
        /// <summary> 
        ///(^PQ) 打印总数 
        /// </summary> 
        /// <param name="q">数量(Total Quantity of Labels to Print)</param> 
        /// <returns></returns> 
        public string _SetPrintQueantity(int q) 
        
            string _pq = string.Format("^PQ{0}", q); 
            return _pq.ToUpper(); 
        
   
        /// <summary> 
        /// (^PQ)打印总数 
        /// {Exemples: ^PQ50,10,1,Y:---- Print a total quantity of 50 labels with one replicate 
        ///of each serial number. Print the total quantity in groups of 10, but do 
        ///not pause after every group.} 
        /// </summary> 
        /// <param name="q">Total Quantity of Labels to Print 
        /// ;Default value: 1 
        ///;Acceptable values: 1 - 99,999,999</param> 
        /// <param name="p">Pause (‘Group’) Count; 
        /// Default value: 0 = no pause 
        ///Acceptable values: 0 - 99,999,999 labels between pauses 
        /// </param> 
        /// <param name="r">Replicates of Each Serial Number; 
        /// Default value: 0 = no replicates 
        ///Acceptable values: 0 - 99,999,999 replicates 
        /// </param> 
        /// <param name="o">Override Pause Count; 
        /// Default value: N = No 
        ///Other value: Y = Yes 
        /// </param> 
        /// <returns></returns> 
        public string _SetPrintQueantity(int q, int p, int r, string o) 
        
            return string.Format("^PQ{0},{1},{2},{3}", q, p, r, o); 
        
   
        /// <summary> 
        /// (^PM)Print Mirror Image of Lable( 
        /// NOTE: The ^PM will remain active unless turned off by ^PMN 
        ///instruction or the printer is powered down.) 
        /// </summary> 
        /// <param name="a">Mirror Print Entire Label 
        ///Y = Yes 
        ///N = No {I.V.P. = N}</param> 
        /// <returns></returns> 
        public string _SetMirrorImageLable(string a) 
        
            return string.Format("^PM{0}", a); 
        
   
        /// <summary> 
        /// (^PO)Print Orientation 
        /// </summary> 
        /// <param name="a">a = Invert 180 Degrees 
        ///N = Normal {I.V.P. = N} 
        ///I = Invert</param> 
        /// <returns></returns> 
        public string _SetPrintOrientation(string a) 
        
            return string.Format("^PO{0}", a); 
        
   
        /// <summary> 
        /// (^GF)Graphic Field(图片打印) 
        /// </summary> 
        /// <param name="CompressionType"> 
        /// Default:ASCII 
        /// Value: 
        /// A = ACSII Hex: 
        /// This follows the conventional download format 
        /// used for all other download commands. 
        /// B = Binary: 
        /// The data sent to the printer after the ‘c’ parameter 
        /// is strictly binary.  
        /// C = Compression Binary : 
        /// The data sent after parameter ‘c’ is in a compressed 
        /// binary format. The data is compressed on 
        /// the host side using a compression algorithm supplied 
        /// by Zebra. The data is then decompressed 
        /// and placed directly in the bitmap. 
        /// </param> 
        /// <param name="BinaryByteCount"> 
        /// Binary Byte Count 
        /// Default:Note-entire command is ignored when not specified 
        /// Value:Total number of bytes  
        /// Range:1 to 99999 
        /// </param> 
        /// <param name="GraphicFieldCount"> 
        /// Graphic Field Count 
        /// </param> 
        /// <param name=";ByteperRow"> 
        /// Bytes per Row 
        /// </param> 
        /// <param name="strData"> 
        /// Default:None=must be specified 
        /// ASCII Hex Data: 
        /// </param> 
        /// <returns></returns> 
        public string _SetGraphicField(string CompressionType, string BinaryByteCount, 
            string GraphicFieldCount, string ByteperRow, string strData) 
        
            return string.Format("^GF{0},{1},{2},{3},{4}", CompressionType.ToUpper(), BinaryByteCount, GraphicFieldCount, ByteperRow, strData); 
        
   
        public string _SetFieldNumber(int i) 
        
            return string.Format("^FN{0}", i); 
        
        public string _SetRecallFormat(string FieldName) 
        
            return string.Format("^XF{0}", FieldName); 
        
   
        /// <summary> 
        ///(^FWr) Set Field Orientation 
        /// </summary> 
        /// <param name="Orig">Rotate Field 
        /// N = Normal {I.V.P. = N} 
        /// R = Rotated 90 degrees; 
        /// I = Inverted (180 degrees); 
        /// B = Bottom Up (270 degrees read from bottom up). 
        /// </param> 
        /// <returns></returns> 
        public string _SetFieldOrientation(string Orig) 
        
            return string.Format("^FW{0}", Orig); 
        
   
    
}