using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 条码测试
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void myp_PrintDocument()
        {
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Drawing.Printing.PaperSize mypapersize = new System.Drawing.Printing.PaperSize("标签打印", 0, 0);
            Font myfont =new Font("宋体",12);
            myp.PageUnits = VBprinter.VB2008Print.PageExportUnit.CentiMeter;
            myp.PaperMargins = new System.Drawing.Printing.Margins(20, 20, 20, 20);
            if (checkBox1.Checked == true)
            {
                myp.IsImmediatePrintNotPreview = true;
            }
            else
            {
                myp.IsImmediatePrintNotPreview = false;
            }
            
           
            myp.NewDoc();
            myp.NewPage(mypapersize);
            myp.Currentx = 10;
            myp.DrawBar(VBprinter.VB2008Print.BarCode.Code128  ,textBox1.Text,650 ,200 ,myfont,Color.Black );
            myp.Currenty = myp.Currenty + 220;
            myp.DrawLine(new Pen(Color.Blue, 2), new PointF(0, myp.Currenty), new PointF(myp.PaperPrintWidth, myp.Currenty));
            myp.Currenty=myp.Currenty+10;
            float mywidth;
            mywidth = myp.PaperPrintWidth / 2 ;
            myp.Currentx =0;
            myp.DrawText("姓名：" + textBox2.Text, myfont);
            myp.Currentx = mywidth;
            myp.DrawText("性别：" + textBox3.Text, myfont);
            myp.NewRow(myp.LastDrawTextHeight*2);
            myp.DrawText("年龄：" + textBox4.Text, myfont);
            myp.Currentx = mywidth;
            myp.DrawText("住院号：" + textBox5.Text, myfont);
            myp.NewRow(myp.LastDrawTextHeight);
            myp.EndDoc();

        }

        private void button2_Click(object sender, EventArgs e)
        {

        }
    }
}
