예제 #1
0
        /// <summary>
        /// 打印委托
        /// </summary>
        /// <param name="g">Graphics</param>
        /// <param name="num">打印第几条</param>
        /// <param name="a">是否继续打印</param>
        private void DrawContent(Graphics g, int num, ref bool a)
        {
            //获得打印数据
            if (num < 0)
            {
                return;
            }
            BarCodeBean barCodeBean = this._printDataList[num];

            //打印基本设置
            int  pageLeft   = Convert.ToInt32(_printSetting.PageLeft) * 4;
            int  pageTop    = Convert.ToInt32(_printSetting.PageTop) * 4;
            uint codeHeight = Convert.ToUInt32(_printSetting.BarCodeHeight) * 4;
            int  wordSize   = Convert.ToInt32(_printSetting.WordSize);
            int  codeSize   = Convert.ToInt32(_printSetting.BarCodeSize);
            Font wordFont   = new Font(_printSetting.WordType, wordSize);
            Font wordFont2  = new Font(_printSetting.WordType, wordSize + 2);
            Font codeFont   = new Font(_printSetting.WordType, codeSize);

            //画出打印内容
            g.DrawString(barCodeBean.Grade, wordFont2, Brushes.Black, pageLeft + 182, pageTop + 8);
            g.DrawString(barCodeBean.Brand, wordFont, Brushes.Black, pageLeft + 190, pageTop + 54);

            BarCode barCode = new BarCode();

            barCode.ValueFont = codeFont;
            barCode.Height    = codeHeight;
            System.Drawing.Bitmap imgBarCode = barCode.GetCodeImage(barCodeBean.BarCode, BarCode.Encode.Code128C);
            g.DrawImage(imgBarCode, pageLeft, pageTop + 255);
            g.DrawString(barCodeBean.ReadCode, codeFont, Brushes.Black, pageLeft, pageTop + 258 + imgBarCode.Height);
        }
예제 #2
0
        private void DoPrint2(Graphics g, int count, ref bool bHadMore)
        {
            if (count < 0)
            {
                return;
            }
            JToken printData = this.printDataList[count];

            int  pageLeft   = int.Parse(this.txtPageLeft.Text) * 4;
            int  pageTop    = int.Parse(this.txtPageTop.Text) * 4;
            uint codeHeight = uint.Parse(this.txtBarCodeHeight.Text) * 4;
            int  wordSize   = int.Parse(this.txtWordSize.Text);
            int  codeSize   = int.Parse(this.txtCodeSize.Text);
            Font wordFont   = new Font(this.txtWordType.Text, wordSize);
            Font wordFont2  = new Font(this.txtWordType.Text, wordSize + 2);
            Font codeFont   = new Font(this.txtWordType.Text, codeSize);


            g.DrawString(printData["grade"].ToString(), wordFont2, Brushes.Black, pageLeft + 182, pageTop + 8);
            g.DrawString(printData["brand"].ToString(), wordFont, Brushes.Black, pageLeft + 190, pageTop + 54);

            BarCode barCode = new BarCode();

            barCode.ValueFont = codeFont;
            barCode.Height    = codeHeight;
            barCode.ReadCode  = this.txtReadCode.Text;
            System.Drawing.Bitmap imgBarCode = barCode.GetCodeImage(printData["barcode"].ToString(), BarCode.Encode.Code128C);
            g.DrawImage(imgBarCode, pageLeft, pageTop + 255);
            g.DrawString(printData["readcode"].ToString(), codeFont, Brushes.Black, pageLeft, pageTop + 258 + imgBarCode.Height);
        }
예제 #3
0
        private void DoPrint(Graphics g, int count, ref bool a)
        {
            int  pageLeft   = int.Parse(this.txtPageLeft.Text) * 4;
            int  pageTop    = int.Parse(this.txtPageTop.Text) * 4;
            uint codeHeight = uint.Parse(this.txtBarCodeHeight.Text) * 4;
            int  wordSize   = int.Parse(this.txtWordSize.Text);
            int  codeSize   = int.Parse(this.txtCodeSize.Text);
            Font wordFont   = new Font(this.txtWordType.Text, wordSize);
            Font wordFont2  = new Font(this.txtWordType.Text, wordSize + 2);
            Font codeFont   = new Font(this.txtWordType.Text, codeSize);

            //通过GDI+绘制打印文档
            //g.DrawLine(new Pen(Color.Black, (float)3.00), 100, 185, 720, 185);

            g.DrawString(this.txtGrade.Text, wordFont2, Brushes.Black, pageLeft + 182, pageTop + 8);
            g.DrawString(this.txtBrand.Text, wordFont, Brushes.Black, pageLeft + 190, pageTop + 54);

            //产品名称
            g.DrawString("鸡大腿", wordFont, Brushes.Black, pageLeft + 35, pageTop + 54);
            //产品规格
            g.DrawString("58*39*10.5cm(9.5kg/1个)", wordFont, Brushes.Black, pageLeft + 35, pageTop + 77);
            //配料
            g.DrawString("酱油", wordFont, Brushes.Black, pageLeft + 35, pageTop + 101);

            //保质期
            g.DrawString("三个月", wordFont, Brushes.Black, pageLeft + 35, pageTop + 189);
            //产地
            g.DrawString("上海市浦东新区", wordFont, Brushes.Black, pageLeft + 190, pageTop + 167);
            //电话
            g.DrawString("021-88888888", wordFont, Brushes.Black, pageLeft + 190, pageTop + 192);
            //净含量
            g.DrawString("1580g", wordFont2, Brushes.Black, pageLeft + 35, pageTop + 230);

            BarCode barCode = new BarCode();

            barCode.ValueFont = codeFont;
            barCode.Height    = codeHeight;
            barCode.ReadCode  = this.txtReadCode.Text;
            System.Drawing.Bitmap imgBarCode = barCode.GetCodeImage(this.txtBarCode.Text, BarCode.Encode.Code128C);
            g.DrawImage(imgBarCode, pageLeft, pageTop + 255);
            g.DrawString(this.txtReadCode.Text, codeFont, Brushes.Black, pageLeft, pageTop + 258 + imgBarCode.Height);
        }