sl@0: using System; sl@0: using System.Drawing; sl@0: using System.Collections; sl@0: using System.ComponentModel; sl@0: using System.Windows.Forms; sl@0: using System.Data; sl@6: using Devices.RemoteControl; sl@0: sl@0: namespace RemoteControlSample sl@0: { sl@0: /// sl@0: /// Summary description for Form1. sl@0: /// sl@0: public class Form1 : System.Windows.Forms.Form sl@0: { sl@0: /// sl@0: /// Required designer variable. sl@0: /// sl@0: private System.ComponentModel.Container components = null; sl@0: private System.Windows.Forms.Label label1; sl@0: private RemoteControlDevice _remote; sl@0: private System.Windows.Forms.Label label2; sl@0: private Timer _timer; sl@0: sl@0: public Form1() sl@0: { sl@0: // sl@0: // Required for Windows Form Designer support sl@0: // sl@0: InitializeComponent(); sl@0: sl@0: _timer = new Timer(); sl@0: _timer.Interval = 3000; sl@0: _timer.Enabled = false; sl@0: _timer.Tick +=new EventHandler(_timer_Tick); sl@0: _remote = new RemoteControlDevice(); sl@6: _remote.ButtonPressed +=new Devices.RemoteControl.RemoteControlDevice.RemoteControlDeviceEventHandler(_remote_ButtonPressed); sl@0: } sl@0: sl@0: /// sl@0: /// Clean up any resources being used. sl@0: /// sl@0: protected override void Dispose( bool disposing ) sl@0: { sl@0: if( disposing ) sl@0: { sl@6: if (components != null) sl@0: { sl@0: components.Dispose(); sl@0: } sl@0: } sl@0: base.Dispose( disposing ); sl@0: } sl@0: sl@0: #region Windows Form Designer generated code sl@0: /// sl@0: /// Required method for Designer support - do not modify sl@0: /// the contents of this method with the code editor. sl@0: /// sl@0: private void InitializeComponent() sl@0: { sl@0: this.label1 = new System.Windows.Forms.Label(); sl@0: this.label2 = new System.Windows.Forms.Label(); sl@0: this.SuspendLayout(); sl@6: // sl@0: // label1 sl@6: // sl@0: this.label1.Dock = System.Windows.Forms.DockStyle.Fill; sl@0: this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); sl@0: this.label1.ForeColor = System.Drawing.Color.White; sl@0: this.label1.Location = new System.Drawing.Point(0, 0); sl@0: this.label1.Name = "label1"; sl@0: this.label1.Size = new System.Drawing.Size(736, 266); sl@0: this.label1.TabIndex = 0; sl@0: this.label1.Text = "Ready..."; sl@0: this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; sl@6: // sl@0: // label2 sl@6: // sl@0: this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); sl@0: this.label2.Location = new System.Drawing.Point(72, 32); sl@0: this.label2.Name = "label2"; sl@0: this.label2.Size = new System.Drawing.Size(576, 23); sl@0: this.label2.TabIndex = 1; sl@0: this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; sl@6: // sl@0: // Form1 sl@6: // sl@0: this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); sl@0: this.BackColor = System.Drawing.Color.LightSteelBlue; sl@0: this.ClientSize = new System.Drawing.Size(736, 266); sl@0: this.Controls.Add(this.label2); sl@0: this.Controls.Add(this.label1); sl@0: this.Name = "Form1"; sl@0: this.Text = "Remote Control Sample"; sl@0: this.Load += new System.EventHandler(this.Form1_Load); sl@0: this.ResumeLayout(false); sl@0: sl@0: } sl@6: #endregion Windows Form Designer generated code sl@0: sl@0: /// sl@0: /// The main entry point for the application. sl@0: /// sl@0: [STAThread] sl@6: static void Main() sl@0: { sl@0: Application.Run(new Form1()); sl@0: } sl@0: sl@0: private void Form1_Load(object sender, System.EventArgs e) sl@0: { sl@6: sl@0: } sl@0: sl@0: sl@0: protected override void WndProc(ref Message message) sl@0: { sl@6: _remote.ProcessMessage(message); sl@0: base.WndProc(ref message); sl@0: } sl@0: sl@0: private void _remote_ButtonPressed(object sender, RemoteControlEventArgs e) sl@0: { sl@0: _timer.Enabled = false; sl@3: if (e.Button != RemoteControlButton.Unknown) sl@3: { sl@3: label1.Text = e.Button.ToString(); sl@3: } sl@8: else if (e.MceButton != Hid.UsageTables.MceButton.Null) sl@3: { sl@5: //Display MCE button name sl@3: label1.Text = e.MceButton.ToString(); sl@5: //Check if this is an HP extension sl@9: if (Enum.IsDefined(typeof(Hid.UsageTables.HpMceButton), (ushort)e.MceButton)) sl@5: { sl@5: //Also display HP button name sl@8: label1.Text += " / HP:" + ((Hid.UsageTables.HpMceButton)e.MceButton).ToString(); sl@6: } sl@3: } sl@3: else sl@3: { sl@3: label1.Text = "Unknown"; sl@3: } sl@6: label2.Text = e.Device.ToString(); sl@0: _timer.Enabled = true; sl@0: } sl@0: sl@0: private void _timer_Tick(object sender, EventArgs e) sl@0: { sl@0: _timer.Enabled = false; sl@0: label1.Text = "Ready..."; sl@0: } sl@0: } sl@0: }