/[Sims3RigEditor]/trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h
ViewVC logotype

Diff of /trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/07/29 17:25:37	5
+++ trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h	2010/07/30 00:28:19	6
@@ -9,14 +9,14 @@
 using namespace System::Windows::Forms;
 using namespace System::Data;
 using namespace System::Drawing;
-
-
-namespace gr2lib
-{
-	namespace core
-	{
-		namespace rigeditor
-		{
+using namespace System::Runtime::InteropServices;
+//
+//namespace gr2lib
+//{
+//	namespace core
+//	{
+//		namespace rigeditor
+//		{
 			/// <summary>
 			/// Summary for gr2lib_rigeditor_frm
 			///
@@ -28,6 +28,8 @@
 			/// </summary>
 			public ref class gr2lib_rigeditor_frm : public System::Windows::Forms::Form
 			{
+			private:			
+				grannyfile* _grn_file;
 			public:
 				gr2lib_rigeditor_frm(void)
 				{
@@ -40,33 +42,9 @@
 				{
 					InitializeComponent();
 					// parse art tool info
-					
-					ArtToolInfo^ _ArtToolInfo = gcnew ArtToolInfo();
-					_ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName));
-
-						Vector3* Origin = new Vector3(
-							grn_file->GrannyFileInfo->ArtToolInfo->Origin[0],
-							grn_file->GrannyFileInfo->ArtToolInfo->Origin[1],
-							grn_file->GrannyFileInfo->ArtToolInfo->Origin[2]);
-						Vector3* Right = new Vector3(
-							grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0],
-							grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1],
-							grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2]);
-						Vector3* Up = new Vector3(
-							grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0],
-							grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1],
-							grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2]);
-						Vector3* Back = new Vector3(
-							grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0],
-							grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1],
-							grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2]);
-
-					_ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
-
-					List<Object^> _selected_object_list = gcnew List<Object^>();
-					_selected_object_list.Add(_ArtToolInfo);
-
-					propgrid->SelectedObjects = _selected_object_list.ToArray();
+					_grn_file = grn_file;
+					propgrid->SelectedObjects = ConvertToManaged();
+				
 				}
 
 			protected:
@@ -82,6 +60,14 @@
 				}
 			private: System::Windows::Forms::PropertyGrid^  propgrid;
 			protected: 
+			private: System::Windows::Forms::MenuStrip^  mainmenu;
+			private: System::Windows::Forms::ToolStripMenuItem^  mnuFile;
+			private: System::Windows::Forms::ToolStripMenuItem^  mnuItemExit;
+			private: System::Windows::Forms::ToolStripMenuItem^  mnuItemOpen;
+			private: System::Windows::Forms::ToolStripMenuItem^  mnuItemSave;
+			private: System::Windows::Forms::ToolStripMenuItem^  mnuItemSaveAs;
+
+			protected: 
 
 			private:
 				/// <summary>
@@ -97,29 +83,183 @@
 				void InitializeComponent(void)
 				{
 					this->propgrid = (gcnew System::Windows::Forms::PropertyGrid());
+					this->mainmenu = (gcnew System::Windows::Forms::MenuStrip());
+					this->mnuFile = (gcnew System::Windows::Forms::ToolStripMenuItem());
+					this->mnuItemExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
+					this->mnuItemOpen = (gcnew System::Windows::Forms::ToolStripMenuItem());
+					this->mnuItemSave = (gcnew System::Windows::Forms::ToolStripMenuItem());
+					this->mnuItemSaveAs = (gcnew System::Windows::Forms::ToolStripMenuItem());
+					this->mainmenu->SuspendLayout();
 					this->SuspendLayout();
 					// 
 					// propgrid
 					// 
 					this->propgrid->Dock = System::Windows::Forms::DockStyle::Fill;
-					this->propgrid->Location = System::Drawing::Point(0, 0);
+					this->propgrid->Location = System::Drawing::Point(0, 24);
 					this->propgrid->Name = L"propgrid";
-					this->propgrid->Size = System::Drawing::Size(284, 262);
-					this->propgrid->TabIndex = 1;
+					this->propgrid->PropertySort = System::Windows::Forms::PropertySort::Categorized;
+					this->propgrid->Size = System::Drawing::Size(558, 456);
+					this->propgrid->TabIndex = 4;
+					this->propgrid->ToolbarVisible = false;
+					// 
+					// mainmenu
+					// 
+					this->mainmenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->mnuFile});
+					this->mainmenu->Location = System::Drawing::Point(0, 0);
+					this->mainmenu->Name = L"mainmenu";
+					this->mainmenu->Size = System::Drawing::Size(558, 24);
+					this->mainmenu->TabIndex = 3;
+					this->mainmenu->Text = L"menuStrip1";
+					// 
+					// mnuFile
+					// 
+					this->mnuFile->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->mnuItemOpen, 
+						this->mnuItemSave, this->mnuItemSaveAs, this->mnuItemExit});
+					this->mnuFile->Name = L"mnuFile";
+					this->mnuFile->Size = System::Drawing::Size(37, 20);
+					this->mnuFile->Text = L"&File";
+					// 
+					// mnuItemExit
+					// 
+					this->mnuItemExit->Name = L"mnuItemExit";
+					this->mnuItemExit->Size = System::Drawing::Size(152, 22);
+					this->mnuItemExit->Text = L"&Exit";
+					this->mnuItemExit->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemExit_Click);
+					// 
+					// mnuItemOpen
+					// 
+					this->mnuItemOpen->Name = L"mnuItemOpen";
+					this->mnuItemOpen->Size = System::Drawing::Size(152, 22);
+					this->mnuItemOpen->Text = L"&Open";
+					this->mnuItemOpen->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemOpen_Click);
+					// 
+					// mnuItemSave
+					// 
+					this->mnuItemSave->Name = L"mnuItemSave";
+					this->mnuItemSave->Size = System::Drawing::Size(152, 22);
+					this->mnuItemSave->Text = L"&Save";
+					// 
+					// mnuItemSaveAs
+					// 
+					this->mnuItemSaveAs->Name = L"mnuItemSaveAs";
+					this->mnuItemSaveAs->Size = System::Drawing::Size(152, 22);
+					this->mnuItemSaveAs->Text = L"Save &As";
 					// 
 					// gr2lib_rigeditor_frm
 					// 
 					this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
 					this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
-					this->ClientSize = System::Drawing::Size(284, 262);
+					this->ClientSize = System::Drawing::Size(558, 480);
 					this->Controls->Add(this->propgrid);
+					this->Controls->Add(this->mainmenu);
 					this->Name = L"gr2lib_rigeditor_frm";
 					this->Text = L"gr2lib_rigeditor_frm";
+					this->mainmenu->ResumeLayout(false);
+					this->mainmenu->PerformLayout();
 					this->ResumeLayout(false);
+					this->PerformLayout();
 
 				}
 		#pragma endregion
-			};
-		}
-	}
-}
\ No newline at end of file
+#pragma region MarshalToMananaged
+				ArtToolInfo^ _ArtToolInfo;
+
+				#pragma region ManagedNativeParsing
+				array<Object^>^ ConvertToManaged()
+				{
+					List<Object^> ret = gcnew List<Object^>();
+
+					// Art Tool info
+						ret.Add(ArtToolInfo_ToManaged(_grn_file->GrannyFileInfo->ArtToolInfo));
+
+					return ret.ToArray();
+				}
+				void ConvertToNative()
+				{
+					// Art Tool info
+					ArtToolInfo_ToNative();
+				}
+				#pragma endregion
+						
+						#pragma region ArtToolInfo
+						ArtToolInfo^ ArtToolInfo_ToManaged(granny_art_tool_info* toolinfo)
+						{
+							_ArtToolInfo = gcnew ArtToolInfo();
+							// Tool Name
+							_ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(toolinfo->FromArtToolName));
+
+							// Tool Vector
+							Vector3* Origin = new Vector3(
+								toolinfo->Origin[0],
+								toolinfo->Origin[1],
+								toolinfo->Origin[2]);
+							Vector3* Right = new Vector3(
+								toolinfo->RightVector[0],
+								toolinfo->RightVector[1],
+								toolinfo->RightVector[2]);
+							Vector3* Up = new Vector3(
+								toolinfo->UpVector[0],
+								toolinfo->UpVector[1],
+								toolinfo->UpVector[2]);
+							Vector3* Back = new Vector3(
+								toolinfo->BackVector[0],
+								toolinfo->BackVector[1],
+								toolinfo->BackVector[2]);
+							_ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
+
+							// Tool Version
+							_ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
+							// Tool Units Per Meter
+							_ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
+							return _ArtToolInfo;
+						}
+						#pragma endregion
+
+						#pragma region MarshalToNative
+
+						#pragma region ArtToolInfo
+						void ArtToolInfo_ToNative()
+						{
+							
+							_grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName = (char*)Marshal::StringToHGlobalAnsi(_ArtToolInfo->FromArtToolName).ToPointer();
+							_grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision = _ArtToolInfo->ToolVersion->Major;
+							_grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision = _ArtToolInfo->ToolVersion->Minor;
+							_grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter = _ArtToolInfo->UnitsPerMeter;
+							
+							
+							_grn_file->GrannyFileInfo->ArtToolInfo->Origin[0] = _ArtToolInfo->Vector->Origin.x;
+							_grn_file->GrannyFileInfo->ArtToolInfo->Origin[1] = _ArtToolInfo->Vector->Origin.y;
+							_grn_file->GrannyFileInfo->ArtToolInfo->Origin[2] = _ArtToolInfo->Vector->Origin.z;
+							
+							_grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0] = _ArtToolInfo->Vector->Right.x;
+							_grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1] = _ArtToolInfo->Vector->Right.y;
+							_grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2] = _ArtToolInfo->Vector->Right.z;
+
+							_grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0] = _ArtToolInfo->Vector->Up.x;
+							_grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1] = _ArtToolInfo->Vector->Up.y;
+							_grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2] = _ArtToolInfo->Vector->Up.z;
+
+							_grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0] = _ArtToolInfo->Vector->Back.x;
+							_grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1] = _ArtToolInfo->Vector->Back.y;
+							_grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2] = _ArtToolInfo->Vector->Back.z;
+
+						}
+						#pragma endregion
+
+						#pragma endregion
+						
+						#pragma endregion
+private: System::Void mnuItemExit_Click(System::Object^  sender, System::EventArgs^  e) 
+		 {
+			 ConvertToNative();
+			 this->Close();
+		 }
+private: System::Void mnuItemOpen_Click(System::Object^  sender, System::EventArgs^  e) 
+		 {
+			_grn_file = new grannyfile("C:\\Program Files\\Granny Viewer\\Gryphon.gr2");
+			propgrid->SelectedObjects = ConvertToManaged();
+		 }
+};
+//		}
+//	}
+//}
\ No newline at end of file

 

  ViewVC Help
Powered by ViewVC 1.1.22