Ejemplo n.º 1
0
        public void PublicPrintLabel(Dictionary <string, string> dic)
        {
            //  StripStatusLabelPatch.Text = "Label File: " + filepatch;
            string LabDir    = ReadIniFile.IniReadValue("TEST_INPUT", "Patch", IniFilePath);
            string filepatch = string.Format(@"{0}\{1}\{2}", LabDir.IndexOf(":") != -1 ? LabDir : LabDir + ":", cbwo.Text, cbroute.Text + ".lab");

            string PrintQty = OperateIni.IniReadValue("TEST_INPUT", "LabelQty", IniFilePath);
            string
                   coordinateX = OperateIni.IniReadValue("TEST_INPUT", "LabelX", IniFilePath);
            string coordinateY = OperateIni.IniReadValue("TEST_INPUT", "LabelY", IniFilePath);

            if (!File.Exists(filepatch))  //判断条码文件是否存在
            {
                SendPrgMsg(mLogMsgType.Error, "条码档没有找到,路径:" + filepatch);
                return;
            }

            try
            {
                lbl.Documents.Open(filepatch, false);// 调用设计好的label文件
                Document doc = lbl.ActiveDocument;
                SendPrgMsg(mLogMsgType.Incoming, "清空模板变量...");
                for (int i = 0; i < doc.Variables.FormVariables.Count; i++)
                {
                    doc.Variables.FormVariables.Item(doc.Variables.FormVariables.Item(i + 1).Name).Value = "";
                }
                SendPrgMsg(mLogMsgType.Incoming, string.Format("模板变量清空完成,共计{0}个...", doc.Variables.FormVariables.Count));
                foreach (KeyValuePair <string, string> _DicKeyValues in dic)
                {
                    try
                    {
                        doc.Variables.FormVariables.Item(_DicKeyValues.Key).Value = _DicKeyValues.Value; //给参数传值
                        SendPrgMsg(mLogMsgType.Outgoing, string.Format("填充打印变量完成:{0}->{1}", _DicKeyValues.Key, _DicKeyValues.Value));
                    }
                    catch
                    {
                    }
                }

                int Num = Convert.ToInt32(PrintQty);        //打印数量
                doc.Format.MarginLeft = (Convert.ToInt32(coordinateX)) * 100;
                doc.Format.MarginTop  = (Convert.ToInt32(coordinateY)) * 100;
                doc.PrintDocument(Num);               //打印
                SendPrgMsg(mLogMsgType.Normal, "打印完成");
            }
            catch (Exception ex)
            {
                SendPrgMsg(mLogMsgType.Error, "发生异常" + ex.Message);
            }
            finally
            {
                // lbl.Quit(); //退出
            }
        }
Ejemplo n.º 2
0
 private void ToolPrintlabel_Click(object sender, EventArgs e)
 {
     ToolPrintlabel.Checked = !ToolPrintlabel.Checked;
     if (ToolPrintlabel.Checked)
     {
         OperateIni.IniWriteValue("TEST_INPUT", "PrintLabel", "1", IniFilePath);
         SendPrgMsg(mLogMsgType.Warning, "打印条码");
     }
     else
     {
         OperateIni.IniWriteValue("TEST_INPUT", "PrintLabel", "0", IniFilePath);
         SendPrgMsg(mLogMsgType.Warning, "打印条码取消");
     }
 }