Form1.cs
changeset 0 82a61d3d2706
child 3 db8e6a25d6bc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Form1.cs	Tue Nov 04 19:31:32 2014 +0100
     1.3 @@ -0,0 +1,137 @@
     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 BruceThomas.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 Form1 : 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 Form1()
    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 +			_remote = new RemoteControlDevice();
    1.40 +			_remote.ButtonPressed +=new BruceThomas.Devices.RemoteControl.RemoteControlDevice.RemoteControlDeviceEventHandler(_remote_ButtonPressed);			
    1.41 +		}
    1.42 +
    1.43 +		/// <summary>
    1.44 +		/// Clean up any resources being used.
    1.45 +		/// </summary>
    1.46 +		protected override void Dispose( bool disposing )
    1.47 +		{
    1.48 +			if( disposing )
    1.49 +			{
    1.50 +				if (components != null) 
    1.51 +				{
    1.52 +					components.Dispose();
    1.53 +				}
    1.54 +			}
    1.55 +			base.Dispose( disposing );
    1.56 +		}
    1.57 +
    1.58 +		#region Windows Form Designer generated code
    1.59 +		/// <summary>
    1.60 +		/// Required method for Designer support - do not modify
    1.61 +		/// the contents of this method with the code editor.
    1.62 +		/// </summary>
    1.63 +		private void InitializeComponent()
    1.64 +		{
    1.65 +			this.label1 = new System.Windows.Forms.Label();
    1.66 +			this.label2 = new System.Windows.Forms.Label();
    1.67 +			this.SuspendLayout();
    1.68 +			// 
    1.69 +			// label1
    1.70 +			// 
    1.71 +			this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
    1.72 +			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
    1.73 +			this.label1.ForeColor = System.Drawing.Color.White;
    1.74 +			this.label1.Location = new System.Drawing.Point(0, 0);
    1.75 +			this.label1.Name = "label1";
    1.76 +			this.label1.Size = new System.Drawing.Size(736, 266);
    1.77 +			this.label1.TabIndex = 0;
    1.78 +			this.label1.Text = "Ready...";
    1.79 +			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    1.80 +			// 
    1.81 +			// label2
    1.82 +			// 
    1.83 +			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
    1.84 +			this.label2.Location = new System.Drawing.Point(72, 32);
    1.85 +			this.label2.Name = "label2";
    1.86 +			this.label2.Size = new System.Drawing.Size(576, 23);
    1.87 +			this.label2.TabIndex = 1;
    1.88 +			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    1.89 +			// 
    1.90 +			// Form1
    1.91 +			// 
    1.92 +			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    1.93 +			this.BackColor = System.Drawing.Color.LightSteelBlue;
    1.94 +			this.ClientSize = new System.Drawing.Size(736, 266);
    1.95 +			this.Controls.Add(this.label2);
    1.96 +			this.Controls.Add(this.label1);
    1.97 +			this.Name = "Form1";
    1.98 +			this.Text = "Remote Control Sample";
    1.99 +			this.Load += new System.EventHandler(this.Form1_Load);
   1.100 +			this.ResumeLayout(false);
   1.101 +
   1.102 +		}
   1.103 +		#endregion
   1.104 +
   1.105 +		/// <summary>
   1.106 +		/// The main entry point for the application.
   1.107 +		/// </summary>
   1.108 +		[STAThread]
   1.109 +		static void Main() 
   1.110 +		{
   1.111 +			Application.Run(new Form1());
   1.112 +		}
   1.113 +
   1.114 +		private void Form1_Load(object sender, System.EventArgs e)
   1.115 +		{
   1.116 +		
   1.117 +		}
   1.118 +
   1.119 +
   1.120 +		protected override void WndProc(ref Message message)
   1.121 +		{
   1.122 +			_remote.ProcessMessage(message);			
   1.123 +			base.WndProc(ref message);
   1.124 +		}
   1.125 +
   1.126 +		private void _remote_ButtonPressed(object sender, RemoteControlEventArgs e)
   1.127 +		{
   1.128 +			_timer.Enabled = false;
   1.129 +			label1.Text = e.Button.ToString();
   1.130 +			label2.Text = e.Device.ToString();			
   1.131 +			_timer.Enabled = true;
   1.132 +		}
   1.133 +
   1.134 +		private void _timer_Tick(object sender, EventArgs e)
   1.135 +		{
   1.136 +			_timer.Enabled = false;
   1.137 +			label1.Text = "Ready...";
   1.138 +		}
   1.139 +	}
   1.140 +}