資源簡介
實現(xiàn)斑馬打印機(jī)的控制格式
代碼片段和文件信息
using?Smt.Zebra;
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Drawing.Printing;
using?System.IO;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.xml;
namespace?ZebarTest1
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????//底部狀態(tài)欄結(jié)果顯示
????????private?void?ShowResult(int?Result)???//??狀態(tài)欄結(jié)果顯示
????????{
????????????//TextError.Text?=?Client.ErrorText(Result);
????????????//if?(Result?==?0)
????????????//????TextError.Text?=?TextError.Text?+?“(“?+?Client.ExecutionTime.ToString()?+?“ms)“;
????????}
????????//使用斑馬打印機(jī)打印
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????RawPrinterHelper.SendStringToPrinter(comboBox1.Text?this.textBox1.Text);
????????????????////實例化一個打印類
????????????????ZebraPrinter?printer?=?new?ZebraPrinter();
????????????????FileStream?fs?=?new?FileStream(“Template.TXT“?FileMode.Open?FileAccess.Read);
????????????????StreamReader?sr?=?new?StreamReader(fs);
????????????????while?(sr.Peek()?>?0)
????????????????{
????????????????????string?str?=?sr.ReadLine();
????????????????????if?(!string.IsNullOrEmpty(str))
????????????????????{
????????????????????????///////定義兩個標(biāo)簽值
????????????????????????//string?str1?=?tag1.Text;
????????????????????????//string?str2?=?tag2.Text;
????????????????????????////依照格式,格式化成新的字符串
????????????????????????//string?str?=?string.Concat(“條碼1“?“^“?“條碼2“?“~“?str1?“^“?str2);???//雙排條形碼
????????????????????????str?=?string.Concat(“?“?“~“?str);??????//單排條形碼????,Concat連接三個指定實例
????????????????????????//str?=?string.Concat(“?“?“^“?“?“?“~“?str?“^“?str);???//雙排條形碼
????????????????????????label6.Text?=?str;
????????????????????????printer.PrintLabEx(“Template.TXT“?str?comboBox1.Text);//printPath:模板名程,從文本框里選。str為ZPL命令。??comboBox1.Text:打印機(jī)名稱
????????????????????}
????????????????}
????????????????fs.Close();
????????????????sr.Close();
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????MessageBox.Show(“Error“?+?ex.Message);
????????????}
????????}
????????//掃描打印機(jī)
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????//顯示時間
????????????timer1.Start();
????????????//選擇打印機(jī)
????????????if?(string.IsNullOrEmpty(comboBox1.Text))
????????????{
????????????????groupBox1.Enabled?=?true;
????????????????groupBox2.Enabled?=?true;
????????????}
????????????string?template;
????????????//加載所有模板
????????????string[]?files?=?Directory.GetFiles(“Template“);//(“D:\\Visual?Studio?2019\\VS?Project\\Zebra\\ZebarTest1\\Template“);
????????????foreach?(string?item?in?files)
????????????{
????????????????template?=?item.ToString();
????????????????string?str1?=?template.Remove(0?9);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-10-10?08:26??.vs\
?????目錄???????????0??2020-10-10?08:26??.vs\ZebarTest1\
?????目錄???????????0??2020-10-10?08:26??.vs\ZebarTest1\v16\
?????文件????????6656??2020-06-29?11:06??.vs\ZebarTest1\v16\.suo
?????文件?????????189??2020-06-29?08:19??App.config
?????目錄???????????0??2020-10-10?08:26??bin\
?????目錄???????????0??2020-10-10?08:26??bin\Debug\
?????文件?????????906??2020-06-29?08:22??bin\Debug\BarcodePath.TXT
?????文件???????24576??2018-10-12?14:54??bin\Debug\FNTHEX32.DLL
?????文件???????45568??2020-06-28?18:18??bin\Debug\SMT.ZEBRA.dll
?????目錄???????????0??2020-10-10?08:26??bin\Debug\Template\
?????文件??????????93??2020-06-30?14:51??bin\Debug\Template\66666.TXT
?????文件??????????91??2020-06-29?18:01??bin\Debug\Template\template3.TXT
?????文件?????????105??2020-06-29?18:06??bin\Debug\Template\template5.TXT
?????文件??????????93??2020-06-30?18:30??bin\Debug\Template\護(hù)發(fā)素.TXT
?????文件??????????93??2020-06-30?18:30??bin\Debug\Template\護(hù)發(fā)素22.TXT
?????文件??????????93??2020-06-30?10:39??bin\Debug\Template\胡辣湯.TXT
?????文件?????6205440??2015-06-29?16:49??bin\Debug\ThoughtWorks.QRCode.dll
?????文件???????44032??2020-07-15?17:41??bin\Debug\ZebarTest1.exe
?????文件?????????189??2020-06-29?08:19??bin\Debug\ZebarTest1.exe.config
?????文件???????52736??2020-07-15?17:41??bin\Debug\ZebarTest1.pdb
?????文件???????????2??2020-06-30?10:38??bin\Debug\油條.TXT
?????文件???????18154??2020-07-08?13:38??Form1.cs
?????文件???????56623??2020-07-07?11:21??Form1.Designer.cs
?????文件???????20610??2020-07-07?11:21??Form1.resx
?????目錄???????????0??2020-10-10?08:26??obj\
?????目錄???????????0??2020-10-21?10:18??obj\Debug\
?????文件?????????214??2020-10-21?10:18??obj\Debug\.NETfr
?????文件????????1435??2020-07-15?17:26??obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????7535??2020-07-01?12:26??obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????目錄???????????0??2020-07-15?17:26??obj\Debug\TempPE\
............此處省略19個文件信息
- 上一篇:listView可修改控件
- 下一篇:C#實現(xiàn)閃屏程序
評論
共有 條評論