Subversion Repositories spk

Rev

Rev 219 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
#pragma once
2
 
3
#include "BaseForm.h"
4
 
5
using namespace System;
6
using namespace System::ComponentModel;
7
using namespace System::Collections;
8
using namespace System::Windows::Forms;
9
using namespace System::Data;
10
using namespace System::Drawing;
11
 
12
namespace Creator {
13
	/// <summary>
14
	/// Summary for MultiForm1
15
	///
16
	/// WARNING: If you change the name of this class, you will need to change the
17
	///          'Resource File Name' property for the managed resource compiler tool
18
	///          associated with all .resx files this class depends on.  Otherwise,
19
	///          the designers will not be able to interact properly with localized
20
	///          resources associated with this form.
21
	/// </summary>
22
// remove before build
23
//#define DESIGNER
24
 
25
#ifdef DESIGNER
26
	public ref class MultiForm : public System::Windows::Forms::Form
27
#else
28
	public ref class MultiForm : public BaseForm
29
#endif
30
	{
31
	public:
36 cycrow 32
		MultiForm(System::Windows::Forms::Form ^parent, System::Windows::Forms::TabControl ^ctrl, System::Windows::Forms::TabPage ^page, System::Windows::Forms::ToolStripMenuItem ^tool, CPackages *p, Windows::Forms::ImageList ^imagelist, SSettings *set)  : BaseForm(parent, ctrl, page, tool, p, imagelist, set)
1 cycrow 33
		{
34
			InitializeComponent();
35
 
36
			m_iFormType = FORMTYPE_MULTI;
37
 
38
			this->listView1->SmallImageList = this->imageList1;
39
			this->listView1->LargeImageList = this->imageList1;
40
 
41
			m_pTabPage->ImageIndex = this->imageList1->Images->IndexOfKey("multi");
42
			m_pMenuItem->Image = this->imageList1->Images[m_pTabPage->ImageIndex];
43
		}
44
 
45
		bool LoadPackage(CMultiSpkFile *base, System::String ^filename);
46
		CMultiSpkFile *GetPackage() { return m_pPackage; }
47
 
48
		void AddPackage()
49
		{
50
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
51
			ofd->Filter = "All (*.spk *.xsp)|*.spk;*.xsp|Package Files (*.spk)|*.spk|Ship Files (*.xsp)|*.xsp";
52
			ofd->FilterIndex = 1;
53
			ofd->RestoreDirectory = true;
54
			ofd->Multiselect = true;
55
 
56
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
57
				AddPackages(ofd->FileNames);
58
		}
59
 
60
		void AddPackages(cli::array<System::String ^> ^list)
61
		{
62
			String ^str;
63
			for ( int i = 0; i < list->Length; i++ )
64
			{
65
				if ( !AddPackage(list[i], false) )
66
				{
67
					if ( str )
68
						str += "\n";
69
					str += list[i];
70
				}
71
			}
72
 
73
			if ( str )
74
			{
75
				MessageBox::Show(this, "Unable to add package files:\n" + str, "Add Package", MessageBoxButtons::OK, MessageBoxIcon::Error);
76
			}
77
 
78
			this->UpdatePackages();
79
			this->UpdateChanged();
80
		}
81
 
82
		bool AddPackage(String ^file, bool single)
83
		{
224 cycrow 84
			if ( m_pPackage->addFile(_WS(file)) )
1 cycrow 85
			{
86
				if ( single )
87
				{
88
					this->UpdatePackages();
89
					this->UpdateChanged();
90
					MessageBox::Show(this, "Unable to add package file: " + file, "Add Package", MessageBoxButtons::OK, MessageBoxIcon::Error);
91
				}
92
				return true;
93
			}
94
 
95
			return false;
96
		}
97
 
98
		void UpdateChanged()
99
		{
100
			if ( m_bLoading )
101
				return;
102
			if ( !m_pPackage )
103
				return;
104
 
177 cycrow 105
			if ( m_pPackage->isChanged() )
1 cycrow 106
			{
177 cycrow 107
				if (!m_pPackage->filename().empty())
108
					this->Text = _US(m_pPackage->filename()) + "*";
1 cycrow 109
				if ( m_pTabPage->Text[m_pTabPage->Text->Length - 1] != '*' )
110
					m_pTabPage->Text += "*";
111
			}
112
			else
113
			{
177 cycrow 114
				this->Text = _US(m_pPackage->filename());
1 cycrow 115
				if ( m_pTabPage->Text[m_pTabPage->Text->Length - 1] == '*' )
116
					m_pTabPage->Text = m_pTabPage->Text->Remove(m_pTabPage->Text->Length - 1);
117
			}
118
		}
119
 
120
		virtual void Save() new;
121
		virtual void SaveAs() new;
122
		bool CheckSave();
123
 
124
		void CreatePackage()
125
		{
126
			if ( m_pPackage ) delete m_pPackage; 
127
			m_pPackage = new CMultiSpkFile; 
128
		}
129
 
130
		void Split(String ^dest)
131
		{
224 cycrow 132
			if ( m_pPackage->extractAll(_WS(dest)) )
1 cycrow 133
				MessageBox::Show(this, "All Packages have been extracted to:\n" + dest, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Information);
134
			else
135
				MessageBox::Show(this, "Failed to extract Packages to:\n" + dest, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Error);
136
		}
137
 
138
		void Split()
139
		{
140
			FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
141
			fbd->Description = "Select the path to split the multi package to";
142
			if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
143
				Split(fbd->SelectedPath);
144
		}
145
 
146
		void Extract(String ^file, String ^to)
147
		{
224 cycrow 148
			if ( m_pPackage->extractFile(_WS(file), _WS(to)) )
1 cycrow 149
				MessageBox::Show(this, "Package: " + file + "\nHas been extracted to: " + to, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Information);
150
			else
151
				MessageBox::Show(this, "Package: " + file + "\nFailed to extract to: " + to, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Error);
152
		}
153
 
154
		void Extract(String ^file)
155
		{
156
			FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
157
			fbd->Description = "Select the path to extract " + file + " to.";
158
			if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
159
				Extract(file, fbd->SelectedPath);
160
		}
161
 
162
	protected:
163
		/// <summary>
164
		/// Clean up any resources being used.
165
		/// </summary>
166
		~MultiForm()
167
		{
168
			if (components)
169
			{
170
				delete components;
171
			}
172
		}
173
 
174
	private:
175
		void UpdateView();
176
		void UpdatePackages();
177
 
178
		CMultiSpkFile	*m_pPackage;
179
	private: System::Windows::Forms::Label^  label1;
180
	private: System::Windows::Forms::Panel^  panel1;
181
	private: System::Windows::Forms::TextBox^  textBox1;
182
	private: System::Windows::Forms::ToolStrip^  toolStrip1;
183
	private: System::Windows::Forms::ToolStripButton^  toolStripButton1;
184
	private: System::Windows::Forms::GroupBox^  groupBox1;
185
	private: System::Windows::Forms::ListView^  listView1;
186
	private: System::Windows::Forms::Panel^  panel2;
187
	private: System::Windows::Forms::CheckBox^  checkBox1;
188
	private: System::Windows::Forms::Label^  label2;
189
	private: System::Windows::Forms::ColumnHeader^  columnHeader1;
190
	private: System::Windows::Forms::ColumnHeader^  columnHeader2;
191
	private: System::Windows::Forms::ColumnHeader^  columnHeader3;
192
	private: System::Windows::Forms::ColumnHeader^  columnHeader4;
193
	private: System::Windows::Forms::ColumnHeader^  columnHeader5;
194
	private: System::Windows::Forms::ColumnHeader^  columnHeader6;
195
	private: System::Windows::Forms::ContextMenuStrip^  contextMenuStrip1;
196
	private: System::Windows::Forms::ToolStripMenuItem^  addPackageToolStripMenuItem;
197
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
198
	private: System::Windows::Forms::ToolStripMenuItem^  removeFileToolStripMenuItem;
199
	private: System::Windows::Forms::ToolStripMenuItem^  clearAllToolStripMenuItem;
200
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator2;
201
private: System::Windows::Forms::ToolStripButton^  toolStripButton2;
202
private: System::Windows::Forms::ToolStripButton^  toolStripButton3;
203
private: System::Windows::Forms::Panel^  panel3;
204
private: System::Windows::Forms::Button^  button1;
205
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator3;
206
private: System::Windows::Forms::ToolStripButton^  toolStripButton4;
207
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator4;
208
private: System::Windows::Forms::ToolStripMenuItem^  extractToolStripMenuItem;
209
private: System::Windows::Forms::Button^  button2;
210
	private: System::ComponentModel::IContainer^  components;
211
 
212
			 /// <summary>
213
		/// Required designer variable.
214
		/// </summary>
215
 
216
 
217
#pragma region Windows Form Designer generated code
218
		/// <summary>
219
		/// Required method for Designer support - do not modify
220
		/// the contents of this method with the code editor.
221
		/// </summary>
222
		void InitializeComponent(void)
223
		{
224
			this->components = (gcnew System::ComponentModel::Container());
225
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MultiForm::typeid));
226
			this->label1 = (gcnew System::Windows::Forms::Label());
227
			this->panel1 = (gcnew System::Windows::Forms::Panel());
228
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
229
			this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
230
			this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
231
			this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator());
232
			this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
233
			this->toolStripButton3 = (gcnew System::Windows::Forms::ToolStripButton());
234
			this->toolStripSeparator3 = (gcnew System::Windows::Forms::ToolStripSeparator());
235
			this->toolStripButton4 = (gcnew System::Windows::Forms::ToolStripButton());
236
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
237
			this->listView1 = (gcnew System::Windows::Forms::ListView());
238
			this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
239
			this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
240
			this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader());
241
			this->columnHeader5 = (gcnew System::Windows::Forms::ColumnHeader());
242
			this->columnHeader4 = (gcnew System::Windows::Forms::ColumnHeader());
243
			this->columnHeader6 = (gcnew System::Windows::Forms::ColumnHeader());
244
			this->contextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
245
			this->addPackageToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
246
			this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
247
			this->removeFileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
248
			this->clearAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
249
			this->toolStripSeparator4 = (gcnew System::Windows::Forms::ToolStripSeparator());
250
			this->extractToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
251
			this->panel3 = (gcnew System::Windows::Forms::Panel());
252
			this->button2 = (gcnew System::Windows::Forms::Button());
253
			this->button1 = (gcnew System::Windows::Forms::Button());
254
			this->panel2 = (gcnew System::Windows::Forms::Panel());
255
			this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
256
			this->label2 = (gcnew System::Windows::Forms::Label());
257
			this->panel1->SuspendLayout();
258
			this->toolStrip1->SuspendLayout();
259
			this->groupBox1->SuspendLayout();
260
			this->contextMenuStrip1->SuspendLayout();
261
			this->panel3->SuspendLayout();
262
			this->panel2->SuspendLayout();
263
			this->SuspendLayout();
264
			// 
265
			// label1
266
			// 
267
			this->label1->Dock = System::Windows::Forms::DockStyle::Left;
268
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
269
				static_cast<System::Byte>(0)));
270
			this->label1->Location = System::Drawing::Point(5, 5);
271
			this->label1->Name = L"label1";
272
			this->label1->Size = System::Drawing::Size(157, 21);
273
			this->label1->TabIndex = 0;
274
			this->label1->Text = L"Multi Pack Name";
275
			// 
276
			// panel1
277
			// 
278
			this->panel1->Controls->Add(this->textBox1);
279
			this->panel1->Controls->Add(this->label1);
280
			this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
281
			this->panel1->Location = System::Drawing::Point(0, 31);
282
			this->panel1->Name = L"panel1";
283
			this->panel1->Padding = System::Windows::Forms::Padding(5);
284
			this->panel1->Size = System::Drawing::Size(596, 31);
285
			this->panel1->TabIndex = 1;
286
			// 
287
			// textBox1
288
			// 
289
			this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill;
290
			this->textBox1->Location = System::Drawing::Point(162, 5);
291
			this->textBox1->Name = L"textBox1";
292
			this->textBox1->Size = System::Drawing::Size(429, 20);
293
			this->textBox1->TabIndex = 1;
294
			this->textBox1->TextChanged += gcnew System::EventHandler(this, &MultiForm::textBox1_TextChanged);
295
			// 
296
			// toolStrip1
297
			// 
298
			this->toolStrip1->GripStyle = System::Windows::Forms::ToolStripGripStyle::Hidden;
299
			this->toolStrip1->ImageScalingSize = System::Drawing::Size(24, 24);
300
			this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(6) {this->toolStripButton1, 
301
				this->toolStripSeparator2, this->toolStripButton2, this->toolStripButton3, this->toolStripSeparator3, this->toolStripButton4});
302
			this->toolStrip1->Location = System::Drawing::Point(0, 0);
303
			this->toolStrip1->Name = L"toolStrip1";
304
			this->toolStrip1->Size = System::Drawing::Size(596, 31);
305
			this->toolStrip1->TabIndex = 2;
306
			this->toolStrip1->Text = L"toolStrip1";
307
			// 
308
			// toolStripButton1
309
			// 
310
			this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton1.Image")));
311
			this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
312
			this->toolStripButton1->Name = L"toolStripButton1";
313
			this->toolStripButton1->Size = System::Drawing::Size(104, 28);
314
			this->toolStripButton1->Text = L"Add Package";
315
			this->toolStripButton1->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton1_Click);
316
			// 
317
			// toolStripSeparator2
318
			// 
319
			this->toolStripSeparator2->Name = L"toolStripSeparator2";
320
			this->toolStripSeparator2->Size = System::Drawing::Size(6, 31);
321
			// 
322
			// toolStripButton2
323
			// 
324
			this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton2.Image")));
325
			this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;
326
			this->toolStripButton2->Name = L"toolStripButton2";
327
			this->toolStripButton2->Size = System::Drawing::Size(59, 28);
328
			this->toolStripButton2->Text = L"Save";
329
			this->toolStripButton2->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton2_Click);
330
			// 
331
			// toolStripButton3
332
			// 
333
			this->toolStripButton3->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton3.Image")));
334
			this->toolStripButton3->ImageTransparentColor = System::Drawing::Color::Magenta;
335
			this->toolStripButton3->Name = L"toolStripButton3";
336
			this->toolStripButton3->Size = System::Drawing::Size(75, 28);
337
			this->toolStripButton3->Text = L"Save As";
338
			this->toolStripButton3->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton3_Click);
339
			// 
340
			// toolStripSeparator3
341
			// 
342
			this->toolStripSeparator3->Name = L"toolStripSeparator3";
343
			this->toolStripSeparator3->Size = System::Drawing::Size(6, 31);
344
			// 
345
			// toolStripButton4
346
			// 
347
			this->toolStripButton4->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton4.Image")));
348
			this->toolStripButton4->ImageTransparentColor = System::Drawing::Color::Magenta;
349
			this->toolStripButton4->Name = L"toolStripButton4";
350
			this->toolStripButton4->Size = System::Drawing::Size(58, 28);
351
			this->toolStripButton4->Text = L"Split";
352
			this->toolStripButton4->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton4_Click);
353
			// 
354
			// groupBox1
355
			// 
356
			this->groupBox1->Controls->Add(this->listView1);
357
			this->groupBox1->Controls->Add(this->panel3);
358
			this->groupBox1->Dock = System::Windows::Forms::DockStyle::Fill;
359
			this->groupBox1->Location = System::Drawing::Point(0, 93);
360
			this->groupBox1->Name = L"groupBox1";
361
			this->groupBox1->Padding = System::Windows::Forms::Padding(6);
362
			this->groupBox1->Size = System::Drawing::Size(596, 429);
363
			this->groupBox1->TabIndex = 3;
364
			this->groupBox1->TabStop = false;
365
			this->groupBox1->Text = L"Packages";
366
			// 
367
			// listView1
368
			// 
369
			this->listView1->CheckBoxes = true;
370
			this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^  >(6) {this->columnHeader1, this->columnHeader2, 
371
				this->columnHeader3, this->columnHeader5, this->columnHeader4, this->columnHeader6});
372
			this->listView1->ContextMenuStrip = this->contextMenuStrip1;
373
			this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
374
			this->listView1->FullRowSelect = true;
375
			this->listView1->HideSelection = false;
376
			this->listView1->Location = System::Drawing::Point(6, 19);
377
			this->listView1->Name = L"listView1";
378
			this->listView1->Size = System::Drawing::Size(584, 373);
379
			this->listView1->TabIndex = 0;
380
			this->listView1->UseCompatibleStateImageBehavior = false;
381
			this->listView1->View = System::Windows::Forms::View::Details;
382
			this->listView1->ItemChecked += gcnew System::Windows::Forms::ItemCheckedEventHandler(this, &MultiForm::listView1_ItemChecked);
383
			this->listView1->SelectedIndexChanged += gcnew System::EventHandler(this, &MultiForm::listView1_SelectedIndexChanged);
384
			// 
385
			// columnHeader1
386
			// 
387
			this->columnHeader1->Text = L"Type";
388
			// 
389
			// columnHeader2
390
			// 
391
			this->columnHeader2->Text = L"Name";
392
			// 
393
			// columnHeader3
394
			// 
395
			this->columnHeader3->Text = L"Author";
396
			// 
397
			// columnHeader5
398
			// 
399
			this->columnHeader5->Text = L"Version";
400
			// 
401
			// columnHeader4
402
			// 
403
			this->columnHeader4->Text = L"Filename";
404
			// 
405
			// columnHeader6
406
			// 
407
			this->columnHeader6->Text = L"Size";
408
			// 
409
			// contextMenuStrip1
410
			// 
411
			this->contextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(6) {this->addPackageToolStripMenuItem, 
412
				this->toolStripSeparator1, this->removeFileToolStripMenuItem, this->clearAllToolStripMenuItem, this->toolStripSeparator4, this->extractToolStripMenuItem});
413
			this->contextMenuStrip1->Name = L"contextMenuStrip1";
414
			this->contextMenuStrip1->Size = System::Drawing::Size(152, 136);
415
			this->contextMenuStrip1->Opening += gcnew System::ComponentModel::CancelEventHandler(this, &MultiForm::contextMenuStrip1_Opening);
416
			// 
417
			// addPackageToolStripMenuItem
418
			// 
419
			this->addPackageToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"addPackageToolStripMenuItem.Image")));
420
			this->addPackageToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
421
			this->addPackageToolStripMenuItem->Name = L"addPackageToolStripMenuItem";
422
			this->addPackageToolStripMenuItem->Size = System::Drawing::Size(151, 30);
423
			this->addPackageToolStripMenuItem->Text = L"Add Package";
424
			this->addPackageToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::addPackageToolStripMenuItem_Click);
425
			// 
426
			// toolStripSeparator1
427
			// 
428
			this->toolStripSeparator1->Name = L"toolStripSeparator1";
429
			this->toolStripSeparator1->Size = System::Drawing::Size(148, 6);
430
			// 
431
			// removeFileToolStripMenuItem
432
			// 
433
			this->removeFileToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"removeFileToolStripMenuItem.Image")));
434
			this->removeFileToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
435
			this->removeFileToolStripMenuItem->Name = L"removeFileToolStripMenuItem";
436
			this->removeFileToolStripMenuItem->Size = System::Drawing::Size(151, 30);
437
			this->removeFileToolStripMenuItem->Text = L"Remove File";
438
			this->removeFileToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::removeFileToolStripMenuItem_Click);
439
			// 
440
			// clearAllToolStripMenuItem
441
			// 
442
			this->clearAllToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"clearAllToolStripMenuItem.Image")));
443
			this->clearAllToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
444
			this->clearAllToolStripMenuItem->Name = L"clearAllToolStripMenuItem";
445
			this->clearAllToolStripMenuItem->Size = System::Drawing::Size(151, 30);
446
			this->clearAllToolStripMenuItem->Text = L"Clear All";
447
			this->clearAllToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::clearAllToolStripMenuItem_Click);
448
			// 
449
			// toolStripSeparator4
450
			// 
451
			this->toolStripSeparator4->Name = L"toolStripSeparator4";
452
			this->toolStripSeparator4->Size = System::Drawing::Size(148, 6);
453
			// 
454
			// extractToolStripMenuItem
455
			// 
456
			this->extractToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"extractToolStripMenuItem.Image")));
457
			this->extractToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
458
			this->extractToolStripMenuItem->Name = L"extractToolStripMenuItem";
459
			this->extractToolStripMenuItem->Size = System::Drawing::Size(151, 30);
460
			this->extractToolStripMenuItem->Text = L"Extract";
461
			this->extractToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::extractToolStripMenuItem_Click);
462
			// 
463
			// panel3
464
			// 
465
			this->panel3->Controls->Add(this->button2);
466
			this->panel3->Controls->Add(this->button1);
467
			this->panel3->Dock = System::Windows::Forms::DockStyle::Bottom;
468
			this->panel3->Location = System::Drawing::Point(6, 392);
469
			this->panel3->Name = L"panel3";
470
			this->panel3->Size = System::Drawing::Size(584, 31);
471
			this->panel3->TabIndex = 1;
472
			// 
473
			// button2
474
			// 
475
			this->button2->Dock = System::Windows::Forms::DockStyle::Right;
476
			this->button2->Enabled = false;
477
			this->button2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"button2.Image")));
478
			this->button2->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
479
			this->button2->Location = System::Drawing::Point(265, 0);
480
			this->button2->Name = L"button2";
481
			this->button2->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
482
			this->button2->Size = System::Drawing::Size(143, 31);
483
			this->button2->TabIndex = 1;
484
			this->button2->Text = L"Extract Selected";
485
			this->button2->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
486
			this->button2->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
487
			this->button2->UseVisualStyleBackColor = true;
488
			this->button2->Click += gcnew System::EventHandler(this, &MultiForm::button2_Click);
489
			// 
490
			// button1
491
			// 
492
			this->button1->Dock = System::Windows::Forms::DockStyle::Right;
493
			this->button1->Enabled = false;
494
			this->button1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"button1.Image")));
495
			this->button1->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
496
			this->button1->Location = System::Drawing::Point(408, 0);
497
			this->button1->Name = L"button1";
498
			this->button1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
499
			this->button1->Size = System::Drawing::Size(176, 31);
500
			this->button1->TabIndex = 0;
501
			this->button1->Text = L"Remove Selected";
502
			this->button1->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
503
			this->button1->UseVisualStyleBackColor = true;
504
			this->button1->Click += gcnew System::EventHandler(this, &MultiForm::button1_Click);
505
			// 
506
			// panel2
507
			// 
508
			this->panel2->Controls->Add(this->checkBox1);
509
			this->panel2->Controls->Add(this->label2);
510
			this->panel2->Dock = System::Windows::Forms::DockStyle::Top;
511
			this->panel2->Location = System::Drawing::Point(0, 62);
512
			this->panel2->Name = L"panel2";
513
			this->panel2->Padding = System::Windows::Forms::Padding(5);
514
			this->panel2->Size = System::Drawing::Size(596, 31);
515
			this->panel2->TabIndex = 4;
516
			// 
517
			// checkBox1
518
			// 
519
			this->checkBox1->AutoSize = true;
520
			this->checkBox1->Dock = System::Windows::Forms::DockStyle::Fill;
521
			this->checkBox1->Location = System::Drawing::Point(162, 5);
522
			this->checkBox1->Name = L"checkBox1";
523
			this->checkBox1->Size = System::Drawing::Size(429, 21);
524
			this->checkBox1->TabIndex = 1;
525
			this->checkBox1->UseVisualStyleBackColor = true;
526
			this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &MultiForm::checkBox1_CheckedChanged);
527
			// 
528
			// label2
529
			// 
530
			this->label2->Dock = System::Windows::Forms::DockStyle::Left;
531
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
532
				static_cast<System::Byte>(0)));
533
			this->label2->Location = System::Drawing::Point(5, 5);
534
			this->label2->Name = L"label2";
535
			this->label2->Size = System::Drawing::Size(157, 21);
536
			this->label2->TabIndex = 0;
537
			this->label2->Text = L"Allow Selection";
538
			// 
539
			// MultiForm
540
			// 
541
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
542
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
543
			this->ClientSize = System::Drawing::Size(596, 522);
544
			this->Controls->Add(this->groupBox1);
545
			this->Controls->Add(this->panel2);
546
			this->Controls->Add(this->panel1);
547
			this->Controls->Add(this->toolStrip1);
548
			this->Name = L"MultiForm";
549
			this->Text = L"MultiForm";
550
			this->Load += gcnew System::EventHandler(this, &MultiForm::MultiForm_Load);
551
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &MultiForm::MultiForm_FormClosing);
552
			this->panel1->ResumeLayout(false);
553
			this->panel1->PerformLayout();
554
			this->toolStrip1->ResumeLayout(false);
555
			this->toolStrip1->PerformLayout();
556
			this->groupBox1->ResumeLayout(false);
557
			this->contextMenuStrip1->ResumeLayout(false);
558
			this->panel3->ResumeLayout(false);
559
			this->panel2->ResumeLayout(false);
560
			this->panel2->PerformLayout();
561
			this->ResumeLayout(false);
562
			this->PerformLayout();
563
 
564
		}
565
#pragma endregion
566
	private: System::Void MultiForm_Load(System::Object^  sender, System::EventArgs^  e) {
567
			 }
568
	private: System::Void toolStripButton1_Click(System::Object^  sender, System::EventArgs^  e) {
569
				 AddPackage();
570
			 }
571
private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
224 cycrow 572
			 m_pPackage->setName(_WS(this->textBox1->Text));
1 cycrow 573
			 this->UpdateChanged();
574
		 }
575
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
177 cycrow 576
			 m_pPackage->setSelection(this->checkBox1->Checked);
1 cycrow 577
			 this->UpdateChanged();
578
		 }
579
private: System::Void contextMenuStrip1_Opening(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
580
			Point ^mousePoint = this->listView1->PointToClient(this->listView1->MousePosition);
581
			m_pSelectedItem = this->listView1->GetItemAt(mousePoint->X, mousePoint->Y);
582
 
583
			bool show = (m_pSelectedItem) ? true : false;
584
 
585
			this->extractToolStripMenuItem->Visible = show;
586
			this->toolStripSeparator1->Visible = show;
587
			this->removeFileToolStripMenuItem->Visible = show;
588
			this->clearAllToolStripMenuItem->Visible = show;
589
			this->toolStripSeparator4->Visible = show;
590
		 }
591
private: System::Void addPackageToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
592
			 AddPackage();
593
		 }
594
private: System::Void removeFileToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
595
			 if ( !m_pSelectedItem ) return;
219 cycrow 596
			 m_pPackage->markRemoveFile(_WS(m_pSelectedItem->SubItems[4]->Text));
1 cycrow 597
			 this->UpdatePackages();
598
			 this->UpdateChanged();
599
		 }
600
private: System::Void clearAllToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
601
			 if ( !m_pSelectedItem ) return;
177 cycrow 602
			 m_pPackage->markRemoveAll();
1 cycrow 603
			 this->UpdatePackages();
604
			 this->UpdateChanged();
605
		 }
606
private: System::Void toolStripButton2_Click(System::Object^  sender, System::EventArgs^  e) {
607
			 Save();
608
		 }
609
private: System::Void toolStripButton3_Click(System::Object^  sender, System::EventArgs^  e) {
610
			 SaveAs();
611
		 }
612
private: System::Void listView1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
613
			 this->button1->Enabled = (this->listView1->SelectedItems->Count) ? true : false;
614
			 this->button2->Enabled = (this->listView1->SelectedItems->Count) ? true : false;
615
		 }
616
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
617
			 for ( int i = 0; i < this->listView1->SelectedItems->Count; i++ )
618
			 {
219 cycrow 619
				m_pPackage->markRemoveFile(_WS(this->listView1->SelectedItems[i]->SubItems[4]->Text));
1 cycrow 620
			 }
621
			 this->UpdatePackages();
622
			 this->UpdateChanged();
623
		 }
624
private: System::Void listView1_ItemChecked(System::Object^  sender, System::Windows::Forms::ItemCheckedEventArgs^  e) {
625
			 if ( m_bLoading ) return;
626
			 ListViewItem ^item = e->Item;
627
			 if ( item && item->SubItems->Count > 4 )
628
			 {
224 cycrow 629
				 const SMultiSpkFile *ms = m_pPackage->findFile(_WS(item->SubItems[4]->Text));
1 cycrow 630
				 if ( ms )
631
				 {
177 cycrow 632
					 const_cast<SMultiSpkFile *>(ms)->bOn = item->Checked;
633
					 m_pPackage->setChanged(true);
1 cycrow 634
					 this->UpdateChanged();
635
				 }
636
			 }
637
		 }
638
private: System::Void MultiForm_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
177 cycrow 639
			if (m_pPackage->isChanged())
1 cycrow 640
			{
641
				String ^name = m_pTabPage->Text;
642
				if ( name[name->Length - 1] == '*' )
643
					name = name->Remove(name->Length - 1);
644
				System::Windows::Forms::DialogResult result = MessageBox::Show("Would you like to save changes to the multi package?\n\n" + name, "Save Multi Package", MessageBoxButtons::YesNoCancel, MessageBoxIcon::Question);
645
 
646
				if ( result == System::Windows::Forms::DialogResult::Cancel )
647
				{
648
					e->Cancel = true;
649
					return;
650
				}
651
				else if ( result == System::Windows::Forms::DialogResult::Yes )
652
				{
653
					if ( !this->CheckSave() )
654
					{
655
						e->Cancel = true;
656
						return;
657
					}
658
 
177 cycrow 659
					if (m_pPackage->filename().empty())
1 cycrow 660
					{
661
						SaveFileDialog ^ofd = gcnew SaveFileDialog();
662
						ofd->Filter = "Multi-Package Files (*.spk)|*.spk";
663
						ofd->FilterIndex = 1;
664
						ofd->RestoreDirectory = true;
665
						if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
224 cycrow 666
							m_pPackage->setFilename(_WS(ofd->FileName));
1 cycrow 667
						else
668
						{
669
							e->Cancel = true;
670
							return;
671
						}
672
					}
673
 
177 cycrow 674
					if (!m_pPackage->writeFile(m_pPackage->filename()))
1 cycrow 675
					{
676
						e->Cancel = true;
177 cycrow 677
						MessageBox::Show("Unable to save package\n" + _US(m_pPackage->filename()), "Save Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
1 cycrow 678
						return;
679
					}
680
				}
681
			}
682
 
683
			delete m_pPackage;
684
			m_pPackage = NULL;
685
		 }
686
private: System::Void toolStripButton4_Click(System::Object^  sender, System::EventArgs^  e) {
687
			 Split();
688
		 }
689
private: System::Void extractToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
690
			 if ( !m_pSelectedItem ) return;
691
			 Extract(m_pSelectedItem->SubItems[4]->Text);
692
		 }
693
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
694
			FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
695
			fbd->Description = "Select the path to extract packages to.";
696
			if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
697
			{
698
				bool success = false;
699
				for ( int i = 0; i < this->listView1->SelectedItems->Count; i++ )
700
				{
224 cycrow 701
					if ( m_pPackage->extractFile(_WS(this->listView1->SelectedItems[i]->SubItems[4]->Text), _WS(fbd->SelectedPath)) )
1 cycrow 702
						success = true;
703
				}
704
 
705
				if ( success )
706
					MessageBox::Show(this, "Packages have been extracted to:\n" + fbd->SelectedPath, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Information);
707
				else
708
					MessageBox::Show(this, "Failed to extract packages to:\n" + fbd->SelectedPath, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Error);
709
			}
710
		 }
711
};
712
}