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

Annotation of /trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (hide annotations) (download)
Fri Jul 30 00:28:19 2010 UTC (9 years, 6 months ago) by william
File MIME type: text/plain
File size: 9925 byte(s)
bulk commit

1 william 5 #pragma once
2     #include "gr2lib_core.h"
3     #include "gr2lib_core_imports.h"
4    
5     using namespace System;
6     using namespace System::ComponentModel;
7     using namespace System::Collections;
8     using namespace System::Collections::Generic;
9     using namespace System::Windows::Forms;
10     using namespace System::Data;
11     using namespace System::Drawing;
12 william 6 using namespace System::Runtime::InteropServices;
13     //
14     //namespace gr2lib
15     //{
16     // namespace core
17     // {
18     // namespace rigeditor
19     // {
20 william 5 /// <summary>
21     /// Summary for gr2lib_rigeditor_frm
22     ///
23     /// WARNING: If you change the name of this class, you will need to change the
24     /// 'Resource File Name' property for the managed resource compiler tool
25     /// associated with all .resx files this class depends on. Otherwise,
26     /// the designers will not be able to interact properly with localized
27     /// resources associated with this form.
28     /// </summary>
29     public ref class gr2lib_rigeditor_frm : public System::Windows::Forms::Form
30     {
31 william 6 private:
32     grannyfile* _grn_file;
33 william 5 public:
34     gr2lib_rigeditor_frm(void)
35     {
36     InitializeComponent();
37     //
38     //TODO: Add the constructor code here
39     //
40     }
41     gr2lib_rigeditor_frm(grannyfile* grn_file)
42     {
43     InitializeComponent();
44     // parse art tool info
45 william 6 _grn_file = grn_file;
46     propgrid->SelectedObjects = ConvertToManaged();
47    
48 william 5 }
49    
50     protected:
51     /// <summary>
52     /// Clean up any resources being used.
53     /// </summary>
54     ~gr2lib_rigeditor_frm()
55     {
56     if (components)
57     {
58     delete components;
59     }
60     }
61     private: System::Windows::Forms::PropertyGrid^ propgrid;
62     protected:
63 william 6 private: System::Windows::Forms::MenuStrip^ mainmenu;
64     private: System::Windows::Forms::ToolStripMenuItem^ mnuFile;
65     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemExit;
66     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemOpen;
67     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSave;
68     private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSaveAs;
69 william 5
70 william 6 protected:
71    
72 william 5 private:
73     /// <summary>
74     /// Required designer variable.
75     /// </summary>
76     System::ComponentModel::Container ^components;
77    
78     #pragma region Windows Form Designer generated code
79     /// <summary>
80     /// Required method for Designer support - do not modify
81     /// the contents of this method with the code editor.
82     /// </summary>
83     void InitializeComponent(void)
84     {
85     this->propgrid = (gcnew System::Windows::Forms::PropertyGrid());
86 william 6 this->mainmenu = (gcnew System::Windows::Forms::MenuStrip());
87     this->mnuFile = (gcnew System::Windows::Forms::ToolStripMenuItem());
88     this->mnuItemExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
89     this->mnuItemOpen = (gcnew System::Windows::Forms::ToolStripMenuItem());
90     this->mnuItemSave = (gcnew System::Windows::Forms::ToolStripMenuItem());
91     this->mnuItemSaveAs = (gcnew System::Windows::Forms::ToolStripMenuItem());
92     this->mainmenu->SuspendLayout();
93 william 5 this->SuspendLayout();
94     //
95     // propgrid
96     //
97     this->propgrid->Dock = System::Windows::Forms::DockStyle::Fill;
98 william 6 this->propgrid->Location = System::Drawing::Point(0, 24);
99 william 5 this->propgrid->Name = L"propgrid";
100 william 6 this->propgrid->PropertySort = System::Windows::Forms::PropertySort::Categorized;
101     this->propgrid->Size = System::Drawing::Size(558, 456);
102     this->propgrid->TabIndex = 4;
103     this->propgrid->ToolbarVisible = false;
104 william 5 //
105 william 6 // mainmenu
106     //
107     this->mainmenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->mnuFile});
108     this->mainmenu->Location = System::Drawing::Point(0, 0);
109     this->mainmenu->Name = L"mainmenu";
110     this->mainmenu->Size = System::Drawing::Size(558, 24);
111     this->mainmenu->TabIndex = 3;
112     this->mainmenu->Text = L"menuStrip1";
113     //
114     // mnuFile
115     //
116     this->mnuFile->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->mnuItemOpen,
117     this->mnuItemSave, this->mnuItemSaveAs, this->mnuItemExit});
118     this->mnuFile->Name = L"mnuFile";
119     this->mnuFile->Size = System::Drawing::Size(37, 20);
120     this->mnuFile->Text = L"&File";
121     //
122     // mnuItemExit
123     //
124     this->mnuItemExit->Name = L"mnuItemExit";
125     this->mnuItemExit->Size = System::Drawing::Size(152, 22);
126     this->mnuItemExit->Text = L"&Exit";
127     this->mnuItemExit->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemExit_Click);
128     //
129     // mnuItemOpen
130     //
131     this->mnuItemOpen->Name = L"mnuItemOpen";
132     this->mnuItemOpen->Size = System::Drawing::Size(152, 22);
133     this->mnuItemOpen->Text = L"&Open";
134     this->mnuItemOpen->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemOpen_Click);
135     //
136     // mnuItemSave
137     //
138     this->mnuItemSave->Name = L"mnuItemSave";
139     this->mnuItemSave->Size = System::Drawing::Size(152, 22);
140     this->mnuItemSave->Text = L"&Save";
141     //
142     // mnuItemSaveAs
143     //
144     this->mnuItemSaveAs->Name = L"mnuItemSaveAs";
145     this->mnuItemSaveAs->Size = System::Drawing::Size(152, 22);
146     this->mnuItemSaveAs->Text = L"Save &As";
147     //
148 william 5 // gr2lib_rigeditor_frm
149     //
150     this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
151     this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
152 william 6 this->ClientSize = System::Drawing::Size(558, 480);
153 william 5 this->Controls->Add(this->propgrid);
154 william 6 this->Controls->Add(this->mainmenu);
155 william 5 this->Name = L"gr2lib_rigeditor_frm";
156     this->Text = L"gr2lib_rigeditor_frm";
157 william 6 this->mainmenu->ResumeLayout(false);
158     this->mainmenu->PerformLayout();
159 william 5 this->ResumeLayout(false);
160 william 6 this->PerformLayout();
161 william 5
162     }
163     #pragma endregion
164 william 6 #pragma region MarshalToMananaged
165     ArtToolInfo^ _ArtToolInfo;
166    
167     #pragma region ManagedNativeParsing
168     array<Object^>^ ConvertToManaged()
169     {
170     List<Object^> ret = gcnew List<Object^>();
171    
172     // Art Tool info
173     ret.Add(ArtToolInfo_ToManaged(_grn_file->GrannyFileInfo->ArtToolInfo));
174    
175     return ret.ToArray();
176     }
177     void ConvertToNative()
178     {
179     // Art Tool info
180     ArtToolInfo_ToNative();
181     }
182     #pragma endregion
183    
184     #pragma region ArtToolInfo
185     ArtToolInfo^ ArtToolInfo_ToManaged(granny_art_tool_info* toolinfo)
186     {
187     _ArtToolInfo = gcnew ArtToolInfo();
188     // Tool Name
189     _ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(toolinfo->FromArtToolName));
190    
191     // Tool Vector
192     Vector3* Origin = new Vector3(
193     toolinfo->Origin[0],
194     toolinfo->Origin[1],
195     toolinfo->Origin[2]);
196     Vector3* Right = new Vector3(
197     toolinfo->RightVector[0],
198     toolinfo->RightVector[1],
199     toolinfo->RightVector[2]);
200     Vector3* Up = new Vector3(
201     toolinfo->UpVector[0],
202     toolinfo->UpVector[1],
203     toolinfo->UpVector[2]);
204     Vector3* Back = new Vector3(
205     toolinfo->BackVector[0],
206     toolinfo->BackVector[1],
207     toolinfo->BackVector[2]);
208     _ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
209    
210     // Tool Version
211     _ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
212     // Tool Units Per Meter
213     _ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
214     return _ArtToolInfo;
215     }
216     #pragma endregion
217    
218     #pragma region MarshalToNative
219    
220     #pragma region ArtToolInfo
221     void ArtToolInfo_ToNative()
222     {
223    
224     _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName = (char*)Marshal::StringToHGlobalAnsi(_ArtToolInfo->FromArtToolName).ToPointer();
225     _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision = _ArtToolInfo->ToolVersion->Major;
226     _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision = _ArtToolInfo->ToolVersion->Minor;
227     _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter = _ArtToolInfo->UnitsPerMeter;
228    
229    
230     _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0] = _ArtToolInfo->Vector->Origin.x;
231     _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1] = _ArtToolInfo->Vector->Origin.y;
232     _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2] = _ArtToolInfo->Vector->Origin.z;
233    
234     _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0] = _ArtToolInfo->Vector->Right.x;
235     _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1] = _ArtToolInfo->Vector->Right.y;
236     _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2] = _ArtToolInfo->Vector->Right.z;
237    
238     _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0] = _ArtToolInfo->Vector->Up.x;
239     _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1] = _ArtToolInfo->Vector->Up.y;
240     _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2] = _ArtToolInfo->Vector->Up.z;
241    
242     _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0] = _ArtToolInfo->Vector->Back.x;
243     _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1] = _ArtToolInfo->Vector->Back.y;
244     _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2] = _ArtToolInfo->Vector->Back.z;
245    
246     }
247     #pragma endregion
248    
249     #pragma endregion
250    
251     #pragma endregion
252     private: System::Void mnuItemExit_Click(System::Object^ sender, System::EventArgs^ e)
253     {
254     ConvertToNative();
255     this->Close();
256     }
257     private: System::Void mnuItemOpen_Click(System::Object^ sender, System::EventArgs^ e)
258     {
259     _grn_file = new grannyfile("C:\\Program Files\\Granny Viewer\\Gryphon.gr2");
260     propgrid->SelectedObjects = ConvertToManaged();
261     }
262     };
263     // }
264     // }
265     //}

  ViewVC Help
Powered by ViewVC 1.1.22