Form1.cs
changeset 37 83b3361510a7
parent 36 259e823a8e84
child 38 98cd08fa1d6d
     1.1 --- a/Form1.cs	Mon Dec 22 11:40:23 2014 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,168 +0,0 @@
     1.4 -using System;
     1.5 -using System.Drawing;
     1.6 -using System.Collections;
     1.7 -using System.ComponentModel;
     1.8 -using System.Windows.Forms;
     1.9 -using System.Data;
    1.10 -using Devices.RemoteControl;
    1.11 -
    1.12 -namespace RemoteControlSample
    1.13 -{
    1.14 -	/// <summary>
    1.15 -	/// Summary description for Form1.
    1.16 -	/// </summary>
    1.17 -	public class MainForm : System.Windows.Forms.Form
    1.18 -	{
    1.19 -		/// <summary>
    1.20 -		/// Required designer variable.
    1.21 -		/// </summary>
    1.22 -		private System.ComponentModel.Container components = null;
    1.23 -		private System.Windows.Forms.Label label1;
    1.24 -		private RemoteControlDevice _remote;
    1.25 -		private System.Windows.Forms.Label label2;
    1.26 -		private Timer _timer;
    1.27 -
    1.28 -		public MainForm()
    1.29 -		{
    1.30 -			//
    1.31 -			// Required for Windows Form Designer support
    1.32 -			//
    1.33 -			InitializeComponent();
    1.34 -
    1.35 -			_timer = new Timer();
    1.36 -			_timer.Interval = 3000;
    1.37 -			_timer.Enabled = false;
    1.38 -			_timer.Tick +=new EventHandler(_timer_Tick);            
    1.39 -		}
    1.40 -
    1.41 -		/// <summary>
    1.42 -		/// Clean up any resources being used.
    1.43 -		/// </summary>
    1.44 -		protected override void Dispose( bool disposing )
    1.45 -		{
    1.46 -			if( disposing )
    1.47 -			{
    1.48 -				if (components != null)
    1.49 -				{
    1.50 -					components.Dispose();
    1.51 -				}
    1.52 -			}
    1.53 -			base.Dispose( disposing );
    1.54 -		}
    1.55 -
    1.56 -		#region Windows Form Designer generated code
    1.57 -		/// <summary>
    1.58 -		/// Required method for Designer support - do not modify
    1.59 -		/// the contents of this method with the code editor.
    1.60 -		/// </summary>
    1.61 -		private void InitializeComponent()
    1.62 -		{
    1.63 -			this.label1 = new System.Windows.Forms.Label();
    1.64 -			this.label2 = new System.Windows.Forms.Label();
    1.65 -			this.SuspendLayout();
    1.66 -			//
    1.67 -			// label1
    1.68 -			//
    1.69 -			this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
    1.70 -			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
    1.71 -			this.label1.ForeColor = System.Drawing.Color.White;
    1.72 -			this.label1.Location = new System.Drawing.Point(0, 0);
    1.73 -			this.label1.Name = "label1";
    1.74 -			this.label1.Size = new System.Drawing.Size(736, 266);
    1.75 -			this.label1.TabIndex = 0;
    1.76 -			this.label1.Text = "Ready...";
    1.77 -			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    1.78 -			//
    1.79 -			// label2
    1.80 -			//
    1.81 -			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
    1.82 -			this.label2.Location = new System.Drawing.Point(72, 32);
    1.83 -			this.label2.Name = "label2";
    1.84 -			this.label2.Size = new System.Drawing.Size(576, 23);
    1.85 -			this.label2.TabIndex = 1;
    1.86 -			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    1.87 -			//
    1.88 -			// Form1
    1.89 -			//
    1.90 -			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    1.91 -			this.BackColor = System.Drawing.Color.LightSteelBlue;
    1.92 -			this.ClientSize = new System.Drawing.Size(736, 266);
    1.93 -			this.Controls.Add(this.label2);
    1.94 -			this.Controls.Add(this.label1);
    1.95 -			this.Name = "Form1";
    1.96 -			this.Text = "Remote Control Sample";
    1.97 -			this.Load += new System.EventHandler(this.Form1_Load);
    1.98 -			this.ResumeLayout(false);
    1.99 -
   1.100 -		}
   1.101 -		#endregion Windows Form Designer generated code
   1.102 -
   1.103 -		/// <summary>
   1.104 -		/// The main entry point for the application.
   1.105 -		/// </summary>
   1.106 -		[STAThread]
   1.107 -		static void Main()
   1.108 -		{
   1.109 -			Application.Run(new MainForm());
   1.110 -		}
   1.111 -
   1.112 -		private void Form1_Load(object sender, System.EventArgs e)
   1.113 -		{
   1.114 -            _remote = new RemoteControlDevice(this.Handle);
   1.115 -            _remote.ButtonPressed += new Devices.RemoteControl.RemoteControlDevice.RemoteControlDeviceEventHandler(_remote_ButtonPressed);
   1.116 -		}
   1.117 -
   1.118 -
   1.119 -		protected override void WndProc(ref Message message)
   1.120 -		{
   1.121 -            if (_remote != null)
   1.122 -            {
   1.123 -                _remote.ProcessMessage(message);
   1.124 -            }
   1.125 -			base.WndProc(ref message);
   1.126 -		}
   1.127 -
   1.128 -		private bool _remote_ButtonPressed(object sender, RemoteControlEventArgs e)
   1.129 -		{
   1.130 -            bool processed = false;
   1.131 -			_timer.Enabled = false;
   1.132 -            if (e.Button != RemoteControlButton.Unknown)
   1.133 -            {
   1.134 -                label1.Text = e.Button.ToString();
   1.135 -                processed = true;
   1.136 -            }
   1.137 -            else if (e.MceButton != Hid.UsageTables.WindowsMediaCenterRemoteControl.Null)
   1.138 -            {
   1.139 -                //Display MCE button name
   1.140 -                label1.Text = e.MceButton.ToString();
   1.141 -                //Check if this is an HP extension
   1.142 -                if (Enum.IsDefined(typeof(Hid.UsageTables.HpWindowsMediaCenterRemoteControl), (ushort)e.MceButton))
   1.143 -                {
   1.144 -                    //Also display HP button name
   1.145 -                    label1.Text += " / HP:" + ((Hid.UsageTables.HpWindowsMediaCenterRemoteControl)e.MceButton).ToString();
   1.146 -                }
   1.147 -
   1.148 -                processed = true;
   1.149 -            }
   1.150 -            else if (e.ConsumerControl != Hid.UsageTables.ConsumerControl.Null)
   1.151 -            {
   1.152 -                //Display consumer control name
   1.153 -                label1.Text = e.ConsumerControl.ToString();
   1.154 -                processed = true;
   1.155 -            }
   1.156 -            else
   1.157 -            {
   1.158 -                label1.Text = "Unknown";
   1.159 -            }
   1.160 -			label2.Text = e.Device.ToString();
   1.161 -			_timer.Enabled = true;
   1.162 -            return processed;
   1.163 -		}
   1.164 -
   1.165 -		private void _timer_Tick(object sender, EventArgs e)
   1.166 -		{
   1.167 -			_timer.Enabled = false;
   1.168 -			label1.Text = "Ready...";
   1.169 -		}
   1.170 -	}
   1.171 -}