Form1.cs
author sl
Tue, 04 Nov 2014 19:31:32 +0100
changeset 0 82a61d3d2706
child 3 db8e6a25d6bc
permissions -rw-r--r--
Initial contribution. Partly working with PCS-MCE.
sl@0
     1
using System;
sl@0
     2
using System.Drawing;
sl@0
     3
using System.Collections;
sl@0
     4
using System.ComponentModel;
sl@0
     5
using System.Windows.Forms;
sl@0
     6
using System.Data;
sl@0
     7
using BruceThomas.Devices.RemoteControl;
sl@0
     8
sl@0
     9
namespace RemoteControlSample
sl@0
    10
{
sl@0
    11
	/// <summary>
sl@0
    12
	/// Summary description for Form1.
sl@0
    13
	/// </summary>
sl@0
    14
	public class Form1 : System.Windows.Forms.Form
sl@0
    15
	{
sl@0
    16
		/// <summary>
sl@0
    17
		/// Required designer variable.
sl@0
    18
		/// </summary>
sl@0
    19
		private System.ComponentModel.Container components = null;
sl@0
    20
		private System.Windows.Forms.Label label1;
sl@0
    21
		private RemoteControlDevice _remote;
sl@0
    22
		private System.Windows.Forms.Label label2;
sl@0
    23
		private Timer _timer;
sl@0
    24
sl@0
    25
		public Form1()
sl@0
    26
		{
sl@0
    27
			//
sl@0
    28
			// Required for Windows Form Designer support
sl@0
    29
			//
sl@0
    30
			InitializeComponent();
sl@0
    31
sl@0
    32
			_timer = new Timer();
sl@0
    33
			_timer.Interval = 3000;
sl@0
    34
			_timer.Enabled = false;
sl@0
    35
			_timer.Tick +=new EventHandler(_timer_Tick);
sl@0
    36
			_remote = new RemoteControlDevice();
sl@0
    37
			_remote.ButtonPressed +=new BruceThomas.Devices.RemoteControl.RemoteControlDevice.RemoteControlDeviceEventHandler(_remote_ButtonPressed);			
sl@0
    38
		}
sl@0
    39
sl@0
    40
		/// <summary>
sl@0
    41
		/// Clean up any resources being used.
sl@0
    42
		/// </summary>
sl@0
    43
		protected override void Dispose( bool disposing )
sl@0
    44
		{
sl@0
    45
			if( disposing )
sl@0
    46
			{
sl@0
    47
				if (components != null) 
sl@0
    48
				{
sl@0
    49
					components.Dispose();
sl@0
    50
				}
sl@0
    51
			}
sl@0
    52
			base.Dispose( disposing );
sl@0
    53
		}
sl@0
    54
sl@0
    55
		#region Windows Form Designer generated code
sl@0
    56
		/// <summary>
sl@0
    57
		/// Required method for Designer support - do not modify
sl@0
    58
		/// the contents of this method with the code editor.
sl@0
    59
		/// </summary>
sl@0
    60
		private void InitializeComponent()
sl@0
    61
		{
sl@0
    62
			this.label1 = new System.Windows.Forms.Label();
sl@0
    63
			this.label2 = new System.Windows.Forms.Label();
sl@0
    64
			this.SuspendLayout();
sl@0
    65
			// 
sl@0
    66
			// label1
sl@0
    67
			// 
sl@0
    68
			this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
sl@0
    69
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
sl@0
    70
			this.label1.ForeColor = System.Drawing.Color.White;
sl@0
    71
			this.label1.Location = new System.Drawing.Point(0, 0);
sl@0
    72
			this.label1.Name = "label1";
sl@0
    73
			this.label1.Size = new System.Drawing.Size(736, 266);
sl@0
    74
			this.label1.TabIndex = 0;
sl@0
    75
			this.label1.Text = "Ready...";
sl@0
    76
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
sl@0
    77
			// 
sl@0
    78
			// label2
sl@0
    79
			// 
sl@0
    80
			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
sl@0
    81
			this.label2.Location = new System.Drawing.Point(72, 32);
sl@0
    82
			this.label2.Name = "label2";
sl@0
    83
			this.label2.Size = new System.Drawing.Size(576, 23);
sl@0
    84
			this.label2.TabIndex = 1;
sl@0
    85
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
sl@0
    86
			// 
sl@0
    87
			// Form1
sl@0
    88
			// 
sl@0
    89
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
sl@0
    90
			this.BackColor = System.Drawing.Color.LightSteelBlue;
sl@0
    91
			this.ClientSize = new System.Drawing.Size(736, 266);
sl@0
    92
			this.Controls.Add(this.label2);
sl@0
    93
			this.Controls.Add(this.label1);
sl@0
    94
			this.Name = "Form1";
sl@0
    95
			this.Text = "Remote Control Sample";
sl@0
    96
			this.Load += new System.EventHandler(this.Form1_Load);
sl@0
    97
			this.ResumeLayout(false);
sl@0
    98
sl@0
    99
		}
sl@0
   100
		#endregion
sl@0
   101
sl@0
   102
		/// <summary>
sl@0
   103
		/// The main entry point for the application.
sl@0
   104
		/// </summary>
sl@0
   105
		[STAThread]
sl@0
   106
		static void Main() 
sl@0
   107
		{
sl@0
   108
			Application.Run(new Form1());
sl@0
   109
		}
sl@0
   110
sl@0
   111
		private void Form1_Load(object sender, System.EventArgs e)
sl@0
   112
		{
sl@0
   113
		
sl@0
   114
		}
sl@0
   115
sl@0
   116
sl@0
   117
		protected override void WndProc(ref Message message)
sl@0
   118
		{
sl@0
   119
			_remote.ProcessMessage(message);			
sl@0
   120
			base.WndProc(ref message);
sl@0
   121
		}
sl@0
   122
sl@0
   123
		private void _remote_ButtonPressed(object sender, RemoteControlEventArgs e)
sl@0
   124
		{
sl@0
   125
			_timer.Enabled = false;
sl@0
   126
			label1.Text = e.Button.ToString();
sl@0
   127
			label2.Text = e.Device.ToString();			
sl@0
   128
			_timer.Enabled = true;
sl@0
   129
		}
sl@0
   130
sl@0
   131
		private void _timer_Tick(object sender, EventArgs e)
sl@0
   132
		{
sl@0
   133
			_timer.Enabled = false;
sl@0
   134
			label1.Text = "Ready...";
sl@0
   135
		}
sl@0
   136
	}
sl@0
   137
}