using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace FreedomKeyboard { public partial class frmMain : Form { private Keyboard fk; public frmMain() { InitializeComponent(); } private void mnuExit_Click(object sender, EventArgs e) { this.Close(); } private void frmMain_Load(object sender, EventArgs e) { fk = new Keyboard(); this.spKey.DataReceived += new SerialDataReceivedEventHandler(SerialEvent); //fk.RawKeyPress_Event += new Keyboard.KeyPress(data); } private void btnStart_Click(object sender, EventArgs e) { //fk.Enable = true; this.spKey.Open(); } private void data(string e) { this.txtKey.Text = e.ToString(); } private void SerialEvent(object sender, SerialDataReceivedEventArgs e) { //string s = ""; //s = new string((char)this.spKey.ReadChar(), 1); char x; while (spKey.BytesToRead != 0) { x = (char)spKey.ReadChar(); this.fk.Key(x); //this.fk.Key((char)spKey.ReadChar()); } //MessageBox.Show(s); } } }