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

Contents of /trunk/gr2lib_cpp/gr2lib_rigeditor_frm.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69 - (show annotations) (download)
Fri Aug 13 17:15:09 2010 UTC (9 years, 6 months ago) by william
File MIME type: text/plain
File size: 39879 byte(s)
Implement support for:
** editing Materials
** editing ExtendedData

1 #define _CRT_SECURE_NO_WARNINGS
2 #pragma warning( disable : 4100 ) // disable 'unreferenced formal parameter' warnings
3 #pragma warning( disable : 4101 ) // disable 'unreferenced local variable' warnings
4
5 #define SHOW_DEBUG_MENU // if defined, will show the debug menu -> else it will not be shown
6
7 #define granny_pixel_layout_bitshift_size 4
8
9 #pragma once
10 //#include "gr2lib_core.h"
11 //#include "gr2lib_core_imports.h"
12 #ifndef GR2LIB_RIGEDITOR_FRM_H
13 #define GR2LIB_RIGEDITOR_FRM_H
14 #include "..\gr2lib_cpp_typedefs\core.h"
15 #include "grannyfile.h"
16 //#include "guicon.h"
17 #include "VSDebugOutput.h"
18 #include "GrannyFileWriter.h"
19 #include <stdio.h>
20 #include <iostream>
21 #include <stdlib.h>
22 #include <assert.h>
23 #include <string>
24 #include <sstream>
25 #include <vcclr.h>
26 using namespace std;
27
28 using namespace gr2lib_cpp::typedefs;
29 using namespace gr2lib::core;
30 using namespace gr2lib::core::coretypes::implementation;
31 using namespace gr2lib::core::apiversion;
32 using namespace gr2lib::core::ui::helpers;
33 using namespace gr2lib::core::helpers;
34 using namespace System;
35 using namespace System::ComponentModel;
36 using namespace System::Collections;
37 using namespace System::Collections::Generic;
38 using namespace System::Windows::Forms;
39 using namespace System::Data;
40 using namespace System::Drawing;
41 using namespace System::Runtime::InteropServices;
42 //using namespace Microsoft::Xna::Framework;
43 //using namespace Microsoft::Xna::Framework::Graphics;
44 //
45 //namespace gr2lib
46 //{
47 // namespace core
48 // {
49 // namespace rigeditor
50 // {
51 /// <summary>
52 /// Summary for gr2lib_rigeditor_frm
53 ///
54 /// WARNING: If you change the name of this class, you will need to change the
55 /// 'Resource File Name' property for the managed resource compiler tool
56 /// associated with all .resx files this class depends on. Otherwise,
57 /// the designers will not be able to interact properly with localized
58 /// resources associated with this form.
59 /// </summary>
60 public ref class gr2lib_rigeditor_frm : public System::Windows::Forms::Form
61 {
62 private:
63 grannyfile* _grn_file;
64 void LogApplicationStartup()
65 {
66 const char* ApplicationName = "GR2Lib Rig Editor: ";
67
68 const char* product_version = (char*)(void*)Marshal::StringToHGlobalAnsi(Application::ProductVersion);
69 const char* version_prefix = "v";
70 const char* startup_string = " {Starting up...}";
71
72
73 int msg_malloc = (strlen(ApplicationName) + strlen(product_version) + strlen(version_prefix) + strlen(startup_string)) + 3;
74
75 char* msg = (char*)malloc(msg_malloc);
76 for (int i=0; i<msg_malloc; i++) {
77 msg[i] = 0; // Initialize all elements to zero.
78 }
79
80 strcat(msg,ApplicationName);
81 strcat(msg,version_prefix);
82 strcat(msg,product_version);
83 strcat(msg,startup_string);
84 strcat(msg,"\n");
85 _grn_file->_logger->LogMessage(msg);
86 }
87 public:
88 gr2lib_rigeditor_frm(void)
89 {
90 InitializeComponent();
91 _grn_file = new grannyfile();
92 //
93 //TODO: Add the constructor code here
94 //
95 // Log Application Startup
96 LogApplicationStartup();
97 }
98 gr2lib_rigeditor_frm(grannyfile* grn_file)
99 {
100 InitializeComponent();
101 // parse art tool info
102 _grn_file = grn_file;
103
104 // Log Application Startup
105 LogApplicationStartup();
106
107 this->GR2LibPropertyWrapper = gcnew GR2LibWrapper();
108 ConvertToManaged();
109 propgrid->SelectedObject = this->GR2LibPropertyWrapper;
110
111 }
112
113 protected:
114 /// <summary>
115 /// Clean up any resources being used.
116 /// </summary>
117 ~gr2lib_rigeditor_frm()
118 {
119 if (components)
120 {
121 delete components;
122 }
123 }
124 private: System::Windows::Forms::PropertyGrid^ propgrid;
125 protected:
126 private: System::Windows::Forms::MenuStrip^ mainmenu;
127 private: System::Windows::Forms::ToolStripMenuItem^ mnuFile;
128 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemExit;
129 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemOpen;
130 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSave;
131 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemSaveAs;
132 private: System::Windows::Forms::ToolStripMenuItem^ mnuDebug;
133 private: System::Windows::Forms::ToolStripMenuItem^ mnuDebug_UnitTests;
134 private: System::Windows::Forms::ToolStripMenuItem^ mnuTestArtToolInfoReturnValues;
135
136 private: System::Windows::Forms::OpenFileDialog^ RigLoader;
137 private: System::Windows::Forms::ToolStripMenuItem^ mnuTestExporterInfoReturnValues;
138 private: System::Windows::Forms::SaveFileDialog^ RigSaver;
139 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemClose;
140 private: System::Windows::Forms::ToolStripMenuItem^ mnuItemTestDDSRender;
141
142
143
144
145
146 protected:
147
148 private:
149 /// <summary>
150 /// Required designer variable.
151 /// </summary>
152 System::ComponentModel::Container ^components;
153
154 #pragma region Windows Form Designer generated code
155 /// <summary>
156 /// Required method for Designer support - do not modify
157 /// the contents of this method with the code editor.
158 /// </summary>
159 void InitializeComponent(void)
160 {
161 this->propgrid = (gcnew System::Windows::Forms::PropertyGrid());
162 this->mainmenu = (gcnew System::Windows::Forms::MenuStrip());
163 this->mnuFile = (gcnew System::Windows::Forms::ToolStripMenuItem());
164 this->mnuItemOpen = (gcnew System::Windows::Forms::ToolStripMenuItem());
165 this->mnuItemClose = (gcnew System::Windows::Forms::ToolStripMenuItem());
166 this->mnuItemSave = (gcnew System::Windows::Forms::ToolStripMenuItem());
167 this->mnuItemSaveAs = (gcnew System::Windows::Forms::ToolStripMenuItem());
168 this->mnuItemExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
169 this->mnuDebug = (gcnew System::Windows::Forms::ToolStripMenuItem());
170 this->mnuDebug_UnitTests = (gcnew System::Windows::Forms::ToolStripMenuItem());
171 this->mnuTestArtToolInfoReturnValues = (gcnew System::Windows::Forms::ToolStripMenuItem());
172 this->mnuTestExporterInfoReturnValues = (gcnew System::Windows::Forms::ToolStripMenuItem());
173 this->mnuItemTestDDSRender = (gcnew System::Windows::Forms::ToolStripMenuItem());
174 this->RigLoader = (gcnew System::Windows::Forms::OpenFileDialog());
175 this->RigSaver = (gcnew System::Windows::Forms::SaveFileDialog());
176 this->mainmenu->SuspendLayout();
177 this->SuspendLayout();
178 //
179 // propgrid
180 //
181 this->propgrid->Dock = System::Windows::Forms::DockStyle::Fill;
182 this->propgrid->Location = System::Drawing::Point(0, 24);
183 this->propgrid->Name = L"propgrid";
184 this->propgrid->PropertySort = System::Windows::Forms::PropertySort::Categorized;
185 this->propgrid->Size = System::Drawing::Size(558, 456);
186 this->propgrid->TabIndex = 4;
187 this->propgrid->ToolbarVisible = false;
188 //
189 // mainmenu
190 //
191 this->mainmenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuFile, this->mnuDebug});
192 this->mainmenu->Location = System::Drawing::Point(0, 0);
193 this->mainmenu->Name = L"mainmenu";
194 this->mainmenu->Size = System::Drawing::Size(558, 24);
195 this->mainmenu->TabIndex = 3;
196 this->mainmenu->Text = L"menuStrip1";
197 //
198 // mnuFile
199 //
200 this->mnuFile->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {this->mnuItemOpen,
201 this->mnuItemClose, this->mnuItemSave, this->mnuItemSaveAs, this->mnuItemExit});
202 this->mnuFile->Name = L"mnuFile";
203 this->mnuFile->Size = System::Drawing::Size(37, 20);
204 this->mnuFile->Text = L"&File";
205 //
206 // mnuItemOpen
207 //
208 this->mnuItemOpen->Name = L"mnuItemOpen";
209 this->mnuItemOpen->Size = System::Drawing::Size(114, 22);
210 this->mnuItemOpen->Text = L"&Open";
211 this->mnuItemOpen->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemOpen_Click);
212 //
213 // mnuItemClose
214 //
215 this->mnuItemClose->Name = L"mnuItemClose";
216 this->mnuItemClose->Size = System::Drawing::Size(114, 22);
217 this->mnuItemClose->Text = L"&Close";
218 this->mnuItemClose->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemClose_Click);
219 //
220 // mnuItemSave
221 //
222 this->mnuItemSave->Name = L"mnuItemSave";
223 this->mnuItemSave->Size = System::Drawing::Size(114, 22);
224 this->mnuItemSave->Text = L"&Save";
225 this->mnuItemSave->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemSave_Click);
226 //
227 // mnuItemSaveAs
228 //
229 this->mnuItemSaveAs->Name = L"mnuItemSaveAs";
230 this->mnuItemSaveAs->Size = System::Drawing::Size(114, 22);
231 this->mnuItemSaveAs->Text = L"Save &As";
232 this->mnuItemSaveAs->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemSaveAs_Click);
233 //
234 // mnuItemExit
235 //
236 this->mnuItemExit->Name = L"mnuItemExit";
237 this->mnuItemExit->Size = System::Drawing::Size(114, 22);
238 this->mnuItemExit->Text = L"&Exit";
239 this->mnuItemExit->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuItemExit_Click);
240 //
241 // mnuDebug
242 //
243 this->mnuDebug->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuDebug_UnitTests,
244 this->mnuItemTestDDSRender});
245 this->mnuDebug->Name = L"mnuDebug";
246 this->mnuDebug->Size = System::Drawing::Size(56, 20);
247 this->mnuDebug->Text = L"&DEBUG";
248 //
249 // mnuDebug_UnitTests
250 //
251 this->mnuDebug_UnitTests->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuTestArtToolInfoReturnValues,
252 this->mnuTestExporterInfoReturnValues});
253 this->mnuDebug_UnitTests->Name = L"mnuDebug_UnitTests";
254 this->mnuDebug_UnitTests->Size = System::Drawing::Size(161, 22);
255 this->mnuDebug_UnitTests->Text = L"&Unit Tests...";
256 //
257 // mnuTestArtToolInfoReturnValues
258 //
259 this->mnuTestArtToolInfoReturnValues->Name = L"mnuTestArtToolInfoReturnValues";
260 this->mnuTestArtToolInfoReturnValues->Size = System::Drawing::Size(238, 22);
261 this->mnuTestArtToolInfoReturnValues->Text = L"Test ArtoolInfo Rerturn values";
262 this->mnuTestArtToolInfoReturnValues->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuTestArtToolInfoReturnValues_Click);
263 //
264 // mnuTestExporterInfoReturnValues
265 //
266 this->mnuTestExporterInfoReturnValues->Name = L"mnuTestExporterInfoReturnValues";
267 this->mnuTestExporterInfoReturnValues->Size = System::Drawing::Size(238, 22);
268 this->mnuTestExporterInfoReturnValues->Text = L"Test ExporterInfo Return Values";
269 this->mnuTestExporterInfoReturnValues->Click += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::mnuTestExporterInfoReturnValues_Click);
270 //
271 // mnuItemTestDDSRender
272 //
273 this->mnuItemTestDDSRender->Name = L"mnuItemTestDDSRender";
274 this->mnuItemTestDDSRender->Size = System::Drawing::Size(161, 22);
275 this->mnuItemTestDDSRender->Text = L"Test DDS Render";
276 //
277 // RigLoader
278 //
279 this->RigLoader->DefaultExt = L"gr2";
280 this->RigLoader->Filter = L"Granny2 Files|*.gr2;*.grannyrig";
281 this->RigLoader->SupportMultiDottedExtensions = true;
282 this->RigLoader->Title = L"Please choose the Granny2 Rig file to load";
283 //
284 // RigSaver
285 //
286 this->RigSaver->DefaultExt = L"gr2";
287 this->RigSaver->Filter = L"Granny2 Files|*.gr2;*.grannyrig";
288 this->RigSaver->SupportMultiDottedExtensions = true;
289 this->RigSaver->Title = L"Please select the Granny2 Rig to write to or create";
290 //
291 // gr2lib_rigeditor_frm
292 //
293 this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
294 this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
295 this->ClientSize = System::Drawing::Size(558, 480);
296 this->Controls->Add(this->propgrid);
297 this->Controls->Add(this->mainmenu);
298 this->Name = L"gr2lib_rigeditor_frm";
299 this->Text = L"gr2lib_rigeditor_frm";
300 this->Load += gcnew System::EventHandler(this, &gr2lib_rigeditor_frm::gr2lib_rigeditor_frm_Load);
301 this->FormClosed += gcnew System::Windows::Forms::FormClosedEventHandler(this, &gr2lib_rigeditor_frm::gr2lib_rigeditor_frm_FormClosed);
302 this->mainmenu->ResumeLayout(false);
303 this->mainmenu->PerformLayout();
304 this->ResumeLayout(false);
305 this->PerformLayout();
306
307 }
308 #pragma endregion
309
310 #pragma region MarshalToMananaged
311 //ArtToolInfo^ _ArtToolInfo;
312 //ExporterInfo^ _ExporterInfo;
313 GR2LibWrapper^ GR2LibPropertyWrapper;
314
315 #pragma region ManagedNativeParsing
316 void ConvertToManaged()
317 {
318 // Art Tool info
319 ArtToolInfo_ToManaged(_grn_file->GrannyFileInfo->ArtToolInfo);
320 // Exporter Info
321 ExporterInfo_ToManaged(_grn_file->GrannyFileInfo->ExporterInfo);
322 // Texture List
323 Textures_ToManaged(_grn_file->GrannyFileInfo->Textures,_grn_file->GrannyFileInfo->TextureCount);
324 // Material List
325 Materials_ToManaged(_grn_file->GrannyFileInfo->Materials,_grn_file->GrannyFileInfo->MaterialCount);
326 }
327 void ConvertToNative()
328 {
329 // Art Tool info
330 ArtToolInfo_ToNative();
331 // Exporter Info
332 ExporterInfo_ToNative();
333 // Texture List
334 Textures_ToNative();
335 // Material List
336 Materials_ToNative();
337 }
338 #pragma endregion
339
340 #pragma region ArtToolInfo_ToManaged
341 void ArtToolInfo_ToManaged(granny_art_tool_info* toolinfo)
342 {
343 //GR2LibPropertyWrapper->ArtToolInfo = gcnew ArtToolInfo();
344 if (toolinfo != NULL)
345 {
346 GR2LibPropertyWrapper->ArtToolInfo->FromArtToolName = gcnew String(reinterpret_cast<const char*>(toolinfo->FromArtToolName));
347
348 // Tool Vector
349 Vector3* Origin = new Vector3(
350 toolinfo->Origin[0],
351 toolinfo->Origin[1],
352 toolinfo->Origin[2]);
353 Vector3* Right = new Vector3(
354 toolinfo->RightVector[0],
355 toolinfo->RightVector[1],
356 toolinfo->RightVector[2]);
357 Vector3* Up = new Vector3(
358 toolinfo->UpVector[0],
359 toolinfo->UpVector[1],
360 toolinfo->UpVector[2]);
361 Vector3* Back = new Vector3(
362 toolinfo->BackVector[0],
363 toolinfo->BackVector[1],
364 toolinfo->BackVector[2]);
365 GR2LibPropertyWrapper->ArtToolInfo->Vector = gcnew ArtToolInfoVector(*Origin,*Right,*Up,*Back);
366
367 // Tool Version
368 GR2LibPropertyWrapper->ArtToolInfo->ToolVersion = gcnew ArtToolInfoVersion(toolinfo->ArtToolMajorRevision,toolinfo->ArtToolMinorRevision);
369 // Tool Units Per Meter
370 GR2LibPropertyWrapper->ArtToolInfo->UnitsPerMeter = toolinfo->UnitsPerMeter;
371 }
372 }
373 #pragma endregion
374 #pragma region ExporterInfo_ToManaged
375 void ExporterInfo_ToManaged(granny_exporter_info* toolinfo)
376 {
377 //GR2LibPropertyWrapper->ExporterInfo = gcnew ExporterInfo();
378 if (toolinfo != NULL)
379 {
380 GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
381 GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
382 toolinfo->ExporterMajorRevision,
383 toolinfo->ExporterMinorRevision,
384 toolinfo->ExporterCustomization,
385 toolinfo->ExporterBuildNumber);
386 }
387 //_ExporterInfo->ExtendedData = new IntPtr(toolinfo->ExtendedData.Object);
388 }
389 #pragma endregion
390 #pragma region Textures_ToManaged
391 void Textures_ToManaged(granny_texture** toolinfo, granny_int32 TextureCount)
392 {
393 if (toolinfo != NULL)
394 {
395 /*GR2LibPropertyWrapper->ExporterInfo->ExporterName = gcnew String(reinterpret_cast<const char*>(toolinfo->ExporterName));
396 GR2LibPropertyWrapper->ExporterInfo->Version = gcnew versiontype(
397 toolinfo->ExporterMajorRevision,
398 toolinfo->ExporterMinorRevision,
399 toolinfo->ExporterCustomization,
400 toolinfo->ExporterBuildNumber);*/
401 GR2LibPropertyWrapper->Textures = gcnew List<Texture^>();
402 for(int i=0;i<TextureCount;i++)
403 {
404 Texture^ t = gcnew Texture();
405
406 t->FromFileName = gcnew FilePath(gcnew String(reinterpret_cast<const char*>(toolinfo[i]->FromFileName)));
407 t->TextureType = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_texture_type>(
408 ::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_texture_type>(
409 (gr2lib::core::typedefs::granny_texture_type)toolinfo[i]->TextureType),
410 (gr2lib::core::typedefs::granny_texture_type)toolinfo[i]->TextureType);
411 t->Width = toolinfo[i]->Width;
412 t->Height = toolinfo[i]->Height;
413 t->Encoding = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_texture_encoding>(
414 ::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_texture_encoding>(
415 (gr2lib::core::typedefs::granny_texture_encoding)toolinfo[i]->Encoding),
416 (gr2lib::core::typedefs::granny_texture_encoding)toolinfo[i]->Encoding);
417 t->SubFormat = gcnew NameValuePair<String^,gr2lib::core::typedefs::granny_pixel_layout>(
418 ::coreapi::EnumToStringSupport::GetGrannyEnumTypeString<gr2lib::core::typedefs::granny_pixel_layout>(
419 (gr2lib::core::typedefs::granny_pixel_layout)toolinfo[i]->SubFormat),
420 (gr2lib::core::typedefs::granny_pixel_layout)toolinfo[i]->SubFormat);
421 t->Layout = gcnew gr2lib::core::coretypes::implementation::Layout();
422 t->Layout->BytesPerPixel = toolinfo[i]->Layout.BytesPerPixel;
423 for(int j=0;j<granny_pixel_layout_bitshift_size;j++)
424 {
425 t->Layout->ShiftForComponent[j] = toolinfo[i]->Layout.ShiftForComponent[j];
426 t->Layout->BitsForComponent[j] = toolinfo[i]->Layout.BitsForComponent[j];
427 }
428 t->Layout->NativePointer = *new IntPtr(&toolinfo[i]->Layout);
429
430 t->Images = gcnew List<gr2lib::core::coretypes::implementation::Image^>();
431 for(int j=0;j<toolinfo[i]->ImageCount;j++)
432 {
433 gr2lib::core::coretypes::implementation::Image^ img = gcnew gr2lib::core::coretypes::implementation::Image();
434 img->MIPLevels = gcnew List<gr2lib::core::coretypes::implementation::MIPLevel^>();
435
436 for(int k=0;k<toolinfo[i]->Images[j].MIPLevelCount;k++)
437 {
438 gr2lib::core::coretypes::implementation::MIPLevel^ mip = gcnew gr2lib::core::coretypes::implementation::MIPLevel();
439 mip->Stride = toolinfo[i]->Images[j].MIPLevels[k].Stride;
440 mip->Pixels = gcnew gr2lib::core::coretypes::implementation::Pixel();
441
442 unsigned char* bytes = (unsigned char*)malloc(toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount);
443 for(int l =0;l<toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
444 {
445 bytes[l] =0;
446 }
447 bytes = (unsigned char*)toolinfo[i]->Images[j].MIPLevels[k].PixelBytes;
448
449 mip->Pixels->NativeTexture = t;
450 mip->Pixels->NativeTexturePointer = *new IntPtr(toolinfo[i]);
451 mip->Pixels->ImageIndex = j;
452 mip->Pixels->MipIndex = k;
453
454 for(int l =0;l<toolinfo[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
455 {
456 mip->Pixels->PixelBytes->Add(bytes[l]);
457 }
458 img->MIPLevels->Add(mip);
459
460 }
461 t->Images->Add(img);
462 t->NativePointer = *new IntPtr(toolinfo[i]);
463 }
464 GR2LibPropertyWrapper->Textures->Add(t);
465 }
466 }
467 }
468 #pragma endregion
469 #pragma region Materials_ToManaged
470 void Materials_ToManaged(granny_material** toolinfo, granny_int32 MaterialCount)
471 {
472 if (toolinfo != NULL)
473 {
474 GR2LibPropertyWrapper->Materials = gcnew List<Material^>();
475 for(int i=0;i<MaterialCount;i++)
476 {
477 Material^ m = gcnew Material();
478 if (toolinfo[i]->Texture != NULL)
479 {
480 m = gcnew Material(*new IntPtr(&toolinfo[i]->Texture));
481 }
482
483 m->Name = gcnew String(reinterpret_cast<const char*>(toolinfo[i]->Name));
484 /*m->Maps = gcnew List<Map^>(toolinfo[i]->MapCount);
485 for(int j=0;j<toolinfo[i]->MapCount;j++)
486 {
487 Map^ map = gcnew Map();
488
489 if(toolinfo[i]->Maps[j].Material != NULL)
490 {
491 map = gcnew Map(*new IntPtr(&toolinfo[i]->Maps[j].Material));
492 }
493
494 map->Usage = gcnew String(reinterpret_cast<const char*>(toolinfo[i]->Maps[j].Usage));
495 map->NativePointer = *new IntPtr(&toolinfo[i]->Maps[j]);
496 m->Maps->Add(map);
497 }*/
498
499 /*if (toolinfo[i]->Texture != NULL)
500 {
501 m->TexturePointer = *new IntPtr(&toolinfo[i]->Texture);
502 }
503 else
504 {
505 m->TexturePointer = IntPtr::Zero;
506 }*/
507
508
509 ExtendedDataWrapper* ExtendedDataWrapped = new ExtendedDataWrapper(toolinfo[i]->ExtendedData, _grn_file->_logger);
510 List<ExtendedDataMemberStruct^>^ _ExtendedDataMember = gcnew List<ExtendedDataMemberStruct^>(ExtendedDataWrapped->MemberCount);
511
512 for (int j=0;j<ExtendedDataWrapped->MemberCount;j++)
513 {
514 ExtendedDataMemberStruct^ _ExtendedDataMemberStruct = gcnew ExtendedDataMemberStruct();
515
516 _ExtendedDataMemberStruct->Index = ExtendedDataWrapped->ExtendedDataMembers[j].Index;
517 _ExtendedDataMemberStruct->Name = gcnew String(reinterpret_cast<const char*>(ExtendedDataWrapped->ExtendedDataMembers[j].Name.c_str()));
518 _ExtendedDataMemberStruct->Type = (gr2lib::core::typedefs::granny_member_type)(int)ExtendedDataWrapped->ExtendedDataMembers[j].Type;
519 _ExtendedDataMemberStruct->Value = ExtendedDataWrapped->GetRealExtendedDataMemberValue(_ExtendedDataMemberStruct->Index);
520 _ExtendedDataMember->Add(_ExtendedDataMemberStruct);
521 }
522
523 m->ExtendedData = gcnew GrannyExtendedData(_ExtendedDataMember);
524
525 ////System::Diagnostics::Debug::WriteLine("Granny Member Type: " + reinterpret_cast<int>(toolinfo[i]->ExtendedData.Type->Type));
526 //System::Diagnostics::Debug::WriteLine("Namee: " + gcnew String(reinterpret_cast<const char*>(toolinfo[i]->ExtendedData.Type->Name)));
527
528 m->NativePointer = *new IntPtr(toolinfo[i]);
529 GR2LibPropertyWrapper->Materials->Add(m);
530 }
531 }
532 }
533 #pragma endregion
534
535 #pragma region MarshalToNative
536
537 #pragma region ArtToolInfo_ToNative
538 void ArtToolInfo_ToNative()
539 {
540 if (_grn_file->GrannyFileInfo->ArtToolInfo == NULL)
541 {
542 _grn_file->GrannyFileInfo->ArtToolInfo = new granny_art_tool_info();
543 }
544
545 _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ArtToolInfo->FromArtToolName).ToPointer();
546 _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision = GR2LibPropertyWrapper->ArtToolInfo->ToolVersion->Major;
547 _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision = GR2LibPropertyWrapper->ArtToolInfo->ToolVersion->Minor;
548 _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter = GR2LibPropertyWrapper->ArtToolInfo->UnitsPerMeter;
549
550
551 _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Origin.x;
552 _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Origin.y;
553 _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Origin.z;
554
555 _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Right.x;
556 _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Right.y;
557 _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Right.z;
558
559 _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Up.x;
560 _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Up.y;
561 _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Up.z;
562
563 _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.x;
564 _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.y;
565 _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2] = GR2LibPropertyWrapper->ArtToolInfo->Vector->Back.z;
566
567 }
568 #pragma endregion
569 #pragma region ExporterInfo_ToNative
570 void ExporterInfo_ToNative()
571 {
572 if (_grn_file->GrannyFileInfo->ExporterInfo == NULL)
573 {
574 _grn_file->GrannyFileInfo->ExporterInfo = new granny_exporter_info();
575 }
576 _grn_file->GrannyFileInfo->ExporterInfo->ExporterName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->ExporterInfo->ExporterName).ToPointer();
577 _grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->major;
578 _grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision = GR2LibPropertyWrapper->ExporterInfo->Version->minor;
579 _grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization = GR2LibPropertyWrapper->ExporterInfo->Version->customization;
580 _grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber = GR2LibPropertyWrapper->ExporterInfo->Version->build;
581 //_grn_file->GrannyFileInfo->ExporterInfo->ExtendedData
582 }
583 #pragma endregion
584 #pragma region Textures_ToNative
585 void Textures_ToNative()
586 {
587 //_grn_file->GrannyFileInfo->Textures = (granny_texture**)malloc(GR2LibPropertyWrapper->Textures->Count);
588 //for(int i=0;i<GR2LibPropertyWrapper->Textures->Count;i++) { _grn_file->GrannyFileInfo->Textures[i] = new granny_texture(); }
589
590 _grn_file->GrannyFileInfo->TextureCount = GR2LibPropertyWrapper->Textures->Count;
591 for(int i=0;i<_grn_file->GrannyFileInfo->TextureCount;i++)
592 {
593 _grn_file->GrannyFileInfo->Textures[i]->FromFileName = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->Textures[i]->FromFileName->FullPath).ToPointer();
594 _grn_file->GrannyFileInfo->Textures[i]->TextureType = (granny_int32)GR2LibPropertyWrapper->Textures[i]->TextureType->Value;
595 _grn_file->GrannyFileInfo->Textures[i]->Width = GR2LibPropertyWrapper->Textures[i]->Width;
596 _grn_file->GrannyFileInfo->Textures[i]->Height = GR2LibPropertyWrapper->Textures[i]->Height;
597 _grn_file->GrannyFileInfo->Textures[i]->Encoding = (granny_int32)GR2LibPropertyWrapper->Textures[i]->Encoding->Value;
598 _grn_file->GrannyFileInfo->Textures[i]->SubFormat = (granny_int32)GR2LibPropertyWrapper->Textures[i]->SubFormat->Value;
599
600 _grn_file->GrannyFileInfo->Textures[i]->Layout.BytesPerPixel = (granny_int32)GR2LibPropertyWrapper->Textures[i]->Layout->BytesPerPixel;
601 for(int j=0;j<granny_pixel_layout_bitshift_size;j++)
602 {
603 _grn_file->GrannyFileInfo->Textures[i]->Layout.ShiftForComponent[j] = GR2LibPropertyWrapper->Textures[i]->Layout->ShiftForComponent[j];
604 _grn_file->GrannyFileInfo->Textures[i]->Layout.BitsForComponent[j] = GR2LibPropertyWrapper->Textures[i]->Layout->BitsForComponent[j];
605 }
606
607 _grn_file->GrannyFileInfo->Textures[i]->ImageCount = GR2LibPropertyWrapper->Textures[i]->Images->Count;
608 _grn_file->GrannyFileInfo->Textures[i]->Images = (granny_texture_image*)malloc(_grn_file->GrannyFileInfo->Textures[i]->ImageCount);
609 for(int j=0;j<_grn_file->GrannyFileInfo->Textures[i]->ImageCount;j++)
610 {
611 _grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevelCount = GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels->Count;
612 _grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels = (granny_texture_mip_level*)malloc(_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevelCount);
613 for(int k=0;k<_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevelCount;k++)
614 {
615 _grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].Stride = GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels[k]->Stride;
616 _grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount = GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels[k]->Pixels->PixelBytes->Count;
617 _grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelBytes = (unsigned char*)malloc(_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount);
618
619
620 for (int l=0;l<_grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelByteCount;l++)
621 {
622 _grn_file->GrannyFileInfo->Textures[i]->Images[j].MIPLevels[k].PixelBytes[l] = GR2LibPropertyWrapper->Textures[i]->Images[j]->MIPLevels[k]->Pixels->PixelBytes[l];
623 }
624 }
625 }
626 _grn_file->GrannyFileInfo->Textures[i]->ExtendedData = *(new granny_variant());
627 }
628
629 }
630 #pragma endregion
631 #pragma region Materials_ToNative
632 void Materials_ToNative()
633 {
634 _grn_file->GrannyFileInfo->MaterialCount = GR2LibPropertyWrapper->Materials->Count;
635 for(int i=0;i<_grn_file->GrannyFileInfo->MaterialCount;i++)
636 {
637 _grn_file->GrannyFileInfo->Materials[i]->Name = (char*)Marshal::StringToHGlobalAnsi(GR2LibPropertyWrapper->Materials[i]->Name).ToPointer();
638
639 // update extended data
640 ExtendedDataWrapper* ExtendedDataWrapped = new ExtendedDataWrapper(_grn_file->GrannyFileInfo->Materials[i]->ExtendedData, _grn_file->_logger);
641 int MemberCount = GR2LibPropertyWrapper->Materials[i]->ExtendedData->ExtendedData->Count;
642 for(int j=0;j<MemberCount;j++)
643 {
644 Object^ value = GR2LibPropertyWrapper->Materials[i]->ExtendedData->ExtendedData[j]->Value;
645
646 if (value->ToString() == (gcnew Object())->ToString()) continue;
647
648
649 int MemberType = ExtendedDataWrapped->ExtendedDataMembers[j].Type;
650 switch(ExtendedDataWrapped->ExtendedDataMembers[j].Type)
651 {
652 // //case granny_member_type::GrannyEndMember: return new void*(); break;
653 // //case granny_member_type::GrannyInlineMember: return new void*(); break;
654 // //case granny_member_type::GrannyReferenceMember: return new void*(); break;
655 // //case granny_member_type::GrannyReferenceToArrayMember: return new void*();break;
656 // //case granny_member_type::GrannyArrayOfReferencesMember: return new void*(); break;
657 // //case granny_member_type::GrannyVariantReferenceMember: return new void*(); break;
658 // //case granny_member_type::GrannyUnsupportedMemberType_Remove: return new void*(); break;
659 // //case granny_member_type::GrannyReferenceToVariantArrayMember: return new void*(); break;
660 case granny_member_type::GrannyStringMember:
661 char* _string;
662 _string = (char*)Marshal::StringToHGlobalAnsi((System::String^)value).ToPointer();
663 ((char*(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = _string;
664 break;
665 //case granny_member_type::GrannyTransformMember: return new void*();break;
666 case granny_member_type::GrannyReal32Member:
667 ((granny_real32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_real32)value; break;
668 case granny_member_type::GrannyInt8Member:
669 ((granny_int8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int8)value; break;
670 case granny_member_type::GrannyUInt8Member:
671 ((granny_uint8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] =(granny_uint8)value; break;
672 case granny_member_type::GrannyBinormalInt8Member:
673 ((granny_int8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int8)value; break;
674 case granny_member_type::GrannyNormalUInt8Member:
675 ((granny_uint8(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint8)value; break;
676 case granny_member_type::GrannyInt16Member:
677 ((granny_int16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int16)value; break;
678 case granny_member_type::GrannyUInt16Member:
679 ((granny_uint16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint16)value; break;
680 case granny_member_type::GrannyBinormalInt16Member:
681 ((granny_int16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int16)value; break;
682 case granny_member_type::GrannyNormalUInt16Member:
683 ((granny_uint16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint16)value; break;
684 case granny_member_type::GrannyInt32Member:
685 ((granny_int32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_int32)value; break;
686 case granny_member_type::GrannyUInt32Member:
687 ((granny_uint32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_uint32)value; break;
688 case granny_member_type::GrannyReal16Member:
689 ((granny_real16(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = (granny_real16)value; break;
690 //case granny_member_type::GrannyEmptyReferenceMember:
691 // ((granny_int32(*)[MAX_GRANNY_MEMBER_COUNT])_grn_file->GrannyFileInfo->Materials[i]->ExtendedData.Object)[0][j] = value; break;
692 //case granny_member_type::GrannyOnePastLastMemberType: break;
693 //case granny_member_type::GrannyBool32Member: break;
694 default: throw gcnew System::InvalidOperationException("Encountered an Invalid Granny Member Type: " + MemberType);
695 }
696
697
698
699
700
701 }
702 }
703 }
704 #pragma endregion
705 #pragma endregion
706
707 #pragma endregion
708
709 #pragma region DoPostSave_Operations
710 void DoPostSave_Operations()
711 {
712 //// Compress Bink Textures
713 //for(int i=0;i<_grn_file->GrannyFileInfo->TextureCount;i++)
714 //{
715 // if (_grn_file->GrannyFileInfo->Textures[i]->Encoding == granny_texture_encoding::GrannyBinkTextureEncoding)
716 // {
717 // int bink_compress = GrannyBinkCompressTexture(
718 // _grn_file->GrannyFileInfo->Textures[i]->Width,
719 // _grn_file->GrannyFileInfo->Textures[i]->Height,
720 // _grn_file->GrannyFileInfo->Textures[i]->Width * _grn_file->GrannyFileInfo->Textures[i]->Layout.BytesPerPixel,
721 // _grn_file->GrannyFileInfo->Textures[i]->Images,
722 // granny_bink_texture_flags::GrannyBinkEncodeAlpha,
723 // granny_compression_type::GrannyNoCompression,
724 // _grn_file->GrannyFileInfo->Textures[i]);
725 // int a = 0;
726 // }
727 //}
728 }
729 #pragma endregion
730
731 private: System::Void mnuItemExit_Click(System::Object^ sender, System::EventArgs^ e)
732 {
733 ConvertToNative();
734 this->Close();
735 }
736 private: System::Void mnuItemOpen_Click(System::Object^ sender, System::EventArgs^ e)
737 {
738 System::Windows::Forms::DialogResult result = RigLoader->ShowDialog();
739 if (result != System::Windows::Forms::DialogResult::OK) return;
740 const char* fn = (char*)Marshal::StringToHGlobalAnsi(RigLoader->FileName).ToPointer();
741
742 _grn_file = new grannyfile();
743 const char* loading_msg = "Loading File: ";
744 int msg_malloc = (strlen(loading_msg) + strlen(fn));
745 char* msg = (char*)malloc(msg_malloc);
746 for (int i=0; i<msg_malloc; i++) { msg[i] = 0; }
747 strcat(msg,loading_msg);
748 strcat(msg,fn);
749 strcat(msg,"\n");
750 _grn_file->_logger->LogMessage(msg);
751 //_grn_file->_logger->SetLogFileName("c:\\gr2_logs",fn);
752 _grn_file = new grannyfile(fn);
753
754 this->GR2LibPropertyWrapper = gcnew GR2LibWrapper();
755 ConvertToManaged();
756 propgrid->SelectedObject = this->GR2LibPropertyWrapper;
757 }
758 private: System::Void gr2lib_rigeditor_frm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e)
759 {
760 //TerminateConsoleIO();
761 }
762 private: System::Void gr2lib_rigeditor_frm_Load(System::Object^ sender, System::EventArgs^ e)
763 {
764 #if defined SHOW_DEBUG_MENU
765 mnuDebug->Visible = true;
766 #else
767 mnuDebug->Visible = false;
768 #endif
769 }
770 private: System::Void mnuTestArtToolInfoReturnValues_Click(System::Object^ sender, System::EventArgs^ e)
771 {
772 // Convert ArtToolInfo To Native, and ouput the values -> to check that they were updated correctly
773 ArtToolInfo_ToNative();
774 VSDebugWriterW VSDebugWriter;
775 VSDebugWriter
776 << "\n\n\tArtToolInfo ->"
777 << "\n\t\tTool Name: "
778 << _grn_file->GrannyFileInfo->ArtToolInfo->FromArtToolName
779 << "\n\t\tTool Version: "
780 << _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMajorRevision
781 << "." << _grn_file->GrannyFileInfo->ArtToolInfo->ArtToolMinorRevision
782 << "\n\t\tUnits Per Meter: "
783 << _grn_file->GrannyFileInfo->ArtToolInfo->UnitsPerMeter
784 << "\n\t\tOrigin: "
785 << "\n\t\t\tX: "
786 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[0]
787 << "\n\t\t\tY: "
788 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[1]
789 << "\n\t\t\tZ: "
790 << _grn_file->GrannyFileInfo->ArtToolInfo->Origin[2]
791 << "\n\t\tRight: "
792 << "\n\t\t\tX: "
793 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[0]
794 << "\n\t\t\tY: "
795 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[1]
796 << "\n\t\t\tZ: "
797 << _grn_file->GrannyFileInfo->ArtToolInfo->RightVector[2]
798 << "\n\t\tUp: "
799 << "\n\t\t\tX: "
800 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[0]
801 << "\n\t\t\tY: "
802 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[1]
803 << "\n\t\t\tZ: "
804 << _grn_file->GrannyFileInfo->ArtToolInfo->UpVector[2]
805 << "\n\t\tBack: "
806 << "\n\t\t\tX: "
807 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[0]
808 << "\n\t\t\tY: "
809 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[1]
810 << "\n\t\t\tZ: "
811 << _grn_file->GrannyFileInfo->ArtToolInfo->BackVector[2]
812 ;
813 }
814 private: System::Void mnuTestExporterInfoReturnValues_Click(System::Object^ sender, System::EventArgs^ e)
815 {
816 // Convert ExporterInfo To Native, and ouput the values -> to check that they were updated correctly
817 ExporterInfo_ToNative();
818 VSDebugWriterW VSDebugWriter;
819 VSDebugWriter
820 << "\n\n\tExporterInfo ->"
821 << "\n\t\tExporter Name: "
822 << _grn_file->GrannyFileInfo->ExporterInfo->ExporterName
823 << "\n\t\tExporter Version: "
824 << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMajorRevision
825 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterMinorRevision
826 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterCustomization
827 << "." << _grn_file->GrannyFileInfo->ExporterInfo->ExporterBuildNumber
828 ;
829 }
830 private: System::Void mnuItemSave_Click(System::Object^ sender, System::EventArgs^ e)
831 {
832 // convert Data to Native
833 try
834 {
835 ConvertToNative();
836 const char* filename = _grn_file->_GrannyFilename;
837 GrannyFileWriter::WriteFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);
838 //DoPostSave_Operations();
839 //GrannyFileWriter::WriteFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);
840 System::Windows::Forms::MessageBox::Show("Successfully Saved: \n" + gcnew String(_grn_file->GrannyFilename()),"File Writer:", MessageBoxButtons::OK,MessageBoxIcon::Information);
841 }
842 catch(Exception^ ex)
843 {
844 System::Windows::Forms::MessageBox::Show("Failed to Save: \n" + gcnew String(_grn_file->GrannyFilename()),"File Writer:", MessageBoxButtons::OK,MessageBoxIcon::Error);
845 }
846 }
847 private: System::Void mnuItemSaveAs_Click(System::Object^ sender, System::EventArgs^ e)
848 {
849 // convert Data to Native
850 try
851 {
852 ConvertToNative();
853 System::Windows::Forms::DialogResult result = RigSaver->ShowDialog();
854 if (result != System::Windows::Forms::DialogResult::OK) return;
855 const char* filename = (char*)Marshal::StringToHGlobalAnsi(RigSaver->FileName).ToPointer();
856 GrannyFileWriter::WriteFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);
857 //DoPostSave_Operations();
858 //GrannyFileWriter::WriteFile(filename,_grn_file->GrannyFileInfo,_grn_file->_logger);
859 System::Windows::Forms::MessageBox::Show("Successfully Saved: \n" + gcnew String(_grn_file->GrannyFilename()),"File Writer:", MessageBoxButtons::OK,MessageBoxIcon::Information);
860 }
861 catch(Exception^ ex)
862 {
863 System::Windows::Forms::MessageBox::Show("Failed to Save: \n" + gcnew String(_grn_file->GrannyFilename()),"File Writer:", MessageBoxButtons::OK,MessageBoxIcon::Error);
864 }
865 }
866 private: System::Void mnuItemClose_Click(System::Object^ sender, System::EventArgs^ e)
867 {
868 propgrid->SelectedObject = nullptr;
869 }
870 };
871 // }
872 // }
873 //}
874 #endif /* GR2LIB_RIGEDITOR_FRM_H */

  ViewVC Help
Powered by ViewVC 1.1.22