#pragma once
#include "LoadVmd.h"
namespace VMD_Parameter_Viewer {

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

	/// <summary>
	/// Form1 の概要
	///
	/// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた
	///          マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
	///          変更する必要があります。この変更を行わないと、
	///          デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、
	///          正しく相互に利用できなくなります。
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: ここにコンストラクタ コードを追加します
			//
		}

	protected:
		/// <summary>
		/// 使用中のリソースをすべてクリーンアップします。
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::DataGridView^  dataGridView1;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::Label^  label7;
	private: System::Windows::Forms::Label^  label8;
	private: System::Windows::Forms::Label^  label9;
	private: System::Windows::Forms::Label^  label10;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  BoneName;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  FrameNo;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Location;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Rotation;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Interpolation;
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	private: System::Windows::Forms::ToolStripMenuItem^  fileFToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  openOToolStripMenuItem;
	private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
	protected: 

	private:
		/// <summary>
		/// 必要なデザイナ変数です。
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
		/// コード エディタで変更しないでください。
		/// </summary>
		void InitializeComponent(void)
		{
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
			this->BoneName = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->FrameNo = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Location = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Rotation = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Interpolation = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->label7 = (gcnew System::Windows::Forms::Label());
			this->label8 = (gcnew System::Windows::Forms::Label());
			this->label9 = (gcnew System::Windows::Forms::Label());
			this->label10 = (gcnew System::Windows::Forms::Label());
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->fileFToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openOToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->BeginInit();
			this->menuStrip1->SuspendLayout();
			this->SuspendLayout();
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(86, 33);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(11, 12);
			this->label1->TabIndex = 0;
			this->label1->Text = L"-";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(86, 45);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(11, 12);
			this->label2->TabIndex = 1;
			this->label2->Text = L"-";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(86, 57);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(11, 12);
			this->label3->TabIndex = 2;
			this->label3->Text = L"-";
			// 
			// dataGridView1
			// 
			this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
			this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(5) {this->BoneName, 
				this->FrameNo, this->Location, this->Rotation, this->Interpolation});
			this->dataGridView1->Location = System::Drawing::Point(12, 75);
			this->dataGridView1->Name = L"dataGridView1";
			this->dataGridView1->RowTemplate->Height = 21;
			this->dataGridView1->Size = System::Drawing::Size(860, 379);
			this->dataGridView1->TabIndex = 3;
			// 
			// BoneName
			// 
			this->BoneName->HeaderText = L"BoneName";
			this->BoneName->Name = L"BoneName";
			// 
			// FrameNo
			// 
			this->FrameNo->HeaderText = L"FrameNo";
			this->FrameNo->Name = L"FrameNo";
			this->FrameNo->Width = 70;
			// 
			// Location
			// 
			this->Location->HeaderText = L"Location";
			this->Location->Name = L"Location";
			// 
			// Rotation
			// 
			this->Rotation->HeaderText = L"Rotation";
			this->Rotation->Name = L"Rotation";
			this->Rotation->Width = 130;
			// 
			// Interpolation
			// 
			this->Interpolation->HeaderText = L"Interpolation";
			this->Interpolation->Name = L"Interpolation";
			this->Interpolation->Width = 400;
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(12, 57);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(69, 12);
			this->label4->TabIndex = 6;
			this->label4->Text = L"Motions size";
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Location = System::Drawing::Point(12, 45);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(68, 12);
			this->label5->TabIndex = 5;
			this->label5->Text = L"Model Name";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Location = System::Drawing::Point(12, 33);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(41, 12);
			this->label6->TabIndex = 4;
			this->label6->Text = L"Header";
			// 
			// label7
			// 
			this->label7->AutoSize = true;
			this->label7->Location = System::Drawing::Point(325, 9);
			this->label7->Name = L"label7";
			this->label7->Size = System::Drawing::Size(0, 12);
			this->label7->TabIndex = 9;
			// 
			// label8
			// 
			this->label8->AutoSize = true;
			this->label8->Location = System::Drawing::Point(325, 21);
			this->label8->Name = L"label8";
			this->label8->Size = System::Drawing::Size(0, 12);
			this->label8->TabIndex = 8;
			// 
			// label9
			// 
			this->label9->AutoSize = true;
			this->label9->Location = System::Drawing::Point(325, 33);
			this->label9->Name = L"label9";
			this->label9->Size = System::Drawing::Size(0, 12);
			this->label9->TabIndex = 7;
			// 
			// label10
			// 
			this->label10->AutoSize = true;
			this->label10->Location = System::Drawing::Point(325, 45);
			this->label10->Name = L"label10";
			this->label10->Size = System::Drawing::Size(0, 12);
			this->label10->TabIndex = 10;
			// 
			// menuStrip1
			// 
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->fileFToolStripMenuItem});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(884, 24);
			this->menuStrip1->TabIndex = 11;
			this->menuStrip1->Text = L"menuStrip1";
			// 
			// fileFToolStripMenuItem
			// 
			this->fileFToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->openOToolStripMenuItem});
			this->fileFToolStripMenuItem->Name = L"fileFToolStripMenuItem";
			this->fileFToolStripMenuItem->Size = System::Drawing::Size(51, 20);
			this->fileFToolStripMenuItem->Text = L"File(&F)";
			// 
			// openOToolStripMenuItem
			// 
			this->openOToolStripMenuItem->Name = L"openOToolStripMenuItem";
			this->openOToolStripMenuItem->Size = System::Drawing::Size(112, 22);
			this->openOToolStripMenuItem->Text = L"Open(&O)";
			this->openOToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openOToolStripMenuItem_Click);
			// 
			// openFileDialog1
			// 
			this->openFileDialog1->FileName = L"openFileDialog1";
			this->openFileDialog1->FileOk += gcnew System::ComponentModel::CancelEventHandler(this, &Form1::openFileDialog1_FileOk);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(884, 455);
			this->Controls->Add(this->label10);
			this->Controls->Add(this->label7);
			this->Controls->Add(this->label8);
			this->Controls->Add(this->label9);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->label5);
			this->Controls->Add(this->label6);
			this->Controls->Add(this->dataGridView1);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->menuStrip1);
			this->MainMenuStrip = this->menuStrip1;
			this->Name = L"Form1";
			this->Text = L"VMD Parameter Viewer";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->EndInit();
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
			 }
	private: System::Void openOToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
				 openFileDialog1->ShowDialog();
			 }
	private: System::Void openFileDialog1_FileOk(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
				 IntPtr ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalUni(((OpenFileDialog^)sender)->FileName);
				 LoadVmd readVMD((LPCTSTR)ptr.ToPointer());
				 System::Runtime::InteropServices::Marshal::FreeHGlobal(ptr);
				 VmdHeader vmdHeader = readVMD.GetHeader();
				 vector<VmdMotion> vmdMotions = readVMD.GetMotions();
				 label1->Text = gcnew String(vmdHeader.vmdHeader);
				 label2->Text = gcnew String(vmdHeader.vmdModelName);
				 label3->Text = gcnew String(vmdMotions.size().ToString());
				 dataGridView1->RowCount = vmdMotions.size();
				 for (int i = 0; i < dataGridView1->RowCount; ++i) {
					 dataGridView1[0, i]->Value = gcnew String(vmdMotions[i].boneName);
					 dataGridView1[1, i]->Value = vmdMotions[i].flameNo.ToString();
					 dataGridView1[2, i]->Value = vmdMotions[i].location[0].ToString("F2");
					 for (int j = 1; j < 3; ++j) dataGridView1[2, i]->Value += gcnew String(", ") + vmdMotions[i].location[j].ToString("F2");
					 dataGridView1[3, i]->Value = vmdMotions[i].rotation[0].ToString("F2");
					 for (int j = 1; j < 4; ++j) dataGridView1[3, i]->Value += gcnew String(", ") + vmdMotions[i].rotation[j].ToString("F2");
					 dataGridView1[4, i]->Value = vmdMotions[i].interpolation[0].ToString("D3");
					 for (int j = 1; j < 16; ++j) dataGridView1[4, i]->Value += gcnew String(", ") + vmdMotions[i].interpolation[j].ToString("D3");
				 }
			 }
	};

}