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

namespace Sampling
{
	/// <summary>
	/// Condition の概要の説明です。
	/// </summary>
	public class Condition : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.TextBox txtNumberOfData;
		private System.Windows.Forms.Label label11;
		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>
		/// 必要なデザイナ変数です。
		/// </summary>
		private System.ComponentModel.Container components = null;

		Cdio dio = new Cdio();

		public 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)
		};
			
		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()
		{
			//
			// Windows フォーム デザイナ サポートに必要です。
			//
			InitializeComponent();

			//
			// TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
			//
		}

		/// <summary>
		/// 使用されているリソースに後処理を実行します。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
		/// コード エディタで変更しないでください。
		/// </summary>
		private void InitializeComponent()
		{
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnOK = 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.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, 232);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(80, 20);
			this.btnCancel.TabIndex = 1;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(280, 232);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(80, 20);
			this.btnOK.TabIndex = 0;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.txtNumberOfData,
																					this.label11});
			this.groupBox2.Location = new System.Drawing.Point(11, 168);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(466, 56);
			this.groupBox2.TabIndex = 10;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "転送個数イベント通知";
			// 
			// txtNumberOfData
			// 
			this.txtNumberOfData.Location = new System.Drawing.Point(24, 24);
			this.txtNumberOfData.Name = "txtNumberOfData";
			this.txtNumberOfData.Size = new System.Drawing.Size(88, 19);
			this.txtNumberOfData.TabIndex = 11;
			this.txtNumberOfData.Text = "";
			this.txtNumberOfData.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(120, 27);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(96, 16);
			this.label11.TabIndex = 0;
			this.label11.Text = "データ毎に通知";
			// 
			// 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(11, 14);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(466, 132);
			this.groupBox1.TabIndex = 2;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "サンプリング条件";
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(432, 71);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(30, 16);
			this.label10.TabIndex = 16;
			this.label10.Text = "ns";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(430, 46);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(30, 16);
			this.label9.TabIndex = 15;
			this.label9.Text = "Hex";
			// 
			// txtStopNumber
			// 
			this.txtStopNumber.Location = new System.Drawing.Point(352, 95);
			this.txtStopNumber.Name = "txtStopNumber";
			this.txtStopNumber.Size = new System.Drawing.Size(72, 19);
			this.txtStopNumber.TabIndex = 9;
			this.txtStopNumber.Text = "";
			this.txtStopNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// txtInternalClock
			// 
			this.txtInternalClock.Location = new System.Drawing.Point(352, 70);
			this.txtInternalClock.Name = "txtInternalClock";
			this.txtInternalClock.Size = new System.Drawing.Size(72, 19);
			this.txtInternalClock.TabIndex = 8;
			this.txtInternalClock.Text = "";
			this.txtInternalClock.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// txtMask
			// 
			this.txtMask.Location = new System.Drawing.Point(352, 45);
			this.txtMask.Name = "txtMask";
			this.txtMask.Size = new System.Drawing.Size(72, 19);
			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(104, 94);
			this.cboStop.Name = "cboStop";
			this.cboStop.Size = new System.Drawing.Size(144, 20);
			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(104, 69);
			this.cboClock.Name = "cboClock";
			this.cboClock.Size = new System.Drawing.Size(144, 20);
			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(264, 96);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(80, 16);
			this.label8.TabIndex = 9;
			this.label8.Text = "停止個数：";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(264, 71);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(80, 16);
			this.label7.TabIndex = 8;
			this.label7.Text = "内部クロック：";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(264, 46);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(80, 16);
			this.label6.TabIndex = 7;
			this.label6.Text = "パターンマスク：";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(430, 21);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(30, 16);
			this.label5.TabIndex = 6;
			this.label5.Text = "Hex";
			// 
			// txtPattern
			// 
			this.txtPattern.Location = new System.Drawing.Point(352, 20);
			this.txtPattern.Name = "txtPattern";
			this.txtPattern.Size = new System.Drawing.Size(72, 19);
			this.txtPattern.TabIndex = 6;
			this.txtPattern.Text = "";
			this.txtPattern.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(264, 21);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(80, 16);
			this.label4.TabIndex = 4;
			this.label4.Text = "比較パターン：";
			// 
			// cboStart
			// 
			this.cboStart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboStart.Location = new System.Drawing.Point(104, 19);
			this.cboStart.Name = "cboStart";
			this.cboStart.Size = new System.Drawing.Size(144, 20);
			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(24, 96);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(73, 16);
			this.label3.TabIndex = 2;
			this.label3.Text = "ストップ条件：";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 71);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(73, 16);
			this.label2.TabIndex = 1;
			this.label2.Text = "クロック条件：";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 21);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(73, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "スタート条件：";
			// 
			// Condition
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(488, 258);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btnCancel,
																		  this.btnOK,
																		  this.groupBox2,
																		  this.groupBox1});
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Condition";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "サンプリング条件設定";
			this.Load += new System.EventHandler(this.Condition_Load);
			this.groupBox2.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion


		//===================================================
		//	ダイアログ初期化
		//===================================================
		private void Condition_Load(object sender, System.EventArgs e)
		{
			//--------------------------------
			// 表示初期化
			//--------------------------------
			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ボタン処理
		//===================================================
		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;
			//--------------------------------
			// 表示データを取得
			//--------------------------------
			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;
			}
			//--------------------------------
			// 設定値を数値に変換
			//--------------------------------
			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;
				}
			}
			//--------------------------------
			// サンプリング条件を設定
			//--------------------------------
			// 入出力方向設定(全点入力)
			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;
			}
			// スタンドアローン
			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;
			}
			// スタート条件設定
			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;
			}
			// クロック条件設定
			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;
			}
			// ストップ条件設定
			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;
			}
			// パターン/マスク
			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;
			}
			// 内部クロック値設定
			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;
			}
			// 停止個数設定
			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();
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		
		//===================================================
		//	スタート条件設定変更
		//===================================================
		private void cboStart_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string	szBuff = new string(' ',100);
			//--------------------------------
			// Pattern と Maskの有効、無効を切り替え
			//--------------------------------
			szBuff = cboStart.Text;
			if (string.Compare(szBuff, "Pattern") == 0)
			{
				txtPattern.Enabled = true;
				txtMask.Enabled = true;
			} 
			else 
			{
				txtPattern.Enabled = false;
				txtMask.Enabled = false;
			}
		}

		//===================================================
		//	クロック条件設定変更
		//===================================================
		private void cboClock_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string	szBuff = new string(' ',100);
			//--------------------------------
			// Internal Clockの有効、無効を切り替え
			//--------------------------------
			szBuff = cboClock.Text;
			if (string.Compare(szBuff, "Internal Clock") == 0)
			{
				txtInternalClock.Enabled = true;
			} 
			else 
			{
				txtInternalClock.Enabled = false;
			}
		}

		//===================================================
		//	ストップ条件設定変更
		//===================================================
		private void cboStop_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			string	szBuff = new string(' ',100);
			//--------------------------------
			// Stop Numberの有効、無効を切り替え
			//--------------------------------
			szBuff = cboStop.Text;
			if (string.Compare(szBuff, "Number") == 0)
			{
				txtStopNumber.Enabled = true;
			}
			else
			{
				txtStopNumber.Enabled = false;
			}
		}
	}
}
