using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestContainer
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox txtValue;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox txtMin;
		private System.Windows.Forms.TextBox txtMax;
		private System.Windows.Forms.TextBox txtSense;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.CheckBox checkBoxLoop;
		private WheelCtrl.WheelCtrl wheelCtrl;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			
			wheelCtrl.WheelDrag += new WheelCtrl.WheelCtrl.WheelEventHandler(wheelCtrl_OnWheelDrag);
			
			txtSense.Text = wheelCtrl.Sensitivity.ToString();
			txtMin.Text = wheelCtrl.Min.ToString();
			txtMax.Text = wheelCtrl.Max.ToString();
			txtValue.Text = wheelCtrl.Value.ToString();
			checkBoxLoop.Checked = wheelCtrl.Loop;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		private void wheelCtrl_OnWheelDrag(object sender, WheelCtrl.WheelEventHandlerArgs e)
		{
			txtValue.Text = wheelCtrl.Value.ToString();
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.txtValue = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.txtMin = new System.Windows.Forms.TextBox();
			this.txtMax = new System.Windows.Forms.TextBox();
			this.txtSense = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.checkBoxLoop = new System.Windows.Forms.CheckBox();
			this.wheelCtrl = new WheelCtrl.WheelCtrl();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(200, 32);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(40, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "Value";
			// 
			// txtValue
			// 
			this.txtValue.Location = new System.Drawing.Point(200, 56);
			this.txtValue.Name = "txtValue";
			this.txtValue.Size = new System.Drawing.Size(56, 20);
			this.txtValue.TabIndex = 2;
			this.txtValue.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(32, 88);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(40, 16);
			this.label2.TabIndex = 3;
			this.label2.Text = "Min";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(104, 88);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(40, 16);
			this.label3.TabIndex = 4;
			this.label3.Text = "Max";
			// 
			// txtMin
			// 
			this.txtMin.Location = new System.Drawing.Point(32, 112);
			this.txtMin.Name = "txtMin";
			this.txtMin.Size = new System.Drawing.Size(48, 20);
			this.txtMin.TabIndex = 5;
			this.txtMin.Text = "";
			this.txtMin.Validated += new System.EventHandler(this.txtMin_Validated);
			// 
			// txtMax
			// 
			this.txtMax.Location = new System.Drawing.Point(104, 112);
			this.txtMax.Name = "txtMax";
			this.txtMax.Size = new System.Drawing.Size(48, 20);
			this.txtMax.TabIndex = 6;
			this.txtMax.Text = "";
			this.txtMax.Validated += new System.EventHandler(this.txtMax_Validated);
			// 
			// txtSense
			// 
			this.txtSense.Location = new System.Drawing.Point(184, 112);
			this.txtSense.Name = "txtSense";
			this.txtSense.Size = new System.Drawing.Size(80, 20);
			this.txtSense.TabIndex = 7;
			this.txtSense.Text = "";
			this.txtSense.Validated += new System.EventHandler(this.txtSense_Validated);
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(184, 88);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 16);
			this.label4.TabIndex = 8;
			this.label4.Text = "Sensitivity";
			// 
			// checkBoxLoop
			// 
			this.checkBoxLoop.Location = new System.Drawing.Point(80, 56);
			this.checkBoxLoop.Name = "checkBoxLoop";
			this.checkBoxLoop.Size = new System.Drawing.Size(104, 16);
			this.checkBoxLoop.TabIndex = 10;
			this.checkBoxLoop.Text = "Loop values";
			this.checkBoxLoop.CheckedChanged += new System.EventHandler(this.checkBoxLoop_CheckedChanged);
			// 
			// wheelCtrl
			// 
			this.wheelCtrl.Location = new System.Drawing.Point(24, 32);
			this.wheelCtrl.Loop = false;
			this.wheelCtrl.Max = 1;
			this.wheelCtrl.Min = 0;
			this.wheelCtrl.Name = "wheelCtrl";
			this.wheelCtrl.Sensitivity = 1;
			this.wheelCtrl.Size = new System.Drawing.Size(59, 8);
			this.wheelCtrl.TabIndex = 11;
			this.wheelCtrl.Value = 0.5;
			this.wheelCtrl.WheelAxe = WheelCtrl.WheelCtrl.Orientation.XAxe;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 150);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.wheelCtrl,
																		  this.checkBoxLoop,
																		  this.label4,
																		  this.txtSense,
																		  this.txtMax,
																		  this.txtMin,
																		  this.label3,
																		  this.label2,
																		  this.txtValue,
																		  this.label1});
			this.Name = "Form1";
			this.Text = "Test WheelCtrl";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void txtMax_Validated(object sender, System.EventArgs e)
		{
			wheelCtrl.Max = Convert.ToDouble(((TextBox) sender).Text);
		}
		
		private void txtMin_Validated(object sender, System.EventArgs e)
		{
			wheelCtrl.Min = Convert.ToDouble(((TextBox) sender).Text);		
		}
		
		private void txtSense_Validated(object sender, System.EventArgs e)
		{
			wheelCtrl.Sensitivity = Convert.ToDouble(((TextBox) sender).Text);	
		}

		private void checkBoxLoop_CheckedChanged(object sender, System.EventArgs e)
		{
			CheckBox chk = (CheckBox) sender;
			wheelCtrl.Loop = chk.Checked;
		}
	}
}
