示例#1
0
        /// <summary>
        /// 照片写入
        /// </summary>
        private void NFC()
        {
            byte[] _nfcTagBmpData       = b2d.GetDataToSend(bp);
            int    _nfcTagBmpDataLength = b2d.SendLength;

            nfcTag.SendBmp2NfcTag(_nfcTagBmpData, _nfcTagBmpDataLength);
        }
示例#2
0
        /// <summary>
        /// 二维码生成
        /// </summary>
        /// <param name="strHZ"></param>
        /// <param name="strGoodsName"></param>
        /// <param name="strQty"></param>
        public void GetImg(string strHZ, string strGoodsName, string strQty, string strGoodsCode, string strBatch, string strBarcode)
        {
            try
            {
                b2d    = new Bmp2Bmp2Data();
                nfcTag = new NfcTag(new WI());

                string strPath = Application.StartupPath + "\\img\\" + strHZ + ".bmp";

                strHZ = "物料:" + strGoodsCode + ",批次:" + strBatch + ",数量:" + strQty + ",单号:" + Globels.strOrderNo + "," + strBarcode;
                int    nLen     = strHZ.Length;
                byte[] fileData = Encoding.GetEncoding("GB2312").GetBytes(strHZ);
                int    nLen2    = fileData.Length;

                Barcode.Make(fileData, nLen2, 0, 0, 0, strPath, 2);
                Thread.Sleep(100);
                FileStream fs     = new FileStream(strPath, FileMode.Open, FileAccess.Read);
                Byte[]     mybyte = new byte[fs.Length];
                fs.Read(mybyte, 0, mybyte.Length);
                fs.Close();

                MemoryStream ms     = new MemoryStream(mybyte);
                Bitmap       myimge = new Bitmap(ms);

                Bitmap   image = new Bitmap(296, 128);                                //初始化大小
                Graphics g     = Graphics.FromImage(image);
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //设置图片质量

                g.Clear(Color.White);
                g.DrawImage(myimge, 190, 15, 80, 80);
                Font  f1 = new Font("Arial ", 40); //, System.Drawing.FontStyle.Bold);//设置字体样式,大小
                Font  f2 = new Font("Arial ", 30); //, System.Drawing.FontStyle.Bold);//设置字体样式,大小
                Font  f3 = new Font("Arial ", 12); //, System.Drawing.FontStyle.Bold);//设置字体样式,大小
                Font  f4 = new Font("Arial ", 10); //, System.Drawing.FontStyle.Bold);//设置字体样式,大小
                Brush b  = new SolidBrush(Color.Black);
                Brush r  = new SolidBrush(Color.White);
                //g.DrawString(strHZ, f3, b, 15, 60);//设置位置

                g.DrawString("名称:" + strGoodsName, f4, b, 4, 10);     //设置位置
                g.DrawString("数量:" + strQty, f4, b, 4, 30);           //设置位置
                g.DrawString("保质期:" + "24小时", f4, b, 4, 50);          //设置位置
                g.DrawString("负责人:" + Globels.strName, f4, b, 4, 70); //设置位置
                //g.DrawString("订单:" + comOrderNo.Text, f4, b, 4, 90);//设置位置

                g.DrawString("日期:" + DateTime.Now.ToString("yyyy-MM-dd"), f4, b, 178, 105); //设置位置

                image.Save(strPath, ImageFormat.Jpeg);                                      //自己创建一个文件夹,放入生成的图片(根目录下)

                //二维码图片nfc写入
                bp = new Bmp2BmpProduct(new TagViewSize((EnumTagViewSizeID)(0x21), 0x00),
                                        new Bitmap(image)
                                        );
                b2d.ImageYuLan(bp);

                byte[] _nfcTagBmpData       = b2d.GetDataToSend(bp);
                int    _nfcTagBmpDataLength = b2d.SendLength;

                nfcTag.SendBmp2NfcTag(_nfcTagBmpData, _nfcTagBmpDataLength);

                //MessageBox.Show("OK");
            }
            catch (Exception ex)
            {
                //untCommon.ErrorMsg("二维码生成异常!:" + ex.Message);
                lblTS.Text = "系统提示:" + "二维码生成异常!:" + ex.Message;
            }
        }