Intermec 700 開發體驗(1)

近來試着在 Intermec 700 上开发带有条码扫描功能的应用程序,初步得出开发时需环境如下:
1. Visual Studio 2003 軟件安裝
2. Microsoft ActiveSync 4.5 中文版安裝,來源自己上網搜尋
3. Intermec开发环境(在Intermec官方网站上下载安装包,后安装即有对应环境,且还有User Guide,该 User Guide对入门很有帮助)
1) Data Collection Resource Kit: 读扫描条码 / SQL Ce操作
2) Device Management Resource Kit: 设备管理操作
3) Device Resource Kit: 声音设备操作
4) Bluetooth Resource Kit: 蓝牙设备操作
5) Printing Resource Kit: 打印设备操作
6) Communications Resource Kit: 通讯设备操作
4. 开发简单的扫描条码的应用程序,请参考Data Collection Resource Kit User Guide的 Net Class Guides的 Using the barcodeReader Class 下的说明及案例
5. 自编程序如下:
1) 实现功能:在Text 框中显示當前扫描到的条码,在 ListBox 框中顯示所有的條碼
2) 在 vs 2003中需引用 Intermec Data Collection dll 文件
3) 編寫 Code 如下
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

namespace SmartDeviceApplication2
{
 /// <summary>
 /// Summary description for Form1.
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  //定义接收barcode的对象
  private Intermec.DataCollection.BarcodeReader MyReaderData = null;
  
  //显示扫描到的barcode(当前)
  private System.Windows.Forms.TextBox txtScan;
  //显示扫描到的barcode(历史)
  private System.Windows.Forms.ListBox ReaderDataListBox;
  //退出按钮
  private System.Windows.Forms.Button Back;
  
  private System.Windows.Forms.Label label1;

  public Form1()
  {
   //
   // Required for Windows Form Designer support
   //
   InitializeComponent();

   //
   // TODO: Add any constructor code after InitializeComponent call
   //
  }
  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   base.Dispose( disposing );
  }
  #region Windows Form Designer generated code
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
   this.txtScan = new System.Windows.Forms.TextBox();
   this.ReaderDataListBox = new System.Windows.Forms.ListBox();
   this.Back = new System.Windows.Forms.Button();
   this.label1 = new System.Windows.Forms.Label();
   //
   // txtScan
   //
   this.txtScan.Location = new System.Drawing.Point(16, 30);
   this.txtScan.Size = new System.Drawing.Size(192, 21);
   this.txtScan.Text = "txtScan";
   //
   // ReaderDataListBox
   //
   this.ReaderDataListBox.Location = new System.Drawing.Point(16, 56);
   this.ReaderDataListBox.Size = new System.Drawing.Size(192, 182);
   //
   // Back
   //
   this.Back.Location = new System.Drawing.Point(112, 248);
   this.Back.Text = "Back";
   this.Back.Click += new System.EventHandler(this.Back_Click);
   //
   // label1
   //
   this.label1.Font = new System.Drawing.Font("SimSun", 12F, System.Drawing.FontStyle.Regular);
   this.label1.Location = new System.Drawing.Point(16, 8);
   this.label1.Text = "Scanning";
   //
   // Form1
   //
   this.Controls.Add(this.label1);
   this.Controls.Add(this.Back);
   this.Controls.Add(this.ReaderDataListBox);
   this.Controls.Add(this.txtScan);
   this.Text = "Form1";
   this.Load += new System.EventHandler(this.Form1_Load);
   this.Closed += new System.EventHandler(this.Form1_Closed);

  }
  #endregion

  /// <summary>
  /// The main entry point for the application.
  /// </summary>

  static void Main()
  {
   Application.Run(new Form1());
  }

  private void Form1_Load(object sender, System.EventArgs e)
  {
   //取得barcodeReader句柄
   MyReaderData = new Intermec.DataCollection.BarcodeReader();
   
   // Create event handler delegate
   MyReaderData.BarcodeRead += new Intermec.DataCollection.BarcodeReadEventHandler(MyReader_ReadNotify);

   //This method tells BarcodeReader to start reading and to fire an event when a bar code is read.
   MyReaderData.ThreadedRead(true);   //本语句必须存在,否则将无法触发 MyReader_ReadNotify 过程
  }

  private void MyReader_ReadNotify(object sender, Intermec.DataCollection.BarcodeReadEventArgs e)
  {
   //显示当前 扫描到的barcode
   txtScan.Text  = e.strDataBuffer;

   //将当前扫描到的barcode 写到历史barcode中
   ReaderDataListBox.Items.Add(e.strDataBuffer);   
  }

  private void Back_Click(object sender, System.EventArgs e)
  {
   //关闭程序
   this.Close();
  }

  private void Form1_Closed(object sender, System.EventArgs e)
  {
   //停止扫描
   Stop_Scan();
  }

  public void Stop_Scan()
  {
   // If you have a scanner
   if(MyReaderData != null)
   {    
    MyReaderData.BarcodeRead -= new Intermec.DataCollection.BarcodeReadEventHandler(MyReader_ReadNotify);
    // Free it up
    MyReaderData.Dispose();

    // Indicate you no longer have a scanner
    MyReaderData = null;
   }
  }

  
 }
}

 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值