⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readerform.cs

📁 RFID Reader SampleCode
💻 CS
📖 第 1 页 / 共 3 页
字号:
// --------------------------------------------------------------------
// FILENAME: ReaderForm.cs
//
// Copyright(c) 2005 Symbol Technologies Inc. All rights reserved.
//
// DESCRIPTION:
//
// NOTES:
//
// 
//--------------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using Symbol;
using Symbol.RFID;

namespace CS_RFIDSample2
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class ReaderForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ColumnHeader Number;
		private System.Windows.Forms.ColumnHeader Tags;
		private System.Windows.Forms.ColumnHeader Actions;
		private System.Windows.Forms.Timer ReaderTimer;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItemFile;
		private System.Windows.Forms.MenuItem menuItemClearList;
		private System.Windows.Forms.MenuItem menuItemExit;
		private System.Windows.Forms.MenuItem menuItemActions;
		private System.Windows.Forms.MenuItem menuItemFind;
		private System.Windows.Forms.MenuItem menuItemProgram;
		private System.Windows.Forms.MenuItem menuItemLock;
		private System.Windows.Forms.MenuItem menuItemKill;
		private System.Windows.Forms.MenuItem menuItemErase;
		private System.Windows.Forms.MenuItem menuItemHelp;
		private System.Windows.Forms.MenuItem menuItemAbout;
		private System.Windows.Forms.StatusBar ReaderStatus;
		private System.Windows.Forms.ListView ReaderDataListView;
		
		private Symbol.RFID.Reader MyReader = null;
		private Symbol.RFID.ReaderData MyReaderData = null;
		private Symbol.RFID.ReaderData FindReaderData = null;
		private System.EventHandler MyEventHandler = null;
		private System.EventHandler FindEventHandler = null;
		private Symbol.RFID.Reader.TriggerEventHandler MyTriggerHandler = null;
		private bool ClearListFlag = false;
		private System.Windows.Forms.MenuItem menuItemTagType;
		private System.Windows.Forms.MenuItem menuItemClass0;
		private System.Windows.Forms.MenuItem menuItemClass1;
		private System.Windows.Forms.MenuItem menuItemGen2Type;
		private System.Windows.Forms.MenuItem menuItemSettings;
		private System.Windows.Forms.MenuItem menuItemGeneral;
		private System.Windows.Forms.MenuItem menuItemGen2;
		private bool TriggerReleasedFlag = false;
		private TagMask prevTagMask = null;
		private byte verifyAttempts = 3;
		private byte opAttempts = 3;
		private byte lockCode = 255;
			
		public ReaderForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		}

		/// <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.ReaderDataListView = new System.Windows.Forms.ListView();
            this.Number = new System.Windows.Forms.ColumnHeader();
            this.Tags = new System.Windows.Forms.ColumnHeader();
            this.Actions = new System.Windows.Forms.ColumnHeader();
            this.ReaderTimer = new System.Windows.Forms.Timer();
            this.ReaderStatus = new System.Windows.Forms.StatusBar();
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.menuItemFile = new System.Windows.Forms.MenuItem();
            this.menuItemClearList = new System.Windows.Forms.MenuItem();
            this.menuItemExit = new System.Windows.Forms.MenuItem();
            this.menuItemActions = new System.Windows.Forms.MenuItem();
            this.menuItemFind = new System.Windows.Forms.MenuItem();
            this.menuItemProgram = new System.Windows.Forms.MenuItem();
            this.menuItemLock = new System.Windows.Forms.MenuItem();
            this.menuItemKill = new System.Windows.Forms.MenuItem();
            this.menuItemErase = new System.Windows.Forms.MenuItem();
            this.menuItemTagType = new System.Windows.Forms.MenuItem();
            this.menuItemClass0 = new System.Windows.Forms.MenuItem();
            this.menuItemClass1 = new System.Windows.Forms.MenuItem();
            this.menuItemGen2Type = new System.Windows.Forms.MenuItem();
            this.menuItemSettings = new System.Windows.Forms.MenuItem();
            this.menuItemGeneral = new System.Windows.Forms.MenuItem();
            this.menuItemGen2 = new System.Windows.Forms.MenuItem();
            this.menuItemHelp = new System.Windows.Forms.MenuItem();
            this.menuItemAbout = new System.Windows.Forms.MenuItem();
            this.SuspendLayout();
            // 
            // ReaderDataListView
            // 
            this.ReaderDataListView.Columns.Add(this.Number);
            this.ReaderDataListView.Columns.Add(this.Tags);
            this.ReaderDataListView.Columns.Add(this.Actions);
            this.ReaderDataListView.FullRowSelect = true;
            this.ReaderDataListView.Location = new System.Drawing.Point(0, 24);
            this.ReaderDataListView.Name = "ReaderDataListView";
            this.ReaderDataListView.Size = new System.Drawing.Size(240, 240);
            this.ReaderDataListView.TabIndex = 1;
            this.ReaderDataListView.View = System.Windows.Forms.View.Details;
            // 
            // Number
            // 
            this.Number.Text = "#";
            this.Number.Width = 22;
            // 
            // Tags
            // 
            this.Tags.Text = "Tags";
            this.Tags.Width = 175;
            // 
            // Actions
            // 
            this.Actions.Text = "Actions";
            this.Actions.Width = 44;
            // 
            // ReaderTimer
            // 
            this.ReaderTimer.Tick += new System.EventHandler(this.ReaderTimer_Tick);
            // 
            // ReaderStatus
            // 
            this.ReaderStatus.Location = new System.Drawing.Point(0, 310);
            this.ReaderStatus.Name = "ReaderStatus";
            this.ReaderStatus.Size = new System.Drawing.Size(243, 24);
           
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.Add(this.menuItemFile);
            this.mainMenu1.MenuItems.Add(this.menuItemActions);
            this.mainMenu1.MenuItems.Add(this.menuItemSettings);
            this.mainMenu1.MenuItems.Add(this.menuItemHelp);
            // 
            // menuItemFile
            // 
            this.menuItemFile.MenuItems.Add(this.menuItemClearList);
            this.menuItemFile.MenuItems.Add(this.menuItemExit);
            this.menuItemFile.Text = "File";
            // 
            // menuItemClearList
            // 
            this.menuItemClearList.Text = "Clear List";
            this.menuItemClearList.Click += new System.EventHandler(this.ClearListMenu_Click);
            // 
            // menuItemExit
            // 
            this.menuItemExit.Text = "Exit";
            this.menuItemExit.Click += new System.EventHandler(this.ExitMenu_Click);
            // 
            // menuItemActions
            // 
            this.menuItemActions.MenuItems.Add(this.menuItemFind);
            this.menuItemActions.MenuItems.Add(this.menuItemProgram);
            this.menuItemActions.MenuItems.Add(this.menuItemLock);
            this.menuItemActions.MenuItems.Add(this.menuItemKill);
            this.menuItemActions.MenuItems.Add(this.menuItemErase);
            this.menuItemActions.MenuItems.Add(this.menuItemTagType);
            this.menuItemActions.Text = "Actions";
            // 
            // menuItemFind
            // 
            this.menuItemFind.Text = "Find";
            this.menuItemFind.Click += new System.EventHandler(this.FindMenu_Click);
            // 
            // menuItemProgram
            // 
            this.menuItemProgram.Text = "Program";
            this.menuItemProgram.Click += new System.EventHandler(this.ProgramMenu_Click);
            // 
            // menuItemLock
            // 
            this.menuItemLock.Text = "Lock";
            this.menuItemLock.Click += new System.EventHandler(this.LockMenu_Click);
            // 
            // menuItemKill
            // 
            this.menuItemKill.Text = "Kill";
            this.menuItemKill.Click += new System.EventHandler(this.KillMenu_Click);
            // 
            // menuItemErase
            // 
            this.menuItemErase.Text = "Erase";
            this.menuItemErase.Click += new System.EventHandler(this.EraseMenu_Click);
            // 
            // menuItemTagType
            // 
            this.menuItemTagType.MenuItems.Add(this.menuItemClass0);
            this.menuItemTagType.MenuItems.Add(this.menuItemClass1);
            this.menuItemTagType.MenuItems.Add(this.menuItemGen2Type);
            this.menuItemTagType.Text = "Tag Type";
            // 
            // menuItemClass0
            // 
            this.menuItemClass0.Text = "Class 0";
            this.menuItemClass0.Click += new System.EventHandler(this.menuItemClass0_Click);
            // 
            // menuItemClass1
            // 
            this.menuItemClass1.Checked = true;
            this.menuItemClass1.Text = "Class 1";
            this.menuItemClass1.Click += new System.EventHandler(this.menuItemClass1_Click);
            // 
            // menuItemGen2Type
            // 
            this.menuItemGen2Type.Text = "Gen2";
            this.menuItemGen2Type.Click += new System.EventHandler(this.menuItemGen2Type_Click);
            // 
            // menuItemSettings
            // 
            this.menuItemSettings.MenuItems.Add(this.menuItemGeneral);
            this.menuItemSettings.MenuItems.Add(this.menuItemGen2);
            this.menuItemSettings.Text = "Settings";
            // 
            // menuItemGeneral
            // 
            this.menuItemGeneral.Text = "General";
            this.menuItemGeneral.Click += new System.EventHandler(this.menuItemGeneral_Click);
            // 
            // menuItemGen2
            // 
            this.menuItemGen2.Text = "Gen2";
            this.menuItemGen2.Click += new System.EventHandler(this.menuItemGen2_Click);
            // 
            // menuItemHelp
            // 
            this.menuItemHelp.MenuItems.Add(this.menuItemAbout);
            this.menuItemHelp.Text = "Help";
            // 
            // menuItemAbout
            // 
            this.menuItemAbout.Text = "About";
            this.menuItemAbout.Click += new System.EventHandler(this.AboutMenu_Click);
            // 
            // ReaderForm
            // 
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
            this.BackColor = System.Drawing.Color.White;
            this.ClientSize = new System.Drawing.Size(243, 334);
            this.Controls.Add(this.ReaderStatus);
            this.Controls.Add(this.ReaderDataListView);
            this.Menu = this.mainMenu1;
            this.MinimizeBox = false;
            this.Name = "ReaderForm";
            this.Text = "RFID Reader Form";
            this.Load += new System.EventHandler(this.ReaderForm_Load);
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
        /// This function scales down the given Form & its child controls in order to
        /// make them completely viewable, based on the screen width & height.
        /// </summary>
        public static void ScaleDown(System.Windows.Forms.Form frm)
        {
            int scrWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            int scrHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            if (scrWidth < frm.Width)
                foreach (System.Windows.Forms.Control cntrl in frm.Controls)
                {
                    cntrl.Width = ((cntrl.Width) * (scrWidth)) / (frm.Width);
                    cntrl.Left = ((cntrl.Left) * (scrWidth)) / (frm.Width);
                }
            if (scrHeight < frm.Height)
                foreach (System.Windows.Forms.Control cntrl in frm.Controls)
                {
                    cntrl.Height = ((cntrl.Height) * (scrHeight)) / (frm.Height);
                    cntrl.Top = ((cntrl.Top) * (scrHeight)) / (frm.Height);
                }

        }

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

		static void Main() 
		{
            ReaderForm rf = new ReaderForm();
            ScaleDown(rf);
            Application.Run(rf);
		}

		/// <summary>
		/// Occurs before the form is displayed for the first time.
		/// </summary>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -