最近开发一个pda程序。
扫描事件,不同的类型的pda,不同的代码,只要一扫描,就把扫描的数据进入他们各自类的buffer中,再取到txt_barcode.Text中
--------------------------------------------------------------------- MyReader = new Symbol.Barcode.Reader(); MyReader.ReadNotify += new EventHandler(MyReader_ReadNotify);
private void MyReader_ReadNotify(object sender, EventArgs e) { txt_barcode.Text = MyReaderData.Text;
、 }
-------------------------------------------------------------------- Scanner sner = new Scanner();
sner.OnDone+=new EventHandler(sner_OnDone); private void sner_OnDone(object sender,EventArgs e)
{
byte[] b=new byte[sner.MAX_NUM_MULTI_CODE];
sner.Input(txt_barcode.Text,0,sner.MAX_NUM_MULTI_CODE); }
--------------------------------------------------------------------怎么才能 封装他们,使用一个类。供其他代码使用
扫描事件,不同的类型的pda,不同的代码,只要一扫描,就把扫描的数据进入他们各自类的buffer中,再取到txt_barcode.Text中
--------------------------------------------------------------------- MyReader = new Symbol.Barcode.Reader(); MyReader.ReadNotify += new EventHandler(MyReader_ReadNotify);
private void MyReader_ReadNotify(object sender, EventArgs e) { txt_barcode.Text = MyReaderData.Text;
、 }
-------------------------------------------------------------------- Scanner sner = new Scanner();
sner.OnDone+=new EventHandler(sner_OnDone); private void sner_OnDone(object sender,EventArgs e)
{
byte[] b=new byte[sner.MAX_NUM_MULTI_CODE];
sner.Input(txt_barcode.Text,0,sner.MAX_NUM_MULTI_CODE); }
--------------------------------------------------------------------怎么才能 封装他们,使用一个类。供其他代码使用
public string Scan()
{
}
然后,Scan里面去执行你扫描的任务并返回string,通过类实例访问Scan,如果是
public static string Scan()
那么可以直接通过类名访问,不需创建实例