123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace ZebraSample
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- PrintLabel("12345", "ABCDEFGHIJK", "SN123", "Test");
- }
- public void PrintLabel(string ProductID, string MAC, string SN, string ProductDesc)
- {
- string strContenx1 = ProductID;
- string strContenx2 = MAC;
- string strContenx3 = SN;
- //全局参数
- int GlobalStartX = int.Parse(txtStartX.Text);
- int GlobalStartY = int.Parse(txtStartY.Text);
- int Deep = int.Parse(coBoxND.SelectedValue.ToString());
- int Quatity = 15;
- int Speed = int.Parse(coBoxSD.SelectedValue.ToString());
- //条码参数
- int BcStartX = int.Parse(txtBcX.Text);
- int BcStartY = int.Parse(txtBcY.Text);
- int BcHeight = int.Parse(txtBcHeight.Text);
- int BcW = int.Parse(cbwidth.SelectedValue.ToString());
- double BcR = double.Parse(cbRatio.SelectedValue.ToString());
- //文字参数
- int intTextH = int.Parse(txtTextHeight.Text);
- int intTextW = int.Parse(txtTextWidth.Text);
- List<GetPrintRowString> bcList = new List<GetPrintRowString>(); ;
- //第一个条码
- Barcode1Dimension bc1 = new Barcode1Dimension(BcStartX, BcStartY);
- bc1.bcContent = strContenx1;//填充打印内容
- bc1.bcSize = BcHeight;//填充条码大小
- bc1.bcW = BcW;
- bc1.bcR = BcR;
- bcList.Add(bc1);
- //第二个条码
- Barcode1Dimension bc2 = new Barcode1Dimension(BcStartX, BcStartY + (BcHeight + intTextH + 10));
- bc2.bcContent = strContenx2.Split('-')[0]; ;//填充打印内容
- bc2.bcSize = BcHeight;//填充条码大小
- bc2.bcW = BcW;
- bc2.bcR = BcR;
- bcList.Add(bc2);
- //第三个条码
- Barcode1Dimension bc3 = new Barcode1Dimension(BcStartX, BcStartY + (BcHeight + intTextH + 10) * 2);
- bc3.bcContent = strContenx3;//填充打印内容
- bc3.bcSize = BcHeight;//填充条码大小
- bc3.bcW = BcW;
- bc3.bcR = BcR;
- bcList.Add(bc3);
- //第一个文本
- Text text1 = new Text(BcStartX, BcStartY + BcHeight + 5);
- text1.txtContent = "PROD ID:" + strContenx1 + " " + ProductDesc;//填充打印内容
- text1.txtH = intTextH;
- text1.txtW = intTextW;
- bcList.Add(text1);
- //第二个文本
- Text text2 = new Text(BcStartX, BcStartY + (BcHeight + intTextH + 10) + BcHeight + 5);
- text2.txtContent = "MAC:" + strContenx2;//填充打印内容
- text2.txtH = intTextH;
- text2.txtW = intTextW;
- bcList.Add(text2);
- //第三个文本
- Text text3 = new Text(BcStartX, BcStartY + (BcHeight + intTextH + 10) * 2 + BcHeight + 5);
- text3.txtContent = "SN:" + strContenx3;//填充打印内容
- text3.txtH = intTextH;
- text3.txtW = intTextW;
- bcList.Add(text3);
- ////图片
- //Images imgPrint = new Images(10, 10);
- //imgPrint.imgName = cmbImage.SelectedItem.ToString(); ;
- //imgPrint.imgMX = int.Parse(cbMagnification.SelectedValue.ToString());
- //imgPrint.imgMY = int.Parse(cbMagnification.SelectedValue.ToString());
- //bcList.Add(imgPrint);
- GetPrintString model = new GetPrintString();
- model.Deep = Deep;
- model.Quatity = Quatity;
- model.Speed = Speed;
- model.StartX = GlobalStartX;
- model.StartY = GlobalStartY;
- model.list = bcList;
- //model.imgPath = cmbImage.SelectedItem.ToString() + ".GRF";
- model.Print();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- FillDataND();
- FillDataSD();
- FillMagnification();
- FillRatio();
- FillWidth();
- }
- private void FillDataND() //浓度
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("code", typeof(string));
- DataRow dr;
- for (int i = 1; i <= 30; i++)
- {
- dr = dt.NewRow();
- dr["code"] = i.ToString();
- dt.Rows.Add(dr);
- }
- this.coBoxND.DataSource = dt;
- this.coBoxND.DisplayMember = "code";
- this.coBoxND.ValueMember = "code";
- }
- private void FillMagnification() //图片倍数
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("code", typeof(string));
- DataRow dr;
- for (int i = 1; i <= 10; i++)
- {
- dr = dt.NewRow();
- dr["code"] = i.ToString();
- dt.Rows.Add(dr);
- }
- this.cbMagnification.DataSource = dt;
- this.cbMagnification.DisplayMember = "code";
- this.cbMagnification.ValueMember = "code";
- }
- private void FillWidth() //W
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("code", typeof(string));
- DataRow dr;
- for (int i = 1; i <= 10; i++)
- {
- dr = dt.NewRow();
- dr["code"] = i.ToString();
- dt.Rows.Add(dr);
- }
- this.cbwidth.DataSource = dt;
- this.cbwidth.DisplayMember = "code";
- this.cbwidth.ValueMember = "code";
- }
- private void FillRatio() //R
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("code", typeof(double));
- DataRow dr;
- double douSeed = 2.0;
- for (int i = 1; i <= 11; i++)
- {
- dr = dt.NewRow();
- dr["code"] = douSeed.ToString();
- dt.Rows.Add(dr);
- douSeed = douSeed + 0.1;
- }
- this.cbRatio.DataSource = dt;
- this.cbRatio.DisplayMember = "code";
- this.cbRatio.ValueMember = "code";
- }
- private void FillDataSD() //速度
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("code", typeof(string));
- dt.Columns.Add("name", typeof(string));
- DataRow dr = dt.NewRow();
- dr["code"] = "1";
- dr["name"] = "1英寸/每秒";
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr["code"] = "2";
- dr["name"] = "2英寸/每秒";
- dt.Rows.Add(dr);
- dr = dt.NewRow();
- dr["code"] = "3";
- dr["name"] = "3英寸/每秒";
- dt.Rows.Add(dr);
- this.coBoxSD.DataSource = dt;
- this.coBoxSD.DisplayMember = "name";
- this.coBoxSD.ValueMember = "code";
- }
- }
- }
|