#pragma once

#include "TUSBSCN2.h"

namespace S03CN2Sample {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	static const short DevId = 0;

	/// <summary>
	/// Form1 の概要
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: ここにコンストラクター コードを追加します
			//
		}

	protected:
		/// <summary>
		/// 使用中のリソースをすべてクリーンアップします。
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	internal: System::Windows::Forms::ComboBox^  SelEdgeDir3;
	protected: 
	internal: System::Windows::Forms::Label^  Label7;
	internal: System::Windows::Forms::Label^  Label16;
	internal: System::Windows::Forms::ComboBox^  SelClock3;
	internal: System::Windows::Forms::ComboBox^  SelEdgeDir2;
	internal: System::Windows::Forms::Label^  Label17;
	internal: System::Windows::Forms::ComboBox^  SelGateTime3;
	internal: System::Windows::Forms::Label^  Label8;
	internal: System::Windows::Forms::RadioButton^  OptPeriod3;
	internal: System::Windows::Forms::RadioButton^  OptFreq3;
	internal: System::Windows::Forms::Label^  Label18;
	internal: System::Windows::Forms::Label^  Label19;
	internal: System::Windows::Forms::ComboBox^  SelGateTime2;
	internal: System::Windows::Forms::Label^  CntDisp3;
	internal: System::Windows::Forms::RadioButton^  OptPeriod2;
	internal: System::Windows::Forms::RadioButton^  OptFreq2;
	internal: System::Windows::Forms::Label^  Label11;
	internal: System::Windows::Forms::GroupBox^  GroupBox1;
	internal: System::Windows::Forms::Label^  Label6;
	internal: System::Windows::Forms::ComboBox^  SelEdgeDir1;
	internal: System::Windows::Forms::Label^  Label5;
	internal: System::Windows::Forms::ComboBox^  SelDivide1;
	internal: System::Windows::Forms::Label^  Label4;
	internal: System::Windows::Forms::ComboBox^  SelClock1;
	internal: System::Windows::Forms::Label^  Label3;
	internal: System::Windows::Forms::ComboBox^  SelGateTime1;
	internal: System::Windows::Forms::RadioButton^  OptPeriod1;
	internal: System::Windows::Forms::RadioButton^  OptFreq1;
	internal: System::Windows::Forms::Label^  Label1;
	internal: System::Windows::Forms::Label^  Label2;
	internal: System::Windows::Forms::Label^  CntDisp1;
	internal: System::Windows::Forms::Label^  Label12;
	internal: System::Windows::Forms::Label^  Label14;
	internal: System::Windows::Forms::Label^  CntDisp2;
	internal: System::Windows::Forms::GroupBox^  GroupBox3;
	internal: System::Windows::Forms::Label^  Label15;
	internal: System::Windows::Forms::ComboBox^  SelDivide3;
	internal: System::Windows::Forms::Label^  Label10;
	internal: System::Windows::Forms::ComboBox^  SelDivide2;
	internal: System::Windows::Forms::GroupBox^  GroupBox2;
	internal: System::Windows::Forms::Label^  Label9;
	internal: System::Windows::Forms::ComboBox^  SelClock2;
	internal: System::Windows::Forms::Timer^  Timer1;
	private: System::ComponentModel::IContainer^  components;
	internal: 

	private:
		/// <summary>
		/// 必要なデザイナー変数です。
		/// </summary>
        //コントロールの配列
        //この配列を通してコントロールを使用します。

		array<System::Windows::Forms::Label^>^ ArryCntDisp;
        array<System::Windows::Forms::RadioButton^>^ ArryOptFreq;
        array<System::Windows::Forms::RadioButton^>^ ArryOptPeriod;
        array<System::Windows::Forms::ComboBox^>^ ArrySelGateTime;
        array<System::Windows::Forms::ComboBox^>^ ArrySelEdgeDir;
        array<System::Windows::Forms::ComboBox^>^ ArrySelClock;
        array<System::Windows::Forms::ComboBox^>^ ArrySelDivide;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
		/// コード エディターで変更しないでください。
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			this->SelEdgeDir3 = (gcnew System::Windows::Forms::ComboBox());
			this->Label7 = (gcnew System::Windows::Forms::Label());
			this->Label16 = (gcnew System::Windows::Forms::Label());
			this->SelClock3 = (gcnew System::Windows::Forms::ComboBox());
			this->SelEdgeDir2 = (gcnew System::Windows::Forms::ComboBox());
			this->Label17 = (gcnew System::Windows::Forms::Label());
			this->SelGateTime3 = (gcnew System::Windows::Forms::ComboBox());
			this->Label8 = (gcnew System::Windows::Forms::Label());
			this->OptPeriod3 = (gcnew System::Windows::Forms::RadioButton());
			this->OptFreq3 = (gcnew System::Windows::Forms::RadioButton());
			this->Label18 = (gcnew System::Windows::Forms::Label());
			this->Label19 = (gcnew System::Windows::Forms::Label());
			this->SelGateTime2 = (gcnew System::Windows::Forms::ComboBox());
			this->CntDisp3 = (gcnew System::Windows::Forms::Label());
			this->OptPeriod2 = (gcnew System::Windows::Forms::RadioButton());
			this->OptFreq2 = (gcnew System::Windows::Forms::RadioButton());
			this->Label11 = (gcnew System::Windows::Forms::Label());
			this->GroupBox1 = (gcnew System::Windows::Forms::GroupBox());
			this->Label6 = (gcnew System::Windows::Forms::Label());
			this->SelEdgeDir1 = (gcnew System::Windows::Forms::ComboBox());
			this->Label5 = (gcnew System::Windows::Forms::Label());
			this->SelDivide1 = (gcnew System::Windows::Forms::ComboBox());
			this->Label4 = (gcnew System::Windows::Forms::Label());
			this->SelClock1 = (gcnew System::Windows::Forms::ComboBox());
			this->Label3 = (gcnew System::Windows::Forms::Label());
			this->SelGateTime1 = (gcnew System::Windows::Forms::ComboBox());
			this->OptPeriod1 = (gcnew System::Windows::Forms::RadioButton());
			this->OptFreq1 = (gcnew System::Windows::Forms::RadioButton());
			this->Label1 = (gcnew System::Windows::Forms::Label());
			this->Label2 = (gcnew System::Windows::Forms::Label());
			this->CntDisp1 = (gcnew System::Windows::Forms::Label());
			this->Label12 = (gcnew System::Windows::Forms::Label());
			this->Label14 = (gcnew System::Windows::Forms::Label());
			this->CntDisp2 = (gcnew System::Windows::Forms::Label());
			this->GroupBox3 = (gcnew System::Windows::Forms::GroupBox());
			this->Label15 = (gcnew System::Windows::Forms::Label());
			this->SelDivide3 = (gcnew System::Windows::Forms::ComboBox());
			this->Label10 = (gcnew System::Windows::Forms::Label());
			this->SelDivide2 = (gcnew System::Windows::Forms::ComboBox());
			this->GroupBox2 = (gcnew System::Windows::Forms::GroupBox());
			this->Label9 = (gcnew System::Windows::Forms::Label());
			this->SelClock2 = (gcnew System::Windows::Forms::ComboBox());
			this->Timer1 = (gcnew System::Windows::Forms::Timer(this->components));
			this->GroupBox1->SuspendLayout();
			this->GroupBox3->SuspendLayout();
			this->GroupBox2->SuspendLayout();
			this->SuspendLayout();
			// 
			// SelEdgeDir3
			// 
			this->SelEdgeDir3->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelEdgeDir3->Items->AddRange(gcnew cli::array< System::Object^  >(2) {L"立上り", L"立下り"});
			this->SelEdgeDir3->Location = System::Drawing::Point(360, 96);
			this->SelEdgeDir3->Name = L"SelEdgeDir3";
			this->SelEdgeDir3->Size = System::Drawing::Size(72, 20);
			this->SelEdgeDir3->TabIndex = 11;
			this->SelEdgeDir3->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelEdgeDir_SelectedIndexChanged);
			// 
			// Label7
			// 
			this->Label7->Location = System::Drawing::Point(360, 80);
			this->Label7->Name = L"Label7";
			this->Label7->Size = System::Drawing::Size(72, 16);
			this->Label7->TabIndex = 12;
			this->Label7->Text = L"ExtInputSet";
			// 
			// Label16
			// 
			this->Label16->Location = System::Drawing::Point(144, 80);
			this->Label16->Name = L"Label16";
			this->Label16->Size = System::Drawing::Size(72, 16);
			this->Label16->TabIndex = 8;
			this->Label16->Text = L"SelClockSet";
			// 
			// SelClock3
			// 
			this->SelClock3->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelClock3->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"100nS", L"1μS", L"10μS", L"100μS"});
			this->SelClock3->Location = System::Drawing::Point(144, 96);
			this->SelClock3->Name = L"SelClock3";
			this->SelClock3->Size = System::Drawing::Size(72, 20);
			this->SelClock3->TabIndex = 7;
			this->SelClock3->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelClock_SelectedIndexChanged);
			// 
			// SelEdgeDir2
			// 
			this->SelEdgeDir2->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelEdgeDir2->Items->AddRange(gcnew cli::array< System::Object^  >(2) {L"立上り", L"立下り"});
			this->SelEdgeDir2->Location = System::Drawing::Point(360, 96);
			this->SelEdgeDir2->Name = L"SelEdgeDir2";
			this->SelEdgeDir2->Size = System::Drawing::Size(72, 20);
			this->SelEdgeDir2->TabIndex = 11;
			this->SelEdgeDir2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelEdgeDir_SelectedIndexChanged);
			// 
			// Label17
			// 
			this->Label17->Location = System::Drawing::Point(40, 80);
			this->Label17->Name = L"Label17";
			this->Label17->Size = System::Drawing::Size(56, 16);
			this->Label17->TabIndex = 6;
			this->Label17->Text = L"GateTime";
			// 
			// SelGateTime3
			// 
			this->SelGateTime3->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelGateTime3->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"10mS", L"100mS", L"1S", L"10S"});
			this->SelGateTime3->Location = System::Drawing::Point(32, 96);
			this->SelGateTime3->Name = L"SelGateTime3";
			this->SelGateTime3->Size = System::Drawing::Size(72, 20);
			this->SelGateTime3->TabIndex = 5;
			this->SelGateTime3->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelGateTime_SelectedIndexChanged);
			// 
			// Label8
			// 
			this->Label8->Location = System::Drawing::Point(248, 80);
			this->Label8->Name = L"Label8";
			this->Label8->Size = System::Drawing::Size(72, 16);
			this->Label8->TabIndex = 10;
			this->Label8->Text = L"Divider Set";
			// 
			// OptPeriod3
			// 
			this->OptPeriod3->Location = System::Drawing::Point(368, 40);
			this->OptPeriod3->Name = L"OptPeriod3";
			this->OptPeriod3->Size = System::Drawing::Size(96, 24);
			this->OptPeriod3->TabIndex = 4;
			this->OptPeriod3->Text = L"周期モード";
			this->OptPeriod3->CheckedChanged += gcnew System::EventHandler(this, &Form1::OptPeriod_CheckedChanged);
			// 
			// OptFreq3
			// 
			this->OptFreq3->Location = System::Drawing::Point(256, 40);
			this->OptFreq3->Name = L"OptFreq3";
			this->OptFreq3->Size = System::Drawing::Size(96, 24);
			this->OptFreq3->TabIndex = 3;
			this->OptFreq3->Text = L"周波数モード";
			this->OptFreq3->CheckedChanged += gcnew System::EventHandler(this, &Form1::OptFreq_CheckedChanged);
			// 
			// Label18
			// 
			this->Label18->Location = System::Drawing::Point(320, 24);
			this->Label18->Name = L"Label18";
			this->Label18->Size = System::Drawing::Size(80, 24);
			this->Label18->TabIndex = 2;
			this->Label18->Text = L"Counter Mode";
			// 
			// Label19
			// 
			this->Label19->Location = System::Drawing::Point(24, 24);
			this->Label19->Name = L"Label19";
			this->Label19->Size = System::Drawing::Size(128, 16);
			this->Label19->TabIndex = 1;
			this->Label19->Text = L"Counter Read";
			// 
			// SelGateTime2
			// 
			this->SelGateTime2->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelGateTime2->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"10mS", L"100mS", L"1S", L"10S"});
			this->SelGateTime2->Location = System::Drawing::Point(32, 96);
			this->SelGateTime2->Name = L"SelGateTime2";
			this->SelGateTime2->Size = System::Drawing::Size(72, 20);
			this->SelGateTime2->TabIndex = 5;
			this->SelGateTime2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelGateTime_SelectedIndexChanged);
			// 
			// CntDisp3
			// 
			this->CntDisp3->BackColor = System::Drawing::Color::Teal;
			this->CntDisp3->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->CntDisp3->Cursor = System::Windows::Forms::Cursors::Default;
			this->CntDisp3->Font = (gcnew System::Drawing::Font(L"ＭＳ ゴシック", 20.25F));
			this->CntDisp3->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(192)), 
				static_cast<System::Int32>(static_cast<System::Byte>(128)));
			this->CntDisp3->Location = System::Drawing::Point(16, 40);
			this->CntDisp3->Name = L"CntDisp3";
			this->CntDisp3->Size = System::Drawing::Size(160, 32);
			this->CntDisp3->TabIndex = 0;
			this->CntDisp3->Text = L"0000000";
			this->CntDisp3->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			// 
			// OptPeriod2
			// 
			this->OptPeriod2->Location = System::Drawing::Point(368, 40);
			this->OptPeriod2->Name = L"OptPeriod2";
			this->OptPeriod2->Size = System::Drawing::Size(96, 24);
			this->OptPeriod2->TabIndex = 4;
			this->OptPeriod2->Text = L"周期モード";
			this->OptPeriod2->CheckedChanged += gcnew System::EventHandler(this, &Form1::OptPeriod_CheckedChanged);
			// 
			// OptFreq2
			// 
			this->OptFreq2->Location = System::Drawing::Point(256, 40);
			this->OptFreq2->Name = L"OptFreq2";
			this->OptFreq2->Size = System::Drawing::Size(96, 24);
			this->OptFreq2->TabIndex = 3;
			this->OptFreq2->Text = L"周波数モード";
			this->OptFreq2->CheckedChanged += gcnew System::EventHandler(this, &Form1::OptFreq_CheckedChanged);
			// 
			// Label11
			// 
			this->Label11->Location = System::Drawing::Point(320, 24);
			this->Label11->Name = L"Label11";
			this->Label11->Size = System::Drawing::Size(80, 24);
			this->Label11->TabIndex = 2;
			this->Label11->Text = L"Counter Mode";
			// 
			// GroupBox1
			// 
			this->GroupBox1->Controls->Add(this->Label6);
			this->GroupBox1->Controls->Add(this->SelEdgeDir1);
			this->GroupBox1->Controls->Add(this->Label5);
			this->GroupBox1->Controls->Add(this->SelDivide1);
			this->GroupBox1->Controls->Add(this->Label4);
			this->GroupBox1->Controls->Add(this->SelClock1);
			this->GroupBox1->Controls->Add(this->Label3);
			this->GroupBox1->Controls->Add(this->SelGateTime1);
			this->GroupBox1->Controls->Add(this->OptPeriod1);
			this->GroupBox1->Controls->Add(this->OptFreq1);
			this->GroupBox1->Controls->Add(this->Label1);
			this->GroupBox1->Controls->Add(this->Label2);
			this->GroupBox1->Controls->Add(this->CntDisp1);
			this->GroupBox1->Location = System::Drawing::Point(12, 15);
			this->GroupBox1->Name = L"GroupBox1";
			this->GroupBox1->Size = System::Drawing::Size(488, 128);
			this->GroupBox1->TabIndex = 9;
			this->GroupBox1->TabStop = false;
			this->GroupBox1->Text = L"INPUT1";
			// 
			// Label6
			// 
			this->Label6->Location = System::Drawing::Point(360, 80);
			this->Label6->Name = L"Label6";
			this->Label6->Size = System::Drawing::Size(72, 16);
			this->Label6->TabIndex = 12;
			this->Label6->Text = L"ExtInputSet";
			// 
			// SelEdgeDir1
			// 
			this->SelEdgeDir1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelEdgeDir1->Items->AddRange(gcnew cli::array< System::Object^  >(2) {L"立上り", L"立下り"});
			this->SelEdgeDir1->Location = System::Drawing::Point(360, 96);
			this->SelEdgeDir1->Name = L"SelEdgeDir1";
			this->SelEdgeDir1->Size = System::Drawing::Size(72, 20);
			this->SelEdgeDir1->TabIndex = 11;
			this->SelEdgeDir1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelEdgeDir_SelectedIndexChanged);
			// 
			// Label5
			// 
			this->Label5->Location = System::Drawing::Point(248, 80);
			this->Label5->Name = L"Label5";
			this->Label5->Size = System::Drawing::Size(72, 16);
			this->Label5->TabIndex = 10;
			this->Label5->Text = L"Divider Set";
			// 
			// SelDivide1
			// 
			this->SelDivide1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelDivide1->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"1/1", L"1/10", L"1/100", L"1/1000"});
			this->SelDivide1->Location = System::Drawing::Point(248, 96);
			this->SelDivide1->Name = L"SelDivide1";
			this->SelDivide1->Size = System::Drawing::Size(72, 20);
			this->SelDivide1->TabIndex = 9;
			this->SelDivide1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelDivide_SelectedIndexChanged);
			// 
			// Label4
			// 
			this->Label4->Location = System::Drawing::Point(144, 80);
			this->Label4->Name = L"Label4";
			this->Label4->Size = System::Drawing::Size(72, 16);
			this->Label4->TabIndex = 8;
			this->Label4->Text = L"SelClockSet";
			// 
			// SelClock1
			// 
			this->SelClock1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelClock1->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"100nS", L"1μS", L"10μS", L"100μS"});
			this->SelClock1->Location = System::Drawing::Point(144, 96);
			this->SelClock1->Name = L"SelClock1";
			this->SelClock1->Size = System::Drawing::Size(72, 20);
			this->SelClock1->TabIndex = 7;
			this->SelClock1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelClock_SelectedIndexChanged);
			// 
			// Label3
			// 
			this->Label3->Location = System::Drawing::Point(40, 80);
			this->Label3->Name = L"Label3";
			this->Label3->Size = System::Drawing::Size(56, 16);
			this->Label3->TabIndex = 6;
			this->Label3->Text = L"GateTime";
			// 
			// SelGateTime1
			// 
			this->SelGateTime1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelGateTime1->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"10mS", L"100mS", L"1S", L"10S"});
			this->SelGateTime1->Location = System::Drawing::Point(32, 96);
			this->SelGateTime1->Name = L"SelGateTime1";
			this->SelGateTime1->Size = System::Drawing::Size(72, 20);
			this->SelGateTime1->TabIndex = 5;
			this->SelGateTime1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelGateTime_SelectedIndexChanged);
			// 
			// OptPeriod1
			// 
			this->OptPeriod1->Location = System::Drawing::Point(368, 40);
			this->OptPeriod1->Name = L"OptPeriod1";
			this->OptPeriod1->Size = System::Drawing::Size(96, 24);
			this->OptPeriod1->TabIndex = 4;
			this->OptPeriod1->Text = L"周期モード";
			this->OptPeriod1->CheckedChanged += gcnew System::EventHandler(this, &Form1::OptPeriod_CheckedChanged);
			// 
			// OptFreq1
			// 
			this->OptFreq1->Location = System::Drawing::Point(256, 40);
			this->OptFreq1->Name = L"OptFreq1";
			this->OptFreq1->Size = System::Drawing::Size(96, 24);
			this->OptFreq1->TabIndex = 3;
			this->OptFreq1->Text = L"周波数モード";
			this->OptFreq1->CheckedChanged += gcnew System::EventHandler(this, &Form1::OptFreq_CheckedChanged);
			// 
			// Label1
			// 
			this->Label1->Location = System::Drawing::Point(320, 24);
			this->Label1->Name = L"Label1";
			this->Label1->Size = System::Drawing::Size(80, 24);
			this->Label1->TabIndex = 2;
			this->Label1->Text = L"Counter Mode";
			// 
			// Label2
			// 
			this->Label2->Location = System::Drawing::Point(24, 24);
			this->Label2->Name = L"Label2";
			this->Label2->Size = System::Drawing::Size(128, 16);
			this->Label2->TabIndex = 1;
			this->Label2->Text = L"Counter Read";
			// 
			// CntDisp1
			// 
			this->CntDisp1->BackColor = System::Drawing::Color::Teal;
			this->CntDisp1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->CntDisp1->Cursor = System::Windows::Forms::Cursors::Default;
			this->CntDisp1->Font = (gcnew System::Drawing::Font(L"ＭＳ ゴシック", 20.25F));
			this->CntDisp1->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(192)), 
				static_cast<System::Int32>(static_cast<System::Byte>(128)));
			this->CntDisp1->Location = System::Drawing::Point(16, 40);
			this->CntDisp1->Name = L"CntDisp1";
			this->CntDisp1->Size = System::Drawing::Size(160, 32);
			this->CntDisp1->TabIndex = 0;
			this->CntDisp1->Text = L"0000000";
			this->CntDisp1->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			// 
			// Label12
			// 
			this->Label12->Location = System::Drawing::Point(24, 24);
			this->Label12->Name = L"Label12";
			this->Label12->Size = System::Drawing::Size(128, 16);
			this->Label12->TabIndex = 1;
			this->Label12->Text = L"Counter Read";
			// 
			// Label14
			// 
			this->Label14->Location = System::Drawing::Point(360, 80);
			this->Label14->Name = L"Label14";
			this->Label14->Size = System::Drawing::Size(72, 16);
			this->Label14->TabIndex = 12;
			this->Label14->Text = L"ExtInputSet";
			// 
			// CntDisp2
			// 
			this->CntDisp2->BackColor = System::Drawing::Color::Teal;
			this->CntDisp2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->CntDisp2->Cursor = System::Windows::Forms::Cursors::Default;
			this->CntDisp2->Font = (gcnew System::Drawing::Font(L"ＭＳ ゴシック", 20.25F));
			this->CntDisp2->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(192)), 
				static_cast<System::Int32>(static_cast<System::Byte>(128)));
			this->CntDisp2->Location = System::Drawing::Point(16, 40);
			this->CntDisp2->Name = L"CntDisp2";
			this->CntDisp2->Size = System::Drawing::Size(160, 32);
			this->CntDisp2->TabIndex = 0;
			this->CntDisp2->Text = L"0000000";
			this->CntDisp2->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			// 
			// GroupBox3
			// 
			this->GroupBox3->Controls->Add(this->Label14);
			this->GroupBox3->Controls->Add(this->SelEdgeDir3);
			this->GroupBox3->Controls->Add(this->Label15);
			this->GroupBox3->Controls->Add(this->SelDivide3);
			this->GroupBox3->Controls->Add(this->Label16);
			this->GroupBox3->Controls->Add(this->SelClock3);
			this->GroupBox3->Controls->Add(this->Label17);
			this->GroupBox3->Controls->Add(this->SelGateTime3);
			this->GroupBox3->Controls->Add(this->OptPeriod3);
			this->GroupBox3->Controls->Add(this->OptFreq3);
			this->GroupBox3->Controls->Add(this->Label18);
			this->GroupBox3->Controls->Add(this->Label19);
			this->GroupBox3->Controls->Add(this->CntDisp3);
			this->GroupBox3->Location = System::Drawing::Point(12, 287);
			this->GroupBox3->Name = L"GroupBox3";
			this->GroupBox3->Size = System::Drawing::Size(488, 128);
			this->GroupBox3->TabIndex = 11;
			this->GroupBox3->TabStop = false;
			this->GroupBox3->Text = L"INPUT3";
			// 
			// Label15
			// 
			this->Label15->Location = System::Drawing::Point(248, 80);
			this->Label15->Name = L"Label15";
			this->Label15->Size = System::Drawing::Size(72, 16);
			this->Label15->TabIndex = 10;
			this->Label15->Text = L"Divider Set";
			// 
			// SelDivide3
			// 
			this->SelDivide3->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelDivide3->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"1/1", L"1/10", L"1/100", L"1/1000"});
			this->SelDivide3->Location = System::Drawing::Point(248, 96);
			this->SelDivide3->Name = L"SelDivide3";
			this->SelDivide3->Size = System::Drawing::Size(72, 20);
			this->SelDivide3->TabIndex = 9;
			this->SelDivide3->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelDivide_SelectedIndexChanged);
			// 
			// Label10
			// 
			this->Label10->Location = System::Drawing::Point(40, 80);
			this->Label10->Name = L"Label10";
			this->Label10->Size = System::Drawing::Size(56, 16);
			this->Label10->TabIndex = 6;
			this->Label10->Text = L"GateTime";
			// 
			// SelDivide2
			// 
			this->SelDivide2->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelDivide2->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"1/1", L"1/10", L"1/100", L"1/1000"});
			this->SelDivide2->Location = System::Drawing::Point(248, 96);
			this->SelDivide2->Name = L"SelDivide2";
			this->SelDivide2->Size = System::Drawing::Size(72, 20);
			this->SelDivide2->TabIndex = 9;
			this->SelDivide2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelDivide_SelectedIndexChanged);
			// 
			// GroupBox2
			// 
			this->GroupBox2->Controls->Add(this->Label7);
			this->GroupBox2->Controls->Add(this->SelEdgeDir2);
			this->GroupBox2->Controls->Add(this->Label8);
			this->GroupBox2->Controls->Add(this->SelDivide2);
			this->GroupBox2->Controls->Add(this->Label9);
			this->GroupBox2->Controls->Add(this->SelClock2);
			this->GroupBox2->Controls->Add(this->Label10);
			this->GroupBox2->Controls->Add(this->SelGateTime2);
			this->GroupBox2->Controls->Add(this->OptPeriod2);
			this->GroupBox2->Controls->Add(this->OptFreq2);
			this->GroupBox2->Controls->Add(this->Label11);
			this->GroupBox2->Controls->Add(this->Label12);
			this->GroupBox2->Controls->Add(this->CntDisp2);
			this->GroupBox2->Location = System::Drawing::Point(12, 151);
			this->GroupBox2->Name = L"GroupBox2";
			this->GroupBox2->Size = System::Drawing::Size(488, 128);
			this->GroupBox2->TabIndex = 10;
			this->GroupBox2->TabStop = false;
			this->GroupBox2->Text = L"INPUT2";
			// 
			// Label9
			// 
			this->Label9->Location = System::Drawing::Point(144, 80);
			this->Label9->Name = L"Label9";
			this->Label9->Size = System::Drawing::Size(72, 16);
			this->Label9->TabIndex = 8;
			this->Label9->Text = L"SelClockSet";
			// 
			// SelClock2
			// 
			this->SelClock2->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->SelClock2->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"100nS", L"1μS", L"10μS", L"100μS"});
			this->SelClock2->Location = System::Drawing::Point(144, 96);
			this->SelClock2->Name = L"SelClock2";
			this->SelClock2->Size = System::Drawing::Size(72, 20);
			this->SelClock2->TabIndex = 7;
			this->SelClock2->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::SelClock_SelectedIndexChanged);
			// 
			// Timer1
			// 
			this->Timer1->Tick += gcnew System::EventHandler(this, &Form1::Timer1_Tick);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(512, 430);
			this->Controls->Add(this->GroupBox1);
			this->Controls->Add(this->GroupBox3);
			this->Controls->Add(this->GroupBox2);
			this->Name = L"Form1";
			this->Text = L"TUSB-S03CN2サンプル";
			this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &Form1::Form1_FormClosed);
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->GroupBox1->ResumeLayout(false);
			this->GroupBox3->ResumeLayout(false);
			this->GroupBox2->ResumeLayout(false);
			this->ResumeLayout(false);

		}
#pragma endregion

		void SettingInit(void)
		{
			short retcode;
            int ch;

            //コントロールの配列に画面のコントロールを設定します
			ArryCntDisp = gcnew array<System::Windows::Forms::Label^>(3) {CntDisp1,CntDisp2,CntDisp3};
            ArryOptFreq = gcnew array<System::Windows::Forms::RadioButton^>(3) {OptFreq1, OptFreq2, OptFreq3};
            ArryOptPeriod = gcnew array<System::Windows::Forms::RadioButton^>(3) {OptPeriod1, OptPeriod2, OptPeriod3};
            ArrySelGateTime = gcnew array<System::Windows::Forms::ComboBox^>(3) {SelGateTime1, SelGateTime2, SelGateTime3};
            ArrySelEdgeDir = gcnew array<System::Windows::Forms::ComboBox^>(3) {SelEdgeDir1, SelEdgeDir2, SelEdgeDir3};
            ArrySelClock = gcnew array<System::Windows::Forms::ComboBox^>(3) {SelClock1, SelClock2, SelClock3};
            ArrySelDivide = gcnew array<System::Windows::Forms::ComboBox^>(3) { SelDivide1, SelDivide2, SelDivide3 };

            for (ch = 0; ch < 3; ch++)
            {
                //各コントロールのTagにchを設定して後で操作に使用します
                ArryOptFreq[ch]->Tag = (unsigned char) ch;
                ArryOptPeriod[ch]->Tag = (unsigned char) ch;
                ArrySelGateTime[ch]->Tag = (unsigned char) ch;
                ArrySelEdgeDir[ch]->Tag = (unsigned char) ch;
                ArrySelClock[ch]->Tag = (unsigned char) ch;
                ArrySelDivide[ch]->Tag = (unsigned char) ch;

                //各コントロールに値を設定初期化します
                ArryOptFreq[ch]->Checked = true;// 周波数モード
                ArrySelGateTime[ch]->SelectedIndex = 0;// 10msゲート
                ArrySelEdgeDir[ch]->SelectedIndex = 0;// 立上りエッジ
                ArrySelClock[ch]->SelectedIndex = 0;// 100nsクロック
                ArrySelDivide[ch]->SelectedIndex = 0;// 分周期1/1

                if((retcode = Tusbs03cn2_Counter_Mode(DevId, (unsigned char)ch, 1)) != 0)
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                if((retcode = Tusbs03cn2_Gate_Time(DevId, (unsigned char) ch, (unsigned char) ArrySelGateTime[ch]->SelectedIndex)) != 0)
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                if((retcode = Tusbs03cn2_Cnt_Clock_Set(DevId, (unsigned char) ch, (unsigned char) ArrySelClock[ch]->SelectedIndex)) != 0 )
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                if((retcode = Tusbs03cn2_Divider_Set(DevId, (unsigned char) ch, (unsigned char) ArrySelDivide[ch]->SelectedIndex)) != 0 )
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                if((retcode = Tusbs03cn2_Ext_Input_Set(DevId, (unsigned char) ch, (unsigned char) ArrySelEdgeDir[ch]->SelectedIndex)) != 0 )
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
            }
		}
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
            short retcode;

           //デバイスオープン
            try
            {
                if ((retcode = Tusbs03cn2_Device_Open(DevId)) != 0)
                {
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                    this->Close();
                }
                else
                {
                    SettingInit();//初期設定
                    Timer1->Enabled = true;
                }
            }
            catch (Exception^ ex)
            {
                MessageBox::Show(ex->Message);
                this->Close();
            }
		 }
private: System::Void Form1_FormClosed(System::Object^  sender, System::Windows::Forms::FormClosedEventArgs^  e) {
			 Tusbs03cn2_Device_Close(DevId);//デバイスクローズ
		 }
private: System::Void OptFreq_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
            short retcode;
            RadioButton^ tmpControl = (RadioButton^)sender;
            if (tmpControl->Checked)
            {
                if ((retcode = Tusbs03cn2_Counter_Mode(DevId, (unsigned char)(tmpControl->Tag), 1)) != 0)
                {
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                }
            }
		 }
private: System::Void OptPeriod_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
            short retcode;
            RadioButton^ tmpControl = (RadioButton^)sender;
            if( tmpControl->Checked)
            {
                if((retcode = Tusbs03cn2_Counter_Mode(DevId,(unsigned char)(tmpControl->Tag),0)) != 0)
                {
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                }
            }
		 }
private: System::Void SelGateTime_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
            short retcode;
            ComboBox^ tmpControl = (ComboBox^)sender;
            if ((retcode = Tusbs03cn2_Gate_Time(DevId, (unsigned char)(tmpControl->Tag), (unsigned char)(tmpControl->SelectedIndex))) != 0)
            {
                MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
            }
		 }
private: System::Void SelClock_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
            short retcode;
            ComboBox^ tmpControl = (ComboBox^)sender;
            if ((retcode = Tusbs03cn2_Cnt_Clock_Set(DevId, (unsigned char)(tmpControl->Tag), (unsigned char)(tmpControl->SelectedIndex))) != 0)
            {
                MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
            }
		 }
private: System::Void SelDivide_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
            short retcode;
            ComboBox^ tmpControl = (ComboBox^)sender;
            if ((retcode = Tusbs03cn2_Divider_Set(DevId, (unsigned char)(tmpControl->Tag), (unsigned char)(tmpControl->SelectedIndex))) != 0)
            {
                MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
            }
		 }
private: System::Void SelEdgeDir_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
            short retcode;
            ComboBox^ tmpControl = (ComboBox^)sender;
            if ((retcode = Tusbs03cn2_Ext_Input_Set(DevId, (unsigned char)(tmpControl->Tag), (unsigned char)(tmpControl->SelectedIndex))) != 0)
            {
                MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
            }
		 }
private: System::Void Timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
            short retcode;
            int CountNum;//カウント値
            unsigned char Valid;//有効フラグ
            unsigned char ch;

            for(ch = 0; ch < 3 ; ch++ )
            {
                if((retcode = Tusbs03cn2_Counter_Read(DevId,ch,&CountNum,&Valid)) != 0 )
                {
                    MessageBox::Show(Tusbs03cn2_GetErrMessage(retcode));
                    Timer1->Enabled = false;
                    return;
                }
                
                if(Valid == 0)//読み込み値が無効ならば
                {
                    ArryCntDisp[ch]->Text = "";
                }
                else//有効ならば
                {
                    ArryCntDisp[ch]->Text = CountNum.ToString("d");
                }
            }
		 }
};
}

