﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Globalization;
using CdioCs;

namespace Sampling
{
	/// <summary>
	/// Summary description for Condition.
	/// </summary>
	public class Condition : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.TextBox txtNumberOfData;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.TextBox txtStopNumber;
		private System.Windows.Forms.TextBox txtInternalClock;
		private System.Windows.Forms.TextBox txtMask;
		private System.Windows.Forms.ComboBox cboStop;
		private System.Windows.Forms.ComboBox cboClock;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.TextBox txtPattern;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.ComboBox cboStart;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		struct StrToNum
		{													// structure of condition and parameters
			public string Str;
			public short Num;
			public StrToNum(string Str, short Num)
			{
				this.Str = Str;
				this.Num = Num;
			}
		};
		// Start Condition
		static	StrToNum[] stnStart = 
		{
			new StrToNum("Software Start",	(short)CdioConst.DIODM_START_SOFT),
			new StrToNum("External UP",		(short)CdioConst.DIODM_START_EXT_RISE),
			new StrToNum("External Down",	(short)CdioConst.DIODM_START_EXT_FALL),
			new StrToNum("Pattern",			(short)CdioConst.DIODM_START_PATTERN),
			new StrToNum("End",				0)
		};
		// Clock Condition
		static	StrToNum[] stnClock = 
		{
			new StrToNum("Internal Clock",	(short)CdioConst.DIODM_CLK_CLOCK),
			new StrToNum("External Clock",	(short)CdioConst.DIODM_CLK_EXT_TRG),
			new StrToNum("Hand Shake",		(short)CdioConst.DIODM_CLK_HANDSHAKE),
			new StrToNum("End",				0)
		};
		// Stop Condition
		static	StrToNum[] stnStop = 
		{
			new StrToNum("Software Stop",	(short)CdioConst.DIODM_STOP_SOFT),
			new StrToNum("External UP",		(short)CdioConst.DIODM_STOP_EXT_RISE),
			new StrToNum("External Down",	(short)CdioConst.DIODM_STOP_EXT_FALL),
			new StrToNum("Number",			(short)CdioConst.DIODM_STOP_NUM),
			new StrToNum("End",				0)
		};
			
		Cdio				dio				= new Cdio();
		static string		szStart			= "Software Start";
		static string		szClock			= "Internal Clock";
		static string		szStop			= "Software Stop";
		static uint			dwPattern		= 0x55;
		static uint			dwMask			= 0xFF;
		static uint			dwInternalClock	= 1000;
		static uint			dwStopNumber	= 1000;
		public static uint	dwNumberOfData	= 500;			// notification count

		public Condition()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

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

		#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.btnCancel = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.txtNumberOfData = new System.Windows.Forms.TextBox();
			this.label11 = new System.Windows.Forms.Label();
			this.btnOK = new System.Windows.Forms.Button();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.label10 = new System.Windows.Forms.Label();
			this.label9 = new System.Windows.Forms.Label();
			this.txtStopNumber = new System.Windows.Forms.TextBox();
			this.txtInternalClock = new System.Windows.Forms.TextBox();
			this.txtMask = new System.Windows.Forms.TextBox();
			this.cboStop = new System.Windows.Forms.ComboBox();
			this.cboClock = new System.Windows.Forms.ComboBox();
			this.label8 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.txtPattern = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.cboStart = new System.Windows.Forms.ComboBox();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.groupBox2.SuspendLayout();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(384, 238);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(80, 23);
			this.btnCancel.TabIndex = 12;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.txtNumberOfData,
																					this.label11});
			this.groupBox2.Location = new System.Drawing.Point(9, 160);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(455, 66);
			this.groupBox2.TabIndex = 14;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Notification";
			// 
			// txtNumberOfData
			// 
			this.txtNumberOfData.Location = new System.Drawing.Point(96, 28);
			this.txtNumberOfData.Name = "txtNumberOfData";
			this.txtNumberOfData.Size = new System.Drawing.Size(88, 20);
			this.txtNumberOfData.TabIndex = 11;
			this.txtNumberOfData.Text = "";
			this.txtNumberOfData.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(8, 31);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(96, 19);
			this.label11.TabIndex = 0;
			this.label11.Text = "Number of Data:";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(288, 238);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(80, 23);
			this.btnOK.TabIndex = 11;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.label10,
																					this.label9,
																					this.txtStopNumber,
																					this.txtInternalClock,
																					this.txtMask,
																					this.cboStop,
																					this.cboClock,
																					this.label8,
																					this.label7,
																					this.label6,
																					this.label5,
																					this.txtPattern,
																					this.label4,
																					this.cboStart,
																					this.label3,
																					this.label2,
																					this.label1});
			this.groupBox1.Location = new System.Drawing.Point(9, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(455, 142);
			this.groupBox1.TabIndex = 13;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Sampling Conditions";
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(424, 83);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(16, 18);
			this.label10.TabIndex = 16;
			this.label10.Text = "ns";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(416, 54);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(30, 18);
			this.label9.TabIndex = 15;
			this.label9.Text = "Hex";
			// 
			// txtStopNumber
			// 
			this.txtStopNumber.Location = new System.Drawing.Point(344, 111);
			this.txtStopNumber.Name = "txtStopNumber";
			this.txtStopNumber.Size = new System.Drawing.Size(72, 20);
			this.txtStopNumber.TabIndex = 9;
			this.txtStopNumber.Text = "";
			this.txtStopNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// txtInternalClock
			// 
			this.txtInternalClock.Location = new System.Drawing.Point(344, 81);
			this.txtInternalClock.Name = "txtInternalClock";
			this.txtInternalClock.Size = new System.Drawing.Size(72, 20);
			this.txtInternalClock.TabIndex = 8;
			this.txtInternalClock.Text = "";
			this.txtInternalClock.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// txtMask
			// 
			this.txtMask.Location = new System.Drawing.Point(344, 52);
			this.txtMask.Name = "txtMask";
			this.txtMask.Size = new System.Drawing.Size(72, 20);
			this.txtMask.TabIndex = 7;
			this.txtMask.Text = "";
			this.txtMask.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// cboStop
			// 
			this.cboStop.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboStop.Location = new System.Drawing.Point(96, 109);
			this.cboStop.Name = "cboStop";
			this.cboStop.Size = new System.Drawing.Size(144, 21);
			this.cboStop.Sorted = true;
			this.cboStop.TabIndex = 5;
			this.cboStop.SelectedIndexChanged += new System.EventHandler(this.cboStop_SelectedIndexChanged);
			// 
			// cboClock
			// 
			this.cboClock.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboClock.Location = new System.Drawing.Point(96, 80);
			this.cboClock.Name = "cboClock";
			this.cboClock.Size = new System.Drawing.Size(144, 21);
			this.cboClock.Sorted = true;
			this.cboClock.TabIndex = 4;
			this.cboClock.SelectedIndexChanged += new System.EventHandler(this.cboClock_SelectedIndexChanged);
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(248, 112);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(96, 18);
			this.label8.TabIndex = 9;
			this.label8.Text = "Stop Number:";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(248, 83);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(96, 18);
			this.label7.TabIndex = 8;
			this.label7.Text = "Internal Clock:";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(248, 54);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(96, 18);
			this.label6.TabIndex = 7;
			this.label6.Text = "Pattern Mask:";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(416, 24);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(30, 19);
			this.label5.TabIndex = 6;
			this.label5.Text = "Hex";
			// 
			// txtPattern
			// 
			this.txtPattern.Location = new System.Drawing.Point(344, 23);
			this.txtPattern.Name = "txtPattern";
			this.txtPattern.Size = new System.Drawing.Size(72, 20);
			this.txtPattern.TabIndex = 6;
			this.txtPattern.Text = "";
			this.txtPattern.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(248, 24);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(104, 18);
			this.label4.TabIndex = 4;
			this.label4.Text = "Compare Pattern:";
			// 
			// cboStart
			// 
			this.cboStart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboStart.Location = new System.Drawing.Point(96, 22);
			this.cboStart.Name = "cboStart";
			this.cboStart.Size = new System.Drawing.Size(144, 21);
			this.cboStart.Sorted = true;
			this.cboStart.TabIndex = 3;
			this.cboStart.SelectedIndexChanged += new System.EventHandler(this.cboStart_SelectedIndexChanged);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 112);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(88, 18);
			this.label3.TabIndex = 2;
			this.label3.Text = "Stop Condition:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 83);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(96, 18);
			this.label2.TabIndex = 1;
			this.label2.Text = "Clock Condition:";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(88, 19);
			this.label1.TabIndex = 0;
			this.label1.Text = "Start Condition:";
			// 
			// Condition
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(472, 270);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btnCancel,
																		  this.groupBox2,
																		  this.btnOK,
																		  this.groupBox1});
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Condition";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Set Sampling Conditions";
			this.Load += new System.EventHandler(this.Condition_Load);
			this.groupBox2.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		//===================================================
		//	Dialog init
		//===================================================
		private void Condition_Load(object sender, System.EventArgs e)
		{
			//--------------------------------
			// Init
			//--------------------------------
			uint	i;
			for (i = 0; string.Compare(stnStart[i].Str, "End") != 0; i++)
			{
				cboStart.Items.Add(stnStart[i].Str);
			}
			for (i = 0; string.Compare(stnClock[i].Str, "End") != 0; i++)
			{
				cboClock.Items.Add(stnClock[i].Str);
			}
			for (i = 0; string.Compare(stnStop[i].Str, "End") != 0; i++)
			{
				cboStop.Items.Add(stnStop[i].Str);
			}

			cboStart.Text = szStart;
			cboClock.Text = szClock;
			cboStop.Text = szStop;

			txtPattern.Text = string.Format("{0:X}", dwPattern);
			txtMask.Text = string.Format("{0:X}", dwMask);
			txtInternalClock.Text = string.Format("{0:d}", dwInternalClock);
			txtStopNumber.Text = string.Format("{0:d}", dwStopNumber);
			txtNumberOfData.Text = string.Format("{0:d}", dwNumberOfData);

			cboStart_SelectedIndexChanged(cboStart, new System.EventArgs());
			cboClock_SelectedIndexChanged(cboClock, new System.EventArgs());
			cboStop_SelectedIndexChanged(cboStop, new System.EventArgs());
		}

		//===================================================
		//	OK button handle
		//===================================================
		private void btnOK_Click(object sender, System.EventArgs e)
		{
			string	szTmp = new string(' ', 100);
			short	Start;
			short	Clock;
			short	Stop;
			short	Direction = (short)CdioConst.DIODM_DIR_IN;
			uint	i;
			int		Ret;
			string	csMsg;
			string	ErrorString;
			//--------------------------------
			// Get the displayed data
			//--------------------------------
			szStart = cboStart.Text;
			szClock = cboClock.Text;
			szStop = cboStop.Text;
			szTmp = txtPattern.Text;
			try
			{
				dwPattern = uint.Parse(szTmp, NumberStyles.HexNumber);
			}
			catch (System.FormatException) 
			{
				dwPattern = 0x55;
			}
			szTmp = txtMask.Text;
			try
			{
				dwMask = uint.Parse(szTmp, NumberStyles.HexNumber);
			}
			catch (System.FormatException) 
			{
				dwMask = 0xFF;
			}
			szTmp = txtInternalClock.Text;
			try
			{
				dwInternalClock = uint.Parse(szTmp);
			}
			catch (System.FormatException)
			{
				dwInternalClock = 1000;
			}
			szTmp = txtStopNumber.Text;			
			try
			{
				dwStopNumber = uint.Parse(szTmp);
			}
			catch (System.FormatException)
			{
				dwStopNumber = 1000;
			}
			szTmp = txtNumberOfData.Text;
			try
			{
				dwNumberOfData = uint.Parse(szTmp);
			}
			catch (System.FormatException)
			{
				dwNumberOfData = 500;
			}
			//--------------------------------
			// Convert data to number
			//--------------------------------
			Start = 0;
			for (i = 0; string.Compare(stnStart[i].Str, "End") != 0; i++)
			{
				if (string.Compare(szStart, stnStart[i].Str) == 0)
				{
					Start = stnStart[i].Num;
					break;
				}
			}
			Clock = 0;
			for (i = 0; string.Compare(stnClock[i].Str, "End") != 0; i++)
			{
				if (string.Compare(szClock, stnClock[i].Str) == 0)
				{
					Clock = stnClock[i].Num;
					break;
				}
			}
			Stop = 0;
			for (i = 0; string.Compare(stnStop[i].Str, "End") != 0; i++)
			{
				if (string.Compare(szStop, stnStop[i].Str) == 0)
				{
					Stop = stnStop[i].Num;
					break;
				}
			}
			//--------------------------------
			// Set sampling condition
			//--------------------------------
			//	Specify input/output direction (32-point input)
			Ret = dio.DmSetDirection(Sampling.m_Id, (short)CdioConst.PI_32);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DioDmSetDirection Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			// Start alone
			Ret = dio.DmSetStandAlone(Sampling.m_Id);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DioDmSetStandAlone Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			// Set start condition
			Ret = dio.DmSetStartTrigger(Sampling.m_Id, Direction, Start);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DmSetStartTrigger Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			// Set clock condition
			Ret = dio.DmSetClockTrigger(Sampling.m_Id, Direction, Clock);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DioDmSetClockTrigger Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			// Set stop condition
			Ret = dio.DmSetStopTrigger(Sampling.m_Id, Direction, Stop);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DioDmSetStopTrigger Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			// Pattern/Mask
			Ret = dio.DmSetStartPattern(Sampling.m_Id, dwPattern, dwMask);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DioDmSetStartPattern Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			// Set internal clock
			Ret = dio.DmSetInternalClock(Sampling.m_Id, Direction, dwInternalClock, (short)CdioConst.DIODM_TIM_UNIT_NS);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DioDmSetInternalClock Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			// Set stop number
			Ret = dio.DmSetStopNumber(Sampling.m_Id, Direction, dwStopNumber);
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS)
			{
				dio.GetErrorString(Ret, out ErrorString);
				csMsg = "DioDmSetStopNumber Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
				MessageBox.Show(csMsg, this.ProductName, MessageBoxButtons.OK);
				return;
			}
			this.Close();
		}

		//===================================================
		//	Cancel button handle
		//===================================================
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		
		//===================================================
		//	Modify start condition
		//===================================================
		private void cboStart_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string	szBuff = new string(' ',100);
			//--------------------------------
			// Enable/disable Pattern and Mask
			//--------------------------------
			szBuff = cboStart.Text;
			if (string.Compare(szBuff, "Pattern") == 0)
			{
				txtPattern.Enabled = true;
				txtMask.Enabled = true;
			} 
			else 
			{
				txtPattern.Enabled = false;
				txtMask.Enabled = false;
			}
		}

		//===================================================
		//	Modify clock condition
		//===================================================
		private void cboClock_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string	szBuff = new string(' ',100);
			//--------------------------------
			// Enable/disable Internal Clock
			//--------------------------------
			szBuff = cboClock.Text;
			if (string.Compare(szBuff, "Internal Clock") == 0)
			{
				txtInternalClock.Enabled = true;
			} 
			else 
			{
				txtInternalClock.Enabled = false;
			}
		}

		//===================================================
		//	Modify stop condition
		//===================================================
		private void cboStop_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string	szBuff = new string(' ',100);
			//--------------------------------
			// Enable/disable Stop Number
			//--------------------------------
			szBuff = cboStop.Text;
			if (string.Compare(szBuff, "Number") == 0)
			{
				txtStopNumber.Enabled = true;
			}
			else
			{
				txtStopNumber.Enabled = false;
			}
		}
	}
}
