/[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 71 - (show annotations) (download)
Sat Aug 14 08:06:32 2010 UTC (9 years, 6 months ago) by william
File MIME type: text/plain
File size: 39410 byte(s)
Conversion of ExtendedData to Managed/Native:
** Move into their own methods, so they can be re-used by all classes
   that need ExtendedData Marshalled to Managed/Native Data.
** Implement Editing ExtendedData for:
    *Art Tool Info
    *Exporter Info
    *Textures
    *Materials
** Fix error in ExtendedDataWrapper, when no extendedData exists -
    * Set MeberCount -> 0 [if == 0], instead of -1 (i.e. MemberCount - 1).

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

  ViewVC Help
Powered by ViewVC 1.1.22