Starting to remove special case for app commands.
Adding a whole bunch of consumer controls.
3 using System.Collections;
4 using System.ComponentModel;
5 using System.Windows.Forms;
7 using Devices.RemoteControl;
9 namespace RemoteControlSample
12 /// Summary description for Form1.
14 public class Form1 : System.Windows.Forms.Form
17 /// Required designer variable.
19 private System.ComponentModel.Container components = null;
20 private System.Windows.Forms.Label label1;
21 private RemoteControlDevice _remote;
22 private System.Windows.Forms.Label label2;
28 // Required for Windows Form Designer support
30 InitializeComponent();
33 _timer.Interval = 3000;
34 _timer.Enabled = false;
35 _timer.Tick +=new EventHandler(_timer_Tick);
39 /// Clean up any resources being used.
41 protected override void Dispose( bool disposing )
45 if (components != null)
50 base.Dispose( disposing );
53 #region Windows Form Designer generated code
55 /// Required method for Designer support - do not modify
56 /// the contents of this method with the code editor.
58 private void InitializeComponent()
60 this.label1 = new System.Windows.Forms.Label();
61 this.label2 = new System.Windows.Forms.Label();
66 this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
67 this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
68 this.label1.ForeColor = System.Drawing.Color.White;
69 this.label1.Location = new System.Drawing.Point(0, 0);
70 this.label1.Name = "label1";
71 this.label1.Size = new System.Drawing.Size(736, 266);
72 this.label1.TabIndex = 0;
73 this.label1.Text = "Ready...";
74 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
78 this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
79 this.label2.Location = new System.Drawing.Point(72, 32);
80 this.label2.Name = "label2";
81 this.label2.Size = new System.Drawing.Size(576, 23);
82 this.label2.TabIndex = 1;
83 this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
87 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
88 this.BackColor = System.Drawing.Color.LightSteelBlue;
89 this.ClientSize = new System.Drawing.Size(736, 266);
90 this.Controls.Add(this.label2);
91 this.Controls.Add(this.label1);
93 this.Text = "Remote Control Sample";
94 this.Load += new System.EventHandler(this.Form1_Load);
95 this.ResumeLayout(false);
98 #endregion Windows Form Designer generated code
101 /// The main entry point for the application.
106 Application.Run(new Form1());
109 private void Form1_Load(object sender, System.EventArgs e)
111 _remote = new RemoteControlDevice(this.Handle);
112 _remote.ButtonPressed += new Devices.RemoteControl.RemoteControlDevice.RemoteControlDeviceEventHandler(_remote_ButtonPressed);
116 protected override void WndProc(ref Message message)
120 _remote.ProcessMessage(message);
122 base.WndProc(ref message);
125 private bool _remote_ButtonPressed(object sender, RemoteControlEventArgs e)
127 bool processed = false;
128 _timer.Enabled = false;
129 if (e.Button != RemoteControlButton.Unknown)
131 label1.Text = e.Button.ToString();
134 else if (e.MceButton != Hid.UsageTables.MceButton.Null)
136 //Display MCE button name
137 label1.Text = e.MceButton.ToString();
138 //Check if this is an HP extension
139 if (Enum.IsDefined(typeof(Hid.UsageTables.HpMceButton), (ushort)e.MceButton))
141 //Also display HP button name
142 label1.Text += " / HP:" + ((Hid.UsageTables.HpMceButton)e.MceButton).ToString();
147 else if (e.ConsumerControl != Hid.UsageTables.ConsumerControl.Null)
149 //Display consumer control name
150 label1.Text = e.ConsumerControl.ToString();
155 label1.Text = "Unknown";
157 label2.Text = e.Device.ToString();
158 _timer.Enabled = true;
162 private void _timer_Tick(object sender, EventArgs e)
164 _timer.Enabled = false;
165 label1.Text = "Ready...";