Ejemplo n.º 1
0
        private void BtnPrnSticker_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            string WT1 = txtName.Text.Trim();
            string B1  = txtBarcode.Text.Trim();

            byte[] result_unicode = System.Text.Encoding.GetEncoding("utf-16").GetBytes("unicode test");
            byte[] result_utf8    = System.Text.Encoding.UTF8.GetBytes("TEXT 40,620,\"ARIAL.TTF\",0,12,12,\"utf8 test Wörter auf Deutsch\"");

            //TSCLIB_DLL.about();
            byte status = TSCLIB_DLL.usbportqueryprinter();     //0 = idle, 1 = head open, 16 = pause, following <ESC>!? command of TSPL manual

            TSCLIB_DLL.openport("TSC TE210");
            TSCLIB_DLL.sendcommand("SIZE 100 mm, 120 mm");
            TSCLIB_DLL.sendcommand("SPEED 4");
            TSCLIB_DLL.sendcommand("DENSITY 12");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
            TSCLIB_DLL.clearbuffer();
            //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");
            TSCLIB_DLL.windowsfont(40, 490, 48, 0, 0, 0, "Arial", "Windows Font Test");
            TSCLIB_DLL.windowsfontUnicode(40, 550, 48, 0, 0, 0, "Arial", result_unicode);
            //TSCLIB_DLL.sendcommand("PUTPCX 40,40,\"UL.PCX\"");
            TSCLIB_DLL.sendBinaryData(result_utf8, result_utf8.Length);
            TSCLIB_DLL.barcode("40", "300", "128", "80", "1", "0", "2", "2", B1);
            TSCLIB_DLL.printerfont("40", "250", "0", "0", "15", "15", WT1);
            TSCLIB_DLL.printlabel("1", "1");
            TSCLIB_DLL.closeport();
        }
Ejemplo n.º 2
0
        // Function to perform printing module!
        private void PrintDemoLabel(bool reprint)
        {
            // Read from DB to get counter. return 1 if db not found.
            // append the string with time,gate and counter
            // write time, gate, count and reprint to DB.
            // Print out ticket accordingly.
            // Update the label for counter.
            // if reprtint, do not increment the counter.
            String printformat = UpdateDB(reprint);

            // Update the counter at here
            LABEL_COUNT.Invoke(new EventHandler(delegate
            {
                LABEL_COUNT.Text = printformat.Split('/').Last();
            }));
            String gatePrint  = "Gate: " + printformat.Split('/')[1];
            String CountPrint = "Counter: " + printformat.Split('/').Last();

            TSCLIB_DLL.openport("TSC TDP-225");                                                 //Open specified printer driver
            TSCLIB_DLL.setup("40", "450", "12", "8", "1", "6", "300");                          //Setup the media size and sensor type info
            TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
            TSCLIB_DLL.barcode("100", "470", "128", "100", "0", "270", "2", "2", printformat);  //Drawing barcode
            TSCLIB_DLL.printerfont("140", "480", "5", "90", "1", "1", gatePrint);               //Print Gate number
            TSCLIB_DLL.printerfont("210", "480", "5", "90", "1", "1", CountPrint);              //Print Ticket Counter
            TSCLIB_DLL.sendcommand($"QRCODE 80,0,M,7,M,0,M2,S1,\"A{printformat}\"");            //Draw QR Code
            TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
            TSCLIB_DLL.closeport();                                                             //Close specified printer driver
        }
Ejemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Hello TSCLIB.DLL')", true);
            //TSCLIB_DLL.about();                                                                 //Show the DLL version
            TSCLIB_DLL.openport("TSC TTP-243 Plus");                                           //Open specified printer driver
            TSCLIB_DLL.setup("52", "28.5", "4", "5", "0", "0", "0");

            /*
             * width    設定標籤寬度   單位mm
             * height   設定標籤高度   單位mm
             * speed    設定列印速度   單位sec 間距1~10
             * density  設定列印濃度   單位    間距0~15
             * sensor   設定使用感應器類別 0 表示使用垂直間距感測器(gap sensor) 1 表示使用黑標感測器(black mark sensor)
             * vertical 字串型別,設定gap/black mark 垂直間距高度,單位:mm
             * offset   字串型別,設定gap/black mark 偏移距離,單位: mm,此參數若使用一般標籤時設為0
             */
            TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
            TSCLIB_DLL.barcode("80", "60", "128", "90", "1", "0", "4", "4", "3680302001393");

            /*
             * x        字串型別,條碼X方向起始點,以點(point)表示。
             * y        字串型別,條碼Y方向起始點,以點(point)表示。
             * type     字串型別
             * height   字串型別,設定條碼高度,高度以點來表示。
             * readable 字串型別,設定是否列印條碼碼文 0: 不列印碼文 1: 列印碼文
             * rotation 字串型別,設定條碼旋轉角度
             * narrow   字串型別,設定條碼窄bar 比例因子,請參考TSPL使用手冊(也會調整條滿寬度)
             * wide     字串型別,設定條碼寬bar 比例因子,請參考TSPL使用手冊(也會調整條滿寬度)
             * code     要列印的條碼
             */
            TSCLIB_DLL.printerfont("100", "200", "4", "0", "1", "2", "Bg04-11");

            /*
             * x:        字串型別,文字X方向起始點,以點(point)表示。
             * y:        字串型別,文字Y方向起始點,以點(point)表示。
             * fonttype: 字串型別,內建字型名稱,共12種。1~5
             * rotaiton: 字串型別,設定文字旋轉角度
             * xmul:     字串型別,設定文字X方向放大倍率,1~8
             * ymul:     字串型別,設定文字y方向放大倍率,1~8
             * text:     字串型別,列印文字內容
             *
             */
            TSCLIB_DLL.windowsfont(50, 270, 30, 0, 0, 0, "標楷體", "MPU-6050三軸加速度傳感器-送排針");

            /*
             * x:        整數型別,文字X方向起始點,以點(point)表示。
             * y:        整數型別,文字y方向起始點,以點(point)表示。
             * fonthigrt:整數型別,字體高度,以點(point)表示。
             * rotation :整數型別,旋轉角度,逆時鐘方向旋轉
             * fontstyle:整數型別,字體外形 0-> 標準(Normal)1-> 斜體(Italic)2-> 粗體(Bold)3-> 粗斜體(Bold and Italic)
             * fontline :整數型別,底線0-> 無底線1-> 加底線
             * szface   :字串型別,字體名稱。如: Arial, Times new Roman, 細名體, 標楷體
             * content  :字串型別,列印文字內容。
             */
            //TSCLIB_DLL.downloadpcx("C:\\ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\UL.PCX", "UL.PCX");                                         //Download PCX file into printer
            //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
            //TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");                                //Drawing PCX graphic
            TSCLIB_DLL.printlabel("1", "1");                                                    //set: 字串型別,設定列印標籤式數(set)copy: 字串型別,設定列印標籤份數(copy)
            TSCLIB_DLL.closeport();
        }
        public void Print(ExportDetail itm)
        {
            if (Export.SourceTransaction != "Sales Order")
            {
                return;
            }
            try
            {
                for (int i = 0; i < Quantity; i++)
                {
                    const int    VerticalSpace   = 150;
                    const int    HorizontalSpace = 100;
                    const string LabelFontSize   = "2.5";

                    TSCLIB_DLL.openport(Settings.Default.TSCPrinter);                                  //Open specified printer driver
                    TSCLIB_DLL.setup("101", "150", "6", "8", "0", "5", "0");                           //Setup the media size and sensor type info
                    TSCLIB_DLL.clearbuffer();                                                          //Clear image buffer
                    TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx");                                      //Download PCX file into printer

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "3", "0", "4", "4", "M.N.I.B.");
                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.25).ToString(), "3", "0", "1.75", "1.75", "Young Street, St. George's, Grenada");

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Instance.Info.Substring(0, Instance.Info.IndexOf(" - ")));
                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "3", "0", "1.75", "1.75", Instance.Info.Substring(Instance.Info.IndexOf(" - ") + 1));


                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", "2", "2", DateTime.Today.ToString("yyyy-MMM-dd"));        //Drawing printer font


                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.Barcode);


                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Export.ProductDescription);

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", Box.Description);

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", "2", "2", itm.Weight.ToString());
                    TSCLIB_DLL.printerfont((HorizontalSpace * 1.5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", "2", "2", "LBS.");

                    TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "128", "125", "1", "0", "8", "8", itm.Barcode); //Drawing barcode



                    TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
                    TSCLIB_DLL.closeport();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 5
0
 private void button1_Click(object sender, EventArgs e)
 {
     //TSCLIB_DLL.about();                                                                 //Show the DLL version
     TSCLIB_DLL.openport("TSC TTP-344M Plus");                                           //Open specified printer driver
     TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0");                           //Setup the media size and sensor type info
     TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
     TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
     TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test");        //Drawing printer font
     TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test");  //Draw windows font
     TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");                                //Drawing PCX graphic
     TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
     TSCLIB_DLL.closeport();                                                             //Close specified printer driver
 }
        private void PrintMediumSizeLabel(PurchaseOrderDetail itm)
        {
            try
            {
                const int    VerticalSpace   = 75;
                const int    HorizontalSpace = 101;
                const string LabelFontSize   = "2.5";

                TSCLIB_DLL.openport(Settings.Default.TSCPrinter);                                   //Open specified printer driver
                TSCLIB_DLL.setup("101", "50.2", "6", "8", "0", "0", "0");                           //Setup the media size and sensor type info
                TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
                TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx");                                       //Download PCX file into printer



                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "2", "0", LabelFontSize, LabelFontSize, PurchaseOrder.Vendor);

                TSCLIB_DLL.printerfont((HorizontalSpace * 5).ToString(), (VerticalSpace * 1.3).ToString(), "2", "0", LabelFontSize, LabelFontSize, PurchaseOrder.PODate.ToString("yyyy-MMM-dd"));        //Drawing printer font

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.3).ToString(), "3", "0", LabelFontSize, LabelFontSize, "Inv#");
                TSCLIB_DLL.printerfont((HorizontalSpace * 2).ToString(), (VerticalSpace * 1.3).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.PurchaseOrderNo);

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2).ToString(), "3", "0", LabelFontSize, LabelFontSize, "Item:");
                TSCLIB_DLL.printerfont((HorizontalSpace * 2.3).ToString(), (VerticalSpace * 2).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.ItemDescription);

                TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "128", "75", "0", "0", "9", "8", itm.Barcode); //Drawing barcode

                TSCLIB_DLL.printerfont((HorizontalSpace * 2).ToString(), (VerticalSpace * 4.1).ToString(), "2", "0", "5", "5", itm.Barcode);

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "SORT");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 0, VerticalSpace * 4.5, HorizontalSpace * 2, VerticalSpace * 4.5 + 50));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "GRADED");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 5.5, HorizontalSpace * 8, VerticalSpace * 5.5 + 50));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "WASH");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 6.5, HorizontalSpace * 8, VerticalSpace * 6.5 + 50));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 7.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "CHILLER#");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 7.5, HorizontalSpace * 8, VerticalSpace * 7.5 + 49));


                TSCLIB_DLL.printlabel("1", itm.LabelQty.ToString());                                                    //Print labels
                TSCLIB_DLL.closeport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 7
0
 private void btn_test_Click(object sender, EventArgs e)//测试按钮
 {
     //TSCLIB_DLL.about();                                                                //Show the DLL version
     TSCLIB_DLL.openport("TSC TDP-245");                                                 //Open specified printer driver
     TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0");                           //Setup the media size and sensor type info
     TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
     TSCLIB_DLL.about();
     TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
     TSCLIB_DLL.printerfont("100", "250", "TSS24.BF2", "0", "1", "1", "Print Font 测试");  //Drawing printer font
     // TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "GBK", "测试"); //Draw windows font
     // TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.sendcommand("PUTPCXL.PC 100,400,\"UL.PCX\"");                           //Drawing PCX graphic
     TSCLIB_DLL.printlabel("1", "1");                                                   //Print labels
     TSCLIB_DLL.closeport();                                                            //Close specified printer driver
 }
Ejemplo n.º 8
0
        public void PrintBarcode(string zXPos, string zYPos, string zFont, string zHeight, string zPrintText,
                                 string zRotation, string zNB1, string zNB2, string zBarcode)
        {
            int labelNo = 0;

            while (labelNo < Convert.ToInt16(_labelsPerLine))
            {
                GlobalVariables.Logger.WriteToInfoLog(string.Format("args: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}",
                                                                    zXPos, zYPos, zFont, zHeight, zPrintText, zRotation, zNB1, zNB2, zBarcode));
                int xPos = Convert.ToInt16(zXPos) + (labelNo * Convert.ToInt16(_zNextPos));
                GlobalVariables.Logger.WriteToInfoLog(string.Format("args: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}",
                                                                    xPos, zYPos, zFont, zHeight, zPrintText, zRotation, zNB1, zNB2, zBarcode));
                TSCLIB_DLL.barcode(xPos.ToString(), zYPos, zFont, zHeight, zPrintText, zRotation, zNB1, zNB2, zBarcode);
                labelNo++;
            }
        }
Ejemplo n.º 9
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Hello TSCLIB.DLL')", true);
     //TSCLIB_DLL.about();                                                                 //Show the DLL version
     TSCLIB_DLL.openport("TSC TTP-245C");                                                //Open specified printer driver
     TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0");                           //Setup the media size and sensor type info
     TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
     TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
     TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test");        //Drawing printer font
     TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test");  //Draw windows font
     //TSCLIB_DLL.downloadpcx("C:\\ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");                                //Drawing PCX graphic
     TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
     TSCLIB_DLL.closeport();
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 条码布局在下方
        /// </summary>
        /// <param name="m"></param>
        /// <param name="layout"></param>
        private void BarCode_BAPrint(InstrumentModel m)
        {
            // 设置标签 宽度、高度 等信息.
            // 宽 94mm  高 25mm
            // 速度为4
            // 字体浓度为8
            // 使用垂直間距感測器(gap sensor)
            // 两个标签之间的  间距为 3.5mm
            //TSCLIB_DLL.setup("35", "35", "1", "8", "1", "3.5", "0");
            // 清除缓冲信息
            TSCLIB_DLL.clearbuffer();
            // 打印条码.
            // 在 (176, 66) 的坐标上
            // 以 Code39 的条码方式
            // 条码高度 130
            // 打印条码的同时,还打印条码的文本信息.
            // 旋转的角度为 0 度
            // 条码 宽 窄 比例因子为 7:12
            // 条码内容为:barCode "200", "5", "128", "65", "1", "0", "2", "2"
            // 发送 TSPL 指令.
            // 设置 打印的方向.
            // 打印文本信息.
            // 在 (176, 16) 的坐标上
            // 字体高度为34
            // 旋转的角度为 0 度
            // 2 表示 粗体.
            // 文字没有下划线.
            // 字体为 黑体.
            // 打印的内容为:title

            TSCLIB_DLL.windowsfont(200, 10, 23, 0, 2, 0, "宋体", "名称:" + m.InstrumentName);

            TSCLIB_DLL.windowsfont(200, 50, 23, 0, 2, 0, "宋体", "仪器型号:" + m.Specification);
            TSCLIB_DLL.windowsfont(200, 90, 23, 0, 2, 0, "宋体", "资产编号:" + m.AssetsNo);
            TSCLIB_DLL.windowsfont(200, 130, 23, 0, 2, 0, "宋体", "出厂编号:" + m.SerialNo);
            TSCLIB_DLL.windowsfont(200, 170, 23, 0, 2, 0, "宋体", "管理编号:" + m.ManageNo);
            TSCLIB_DLL.barcode("280", "220", "128", "65", "1", "0", "2", "2", m.BarCode);


            // 打印.
            TSCLIB_DLL.printlabel("1", "1");
            // 关闭 打印机 端口
            TSCLIB_DLL.closeport();
        }
        public void PrintOverTSC(string model, List <LabelData> labelList)
        {
            if (labelList.Count == 0)
            {
                return;
            }

            try
            {
                TSCLIB_DLL.openport(model);

                foreach (LabelData l in labelList)
                {
                    TSCLIB_DLL.setup("75", "30", "4", "8", "0", "2", "0");
                    TSCLIB_DLL.clearbuffer();
                    TSCLIB_DLL.printerfont("24", "24", "4", "0", "1", "1", l.Device);
                    TSCLIB_DLL.windowsfont(24, 60, 32, 0, 0, 0, "Arial", l.Drawer);
                    TSCLIB_DLL.windowsfont(336, 24, 32, 0, 0, 0, "Arial", currentTime);

                    if (l.MedName.Length <= 43)
                    {
                        TSCLIB_DLL.windowsfont(16, 96, 32, 0, 0, 0, "Arial", l.MedName);
                    }
                    else
                    {
                        TSCLIB_DLL.windowsfont(16, 96, 32, 0, 0, 0, "Arial", l.MedName.Substring(0, 43));
                        TSCLIB_DLL.windowsfont(16, 128, 32, 0, 0, 0, "Arial", l.MedName.Substring(43));
                    }

                    TSCLIB_DLL.windowsfont(24, 182, 48, 0, 0, 0, "標楷體", $"數量: {l.Amount}");
                    TSCLIB_DLL.barcode("264", "166", "128", "56", "1", "0", "2", "1", l.MedID);
                    TSCLIB_DLL.printlabel("1", "1");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                TSCLIB_DLL.closeport();
            }
        }
Ejemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] result = System.Text.Encoding.GetEncoding("utf-16").GetBytes("unicode test");

            //TSCLIB_DLL.about();
            TSCLIB_DLL.openport("TSC TA210");
            TSCLIB_DLL.sendcommand("SIZE 76 mm, 20 mm");
            TSCLIB_DLL.sendcommand("SPEED 4");
            TSCLIB_DLL.sendcommand("DENSITY 12");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.clearbuffer();
            TSCLIB_DLL.barcode("335", "30", "128", "100", "1", "0", "2", "2", "3410156300419176");
            TSCLIB_DLL.barcode("35", "30", "128", "100", "1", "0", "2", "2", "3410156300419176");
            //TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test");
            //TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test");
            //TSCLIB_DLL.windowsfontUnicode(100, 350, 24, 0, 0, 0, "ARIAL", result);
            TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");
            TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");
            TSCLIB_DLL.printlabel("4", "4");
            TSCLIB_DLL.closeport();
        }
Ejemplo n.º 13
0
        public void Print(ExportDetail itm)
        {
            if (Export.SourceTransaction != "Sales Order")
            {
                return;
            }
            try
            {
                const int    VerticalSpace   = 150;
                const int    HorizontalSpace = 100;
                const string LabelFontSize   = "2.5";

                TSCLIB_DLL.openport(Settings.Default.TSCPrinter);                              //Open specified printer driver
                TSCLIB_DLL.setup("101", "150", "6", "8", "0", "5", "0");                       //Setup the media size and sensor type info
                TSCLIB_DLL.clearbuffer();                                                      //Clear image buffer
                TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx");                                  //Download PCX file into printer

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "3", "0", "4", "4", "M.N.I.B.");
                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.25).ToString(), "3", "0", "1.75", "1.75", "Young Street, St. George's, Grenada");

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Customer.CustomerName);
                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "3", "0", "1.75", "1.75", Customer.CustomerAddress);


                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", "2", "2", DateTime.Today.ToString("yyyy-MMM-dd"));         //Drawing printer font


                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.Barcode);


                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Export.ProductDescription);

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", Box.Description);

                TSCLIB_DLL.printerfont((HorizontalSpace * 3).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", itm.Weight.ToString());
                TSCLIB_DLL.printerfont((HorizontalSpace * 4).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", "LBS.");

                TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "128", "125", "1", "0", "8", "8", itm.Barcode); //Drawing barcode

                //  TSCLIB_DLL.printerfont((HorizontalSpace * 2.3).ToString(), (VerticalSpace * 8.5).ToString(), "3", "0", "2", "2", Box.Description);

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", LabelFontSize, LabelFontSize, "SORT");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4,VerticalSpace * 4,HorizontalSpace * 8,VerticalSpace * 4 + 100));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "GRADED");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 5, HorizontalSpace * 8, VerticalSpace * 5 + 100));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6).ToString(), "3", "0", LabelFontSize, LabelFontSize, "WASH");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 6, HorizontalSpace * 8, VerticalSpace * 6 + 100));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "3", "0", LabelFontSize, LabelFontSize, "CHILLER#");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 7, HorizontalSpace * 8, VerticalSpace * 7 + 100));


                TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
                TSCLIB_DLL.closeport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 14
0
        private void price4515()
        {
            int select_count = dgv_malzeme.SelectedRows.Count;

            if (select_count > 0)
            {
                List <DataGridViewRow> rows =
                    (from DataGridViewRow row in dgv_malzeme.SelectedRows
                     where !row.IsNewRow
                     orderby row.Index
                     select row).ToList <DataGridViewRow>();
                string barcode;
                string ek_sutun;
                string item_code;
                string item_name;
                string printer_name = cmb_printer.Text;
                string label_count  = labelCount.Value.ToString();

                TSCLIB_DLL.openport(printer_name);
                TSCLIB_DLL.sendcommand("SIZE 45 mm, 15 mm");
                TSCLIB_DLL.sendcommand("SPEED 4");
                TSCLIB_DLL.sendcommand("GAP 3 mm, 0 mm");
                if (cmb_priceStyle.Text == "Ribonlı yazdırım")
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON ON");
                }
                else
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                }
                TSCLIB_DLL.sendcommand("DENSITY 8");
                TSCLIB_DLL.sendcommand("DIRECTION 1");
                TSCLIB_DLL.sendcommand("SET TEAR ON");
                TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
                // byte[] result_utf8 = System.Text.Encoding.UTF8.GetBytes("TEXT 40,620,\"ARIAL.TTF\",0,12,12,\"utf8 test Wörter auf Deutsch\"");
                for (int i = 0; i < select_count; i++)
                {
                    //float dev = float.Parse(rows[i].Cells[6].Value.ToString());
                    //if (dev>0)
                    //{
                    //    barcode = rows[i].Cells[7].Value.ToString();
                    //}
                    //else
                    //{

                    //    barcode = rows[i].Cells[3].Value.ToString();
                    //}
                    barcode   = rows[i].Cells[3].Value.ToString();
                    ek_sutun  = rows[i].Cells[4].Value.ToString();
                    item_name = rows[i].Cells[2].Value.ToString();
                    item_code = rows[i].Cells[1].Value.ToString();

                    TSCLIB_DLL.clearbuffer();
                    TSCLIB_DLL.windowsfont(16, 0, 26, 0, 2, 0, "Century Gothic", CenterString(item_code, 35));
                    if (item_name.Length > 30)
                    {
                        TSCLIB_DLL.windowsfont(16, 22, 15, 0, 2, 0, "Century Gothic", CenterString(item_name, 60));
                    }
                    else
                    {
                        TSCLIB_DLL.windowsfont(16, 22, 16, 0, 2, 0, "Century Gothic", CenterString(item_name, 70));
                    }

                    //BARCODE X,Y, "code type",height,human readable,rotation,narrow,wide,[alignment,] "content "
                    //TSCLIB_DLL.sendcommand("AZTEC 50, 45, 0, 4, 1, \"ABCDE\"");

                    if (barcode.Length <= 5)
                    {
                        TSCLIB_DLL.barcode("100", "42", "128", "40", "0", "0", "2", "1", barcode);
                    }
                    else if (barcode.Length == 6)
                    {
                        TSCLIB_DLL.barcode("80", "42", "128", "40", "0", "0", "2", "1", barcode);
                    }
                    else if (barcode.Length == 7)
                    {
                        TSCLIB_DLL.barcode("70", "42", "128", "40", "0", "0", "2", "1", barcode);
                    }
                    else if (barcode.Length == 8)
                    {
                        TSCLIB_DLL.barcode("60", "42", "128", "40", "0", "0", "2", "1", barcode);
                    }
                    else if (barcode.Length == 9)
                    {
                        TSCLIB_DLL.barcode("50", "42", "128", "40", "0", "0", "2", "1", barcode);
                    }
                    else if (barcode.Length == 10)
                    {
                        TSCLIB_DLL.barcode("40", "42", "128", "40", "0", "0", "2", "1", barcode);
                    }
                    else if (barcode.Length == 11)
                    {
                        TSCLIB_DLL.barcode("27", "42", "128", "40", "0", "0", "2", "1", barcode);
                    }
                    else if (barcode.Length < 15)
                    {
                        TSCLIB_DLL.barcode("90", "42", "128", "40", "0", "0", "1", "1", barcode);
                    }
                    else if (barcode.Length < 18)
                    {
                        TSCLIB_DLL.barcode("70", "42", "128", "40", "0", "0", "1", "1", barcode);
                    }
                    else if (barcode.Length >= 18)
                    {
                        TSCLIB_DLL.barcode("45", "42", "128", "40", "0", "0", "1", "1", barcode);
                    }

                    TSCLIB_DLL.windowsfont(20, 81, 20, 0, 2, 0, "Century Gothic", CenterString(barcode, 60));
                    TSCLIB_DLL.windowsfont(20, 95, 20, 0, 2, 0, "Century Gothic", CenterString(ek_sutun, 60));
                    TSCLIB_DLL.printlabel("1", label_count);
                }
                TSCLIB_DLL.closeport();
            }
        }
Ejemplo n.º 15
0
        private void price3825()
        {
            int select_count = dgv_malzeme.SelectedRows.Count;

            if (select_count > 0)
            {
                List <DataGridViewRow> rows =
                    (from DataGridViewRow row in dgv_malzeme.SelectedRows
                     where !row.IsNewRow
                     orderby row.Index
                     select row).ToList <DataGridViewRow>();
                string barcode;
                string ek_sutun;
                string item_code;
                string item_name;
                string printer_name = cmb_printer.Text;
                string label_count  = labelCount.Value.ToString();

                TSCLIB_DLL.openport(printer_name);
                TSCLIB_DLL.sendcommand("SIZE 38 mm, 25 mm");
                TSCLIB_DLL.sendcommand("SPEED 4");
                TSCLIB_DLL.sendcommand("GAP 3 mm, 0 mm");
                if (cmb_priceStyle.Text == "Ribonlı yazdırım")
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON ON");
                }
                else
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                }
                TSCLIB_DLL.sendcommand("DENSITY 8");
                TSCLIB_DLL.sendcommand("DIRECTION 1");
                TSCLIB_DLL.sendcommand("SET TEAR ON");
                TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
                // byte[] result_utf8 = System.Text.Encoding.UTF8.GetBytes("TEXT 40,620,\"ARIAL.TTF\",0,12,12,\"utf8 test Wörter auf Deutsch\"");
                for (int i = 0; i < select_count; i++)
                {
                    barcode   = rows[i].Cells[3].Value.ToString();
                    ek_sutun  = rows[i].Cells[4].Value.ToString();
                    item_name = rows[i].Cells[2].Value.ToString();
                    item_code = rows[i].Cells[1].Value.ToString();

                    TSCLIB_DLL.clearbuffer();
                    TSCLIB_DLL.windowsfont(16, 0, 24, 0, 2, 0, "Century Gothic", CenterString(item_code, 30));
                    if (item_name.Length > 35)
                    {
                        TSCLIB_DLL.windowsfont(16, 20, 16, 0, 2, 0, "Century Gothic", CenterString(item_name.Substring(0, 35) + "-", 50));
                        TSCLIB_DLL.windowsfont(16, 32, 16, 0, 2, 0, "Century Gothic", CenterString(item_name.Substring(35, item_name.Length - 35), 50));
                    }
                    else
                    {
                        TSCLIB_DLL.windowsfont(16, 26, 16, 0, 2, 0, "Century Gothic", CenterString(item_name, 60));
                    }
                    if (radioButton1.Checked)
                    {
                        if (barcode.Length <= 5)
                        {
                            TSCLIB_DLL.barcode("80", "58", "128", "65", "0", "0", "2", "1", barcode);
                        }
                        else if (barcode.Length == 6)
                        {
                            TSCLIB_DLL.barcode("60", "58", "128", "65", "0", "0", "2", "1", barcode);
                        }
                        else if (barcode.Length == 7)
                        {
                            TSCLIB_DLL.barcode("58", "58", "128", "65", "0", "0", "2", "1", barcode);
                        }
                        else if (barcode.Length == 8)
                        {
                            TSCLIB_DLL.barcode("55", "58", "128", "65", "0", "0", "2", "1", barcode);
                        }
                        else if (barcode.Length == 9)
                        {
                            TSCLIB_DLL.barcode("20", "58", "128", "65", "0", "0", "2", "1", barcode);
                        }
                        else if (barcode.Length < 15)
                        {
                            TSCLIB_DLL.barcode("70", "58", "128", "65", "0", "0", "1", "1", barcode);
                        }
                        else if (barcode.Length < 18)
                        {
                            TSCLIB_DLL.barcode("58", "58", "128", "65", "0", "0", "1", "1", barcode);
                        }
                        else if (barcode.Length >= 18)
                        {
                            TSCLIB_DLL.barcode("25", "58", "128", "65", "0", "0", "1", "1", barcode);
                        }
                        TSCLIB_DLL.windowsfont(20, 130, 22, 0, 2, 0, "Century Gothic", CenterString(barcode, 40));
                        TSCLIB_DLL.windowsfont(20, 150, 22, 0, 2, 0, "Century Gothic", CenterString(ek_sutun, 30));
                    }
                    else
                    {
                        //TSCLIB_DLL.sendcommand("AZTEC 110, 50, 0, 7, 1, \"" + barcode + "\"");
                        TSCLIB_DLL.sendcommand("QRCODE 110, 50, Q, 5, A, 0 , M2, \"" + barcode + "\"");

                        TSCLIB_DLL.windowsfont(20, 155, 22, 0, 2, 0, "Century Gothic", CenterString(barcode, 40));
                        TSCLIB_DLL.windowsfont(20, 170, 22, 0, 2, 0, "Century Gothic", CenterString(ek_sutun, 35));
                    }
                    //BARCODE X,Y, "code type",height,human readable,rotation,narrow,wide,[alignment,] "content "

                    TSCLIB_DLL.printlabel("1", label_count);
                }
                TSCLIB_DLL.closeport();
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 条码布局在下方
        /// </summary>
        /// <param name="m"></param>
        /// <param name="layout"></param>
        private void MixCode_ABPrint(InstrumentModel m)
        {
            // 设置标签 宽度、高度 等信息.
            // 宽 94mm  高 25mm
            // 速度为4
            // 字体浓度为8
            // 使用垂直間距感測器(gap sensor)
            // 两个标签之间的  间距为 3.5mm
            //TSCLIB_DLL.setup("35", "35", "1", "8", "1", "3.5", "0");
            // 清除缓冲信息
            TSCLIB_DLL.clearbuffer();
            // 发送 TSPL 指令.
            // 设置 打印的方向.
            TSCLIB_DLL.sendcommand("DIRECTION 0");
            string strP = "QRCODE 530,140,H,6,A,0,M2,S1,\"" + m.BarCode + "\"";

            TSCLIB_DLL.sendcommand(strP);
            TSCLIB_DLL.barcode("280", "7", "128", "65", "1", "0", "2", "2", m.BarCode);
            // 打印文本信息.
            // 在 (176, 16) 的坐标上
            // 字体高度为34
            // 旋转的角度为 0 度
            // 2 表示 粗体.
            // 文字没有下划线.
            // 字体为 黑体.
            // 打印的内容为:title
            //TSCLIB_DLL.barcode("280", "7", "128", "65", "1", "0", "2", "2", m.BarCode);
            //TSCLIB_DLL.windowsfont(340, 120, 23, 0, 2, 0, "宋体", "名称:" + m.InstrumentName);
            //TSCLIB_DLL.windowsfont(340, 160, 23, 0, 2, 0, "宋体", "仪器型号:" + m.Specification);
            //TSCLIB_DLL.windowsfont(340, 200, 23, 0, 2, 0, "宋体", "资产编号:" + m.AssetsNo);
            //TSCLIB_DLL.windowsfont(340, 240, 23, 0, 2, 0, "宋体", "出厂编号:" + m.SerialNo);
            //TSCLIB_DLL.windowsfont(340, 280, 23, 0, 2, 0, "宋体", "管理编号:" + m.ManageNo);
            int    Y    = 0;
            string name = m.InstrumentName;

            if (m.InstrumentName.Length > 10)
            {
                Y    = 40;
                name = m.InstrumentName.Substring(0, 10);
            }
            TSCLIB_DLL.windowsfont(200, 110, 23, 0, 2, 0, "宋体", "名称:" + name);
            if (m.InstrumentName.Length > 10)
            {
                TSCLIB_DLL.windowsfont(200, 110 + Y, 23, 0, 2, 0, "宋体", m.InstrumentName.Substring(10, m.InstrumentName.Length - 10));
            }
            TSCLIB_DLL.windowsfont(200, 140 + Y, 23, 0, 2, 0, "宋体", "仪器型号:" + m.Specification);
            TSCLIB_DLL.windowsfont(200, 170 + Y, 23, 0, 2, 0, "宋体", "资产编号:" + m.AssetsNo);
            TSCLIB_DLL.windowsfont(200, 200 + Y, 23, 0, 2, 0, "宋体", "出厂编号:" + m.SerialNo);
            TSCLIB_DLL.windowsfont(200, 230 + Y, 23, 0, 2, 0, "宋体", "管理编号:" + m.ManageNo);
            // 打印条码.
            // 在 (176, 66) 的坐标上
            // 以 Code39 的条码方式
            // 条码高度 130
            // 打印条码的同时,还打印条码的文本信息.
            // 旋转的角度为 0 度
            // 条码 宽 窄 比例因子为 7:12
            // 条码内容为:barCode
            //TSCLIB_DLL.barcode("176", "66", "39", "130", "1", "0", "7", "12", barCode);
            // 打印.
            TSCLIB_DLL.printlabel("1", "1");
            // 关闭 打印机 端口
            TSCLIB_DLL.closeport();
        }
Ejemplo n.º 17
0
        /*
         * barcode - Arassa barcode bermeli 240001, 2500001
         * item_code - haryt kody
         * item_name - haryt ady
         * birim_code - adet, packa
         * label_count - print count, yazdyryljak etiket sany
         * birim - 100 adet, 10.5 M
         * ek_sutun - goshamaca name maglumat bermeli bolsa,
         * unit_length - mukar beriljek wagty nace sany edip bermeli 55- lik bolsa 5, 46 bolsa 6
         * dev - 1000 lukmi yada 1 likmi
         * kapak - egerde kapak adyny cykarmaly bolsa kapak adynyn yazyp ugratmaly
         * galyndy - 1 bolsa yazgy gornushi uytgeyar, 0 bolsa galyndy dal digini anlatyar
         */

        private void birimBarcodePrint(string barcode, string item_code, string item_name, string birim_code, int label_count, float birim, string ek_sutun, int unit_length, int dev, string kapak, int galyndy, int ribon)
        {
            TSCLIB_DLL.openport(printer);
            TSCLIB_DLL.sendcommand("SIZE 45 mm, 15 mm");
            TSCLIB_DLL.sendcommand("SPEED 4");
            TSCLIB_DLL.sendcommand("GAP 3 mm, 0 mm");
            if (ribon == 1)
            {
                TSCLIB_DLL.sendcommand("SET RIBBON ON");
            }
            else
            {
                TSCLIB_DLL.sendcommand("SET RIBBON OFF");
            }

            TSCLIB_DLL.sendcommand("DENSITY 8");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");

            if (birim != 1)
            {
                string nollar = "";
                for (int j = 0; j < (int)unit_length; j++)
                {
                    nollar += "0";
                }
                barcode += ((int)dev * (float)birim).ToString(nollar);
                barcode  = makeControl(barcode);
            }

            TSCLIB_DLL.clearbuffer();
            if (kapak != "")
            {
                //TSCLIB_DLL.sendcommand("TEXT 300, 60,\"2\",0,1,1,2,\"" + kapak + "\"");
                //TSCLIB_DLL.sendcommand("BOX 260, 45, 340, 100, 2");
                TSCLIB_DLL.windowsfont(300, 10, 17, 0, 2, 0, "Century Gothic", kapak);
            }
            TSCLIB_DLL.sendcommand("BOX 40, 45, 120, 100, 2");

            /*
             * TSCLIB_DLL.windowsfont(30, 40, 28, 0, 2, 0, "Century Gothic", CenterString(birim.ToString(), 9));
             * TSCLIB_DLL.windowsfont(30, 60, 20, 0, 2, 0, "Century Gothic", CenterString(birim_code, 14));
             * TSCLIB_DLL.windowsfont(30, 75, 17, 0, 2, 0, "Century Gothic", "GALYNDY");*/
            TSCLIB_DLL.sendcommand("TEXT 80, 50,\"2\",0,1,1,2,\"" + birim.ToString() + "\"");
            TSCLIB_DLL.sendcommand("TEXT 80, 70,\"2\",0,1,1,2,\"" + birim_code + "\"");
            // TSCLIB_DLL.sendcommand("TEXT 30, 70,\"1\",90,1,1,2,\"" + DateTime.Now.ToString("yy.MM.dd") + "\"");
            if (galyndy == 1)
            {
                TSCLIB_DLL.windowsfont(20, 105, 17, 90, 2, 0, "Century Gothic", DateTime.Now.ToString("dd.MM.yy HH:mm"));
            }


            TSCLIB_DLL.windowsfont(42, 10, 20, 0, 2, 0, "Century Gothic", item_code);
            TSCLIB_DLL.windowsfont(42, 25, 16, 0, 2, 0, "Century Gothic", item_name);
            TSCLIB_DLL.barcode("130", "43", "128", "40", "0", "0", "1.4", "1", barcode);
            TSCLIB_DLL.windowsfont(130, 83, 14, 0, 2, 0, "Century Gothic", barcode);
            TSCLIB_DLL.windowsfont(130, 95, 16, 0, 2, 0, "Century Gothic", ek_sutun);
            TSCLIB_DLL.printlabel("1", label_count.ToString());

            TSCLIB_DLL.closeport();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// print TTLabel
        /// </summary>
        /// <param name="ttLabelInfo">Id, Name, MarkingNumber must not be null</param>
        /// <returns>successful</returns>
        public bool PrintTTLabel_Direction_0(TTLabelInfo ttLabelInfo)
        {
            lock (syncRoot)
            {
                try
                {
                    //LogManager.Debug("PrintTTLabel ");
                    // validate
                    if (!ttLabelInfo.IsValid())
                    {
                        LogManager.Debug("!ttLabelInfo.IsValid");
                        return(false);
                    }

                    //Open specified printer driver
                    TSCLIB_DLL.openport(EnumDeviceNames.TTLabelPrinter);

                    //Setup the media size and sensor type info
                    // page size 55mm x 30mm
                    // template size 45mm x 30mm (actually 55mm x 32.5mm)
                    //TSCLIB_DLL.setup("55", "32.5", "4", "8", "0", "0", "0");
                    TSCLIB_DLL.setup("50", "30", "4", "8", "0", "0", "0");
                    TSCLIB_DLL.sendcommand("GAP 3mm, 0mm");
                    //TSCLIB_DLL.setup("52.5", "30", "4", "8", "0", "0", "0");
                    //TSCLIB_DLL.sendcommand("GAP 1.3mm, 0mm");
                    TSCLIB_DLL.sendcommand("DIRECTION 0");
                    TSCLIB_DLL.sendcommand("CLS");

                    //Clear image buffer
                    //TSCLIB_DLL.clearbuffer();

                    // DPI = 203 => 8px = 1 mm
                    //Draw windows font
                    //int startX = 54;
                    //int startY = 32;
                    int startX = 48;
                    int startY = 16;
                    //int startX = 40;
                    //int startY = 0;
                    string fontName   = "ARIAL";
                    int    fontStyle  = 2;  // Bold
                    int    fontHeight = 30;
                    int    maxChar    = 17; // max char of name at first name line

                    // Name line
                    TSCLIB_DLL.windowsfont(startX, startY, fontHeight, 0, fontStyle, 0, fontName, "Name");
                    if (ttLabelInfo.Name.Length > maxChar)
                    {
                        TSCLIB_DLL.windowsfont(startX + 70, startY, fontHeight, 0, fontStyle, 0, fontName, " : " + ttLabelInfo.Name.Substring(0, maxChar));
                        // Add name line if name is too long. Need to improve (split name by space char)
                        TSCLIB_DLL.windowsfont(startX + 100, startY += fontHeight, fontHeight, 0, fontStyle, 0, fontName, ttLabelInfo.Name.Substring(maxChar, ttLabelInfo.Name.Length - maxChar));
                    }
                    else
                    {
                        TSCLIB_DLL.windowsfont(startX + 70, startY, fontHeight, 0, fontStyle, 0, fontName, " : " + ttLabelInfo.Name);
                        startY += fontHeight;
                    }

                    // ID line
                    TSCLIB_DLL.windowsfont(startX, startY += fontHeight, fontHeight, 0, fontStyle, 0, fontName, "ID");
                    TSCLIB_DLL.windowsfont(startX + 70, startY, fontHeight, 0, fontStyle, 0, fontName, " : " + ttLabelInfo.ID);

                    //Drawing barcode
                    TSCLIB_DLL.barcode(startX.ToString(), (startY += fontHeight + 8).ToString(), "39", "72", "0", "0", "1", "3", ttLabelInfo.MarkingNumber);

                    // Drawing barcode buildin function do not let us set text size of readable line, so we need to draw a line to display MarkingNumber
                    TSCLIB_DLL.windowsfont(startX, startY += 80, fontHeight, 0, fontStyle, 0, fontName, ttLabelInfo.MarkingNumber);

                    //Print labels
                    TSCLIB_DLL.printlabel("1", "1");
                    TSCLIB_DLL.closeport();

                    //LogManager.Debug("Print OK");
                    return(true);
                }
                catch (Exception ex)
                {
                    //Debug.WriteLine("Print exception: " + ex.ToString());
                    LogManager.Debug("Print exception: " + ex.ToString());
                    return(false);
                }
            }
        }