Rev 177 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#pragma once
#include "BaseForm.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace Creator {
/// <summary>
/// Summary for MultiForm1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
// remove before build
//#define DESIGNER
#ifdef DESIGNER
public ref class MultiForm : public System::Windows::Forms::Form
#else
public ref class MultiForm : public BaseForm
#endif
{
public:
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)
{
InitializeComponent();
m_iFormType = FORMTYPE_MULTI;
this->listView1->SmallImageList = this->imageList1;
this->listView1->LargeImageList = this->imageList1;
m_pTabPage->ImageIndex = this->imageList1->Images->IndexOfKey("multi");
m_pMenuItem->Image = this->imageList1->Images[m_pTabPage->ImageIndex];
}
bool LoadPackage(CMultiSpkFile *base, System::String ^filename);
CMultiSpkFile *GetPackage() { return m_pPackage; }
void AddPackage()
{
OpenFileDialog ^ofd = gcnew OpenFileDialog();
ofd->Filter = "All (*.spk *.xsp)|*.spk;*.xsp|Package Files (*.spk)|*.spk|Ship Files (*.xsp)|*.xsp";
ofd->FilterIndex = 1;
ofd->RestoreDirectory = true;
ofd->Multiselect = true;
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
AddPackages(ofd->FileNames);
}
void AddPackages(cli::array<System::String ^> ^list)
{
String ^str;
for ( int i = 0; i < list->Length; i++ )
{
if ( !AddPackage(list[i], false) )
{
if ( str )
str += "\n";
str += list[i];
}
}
if ( str )
{
MessageBox::Show(this, "Unable to add package files:\n" + str, "Add Package", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
this->UpdatePackages();
this->UpdateChanged();
}
bool AddPackage(String ^file, bool single)
{
if ( m_pPackage->addFile(_S(file)) )
{
if ( single )
{
this->UpdatePackages();
this->UpdateChanged();
MessageBox::Show(this, "Unable to add package file: " + file, "Add Package", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
return true;
}
return false;
}
void UpdateChanged()
{
if ( m_bLoading )
return;
if ( !m_pPackage )
return;
if ( m_pPackage->isChanged() )
{
if (!m_pPackage->filename().empty())
this->Text = _US(m_pPackage->filename()) + "*";
if ( m_pTabPage->Text[m_pTabPage->Text->Length - 1] != '*' )
m_pTabPage->Text += "*";
}
else
{
this->Text = _US(m_pPackage->filename());
if ( m_pTabPage->Text[m_pTabPage->Text->Length - 1] == '*' )
m_pTabPage->Text = m_pTabPage->Text->Remove(m_pTabPage->Text->Length - 1);
}
}
virtual void Save() new;
virtual void SaveAs() new;
bool CheckSave();
void CreatePackage()
{
if ( m_pPackage ) delete m_pPackage;
m_pPackage = new CMultiSpkFile;
}
void Split(String ^dest)
{
if ( m_pPackage->extractAll(_S(dest)) )
MessageBox::Show(this, "All Packages have been extracted to:\n" + dest, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Information);
else
MessageBox::Show(this, "Failed to extract Packages to:\n" + dest, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
void Split()
{
FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
fbd->Description = "Select the path to split the multi package to";
if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
Split(fbd->SelectedPath);
}
void Extract(String ^file, String ^to)
{
if ( m_pPackage->extractFile(_S(file), _S(to)) )
MessageBox::Show(this, "Package: " + file + "\nHas been extracted to: " + to, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Information);
else
MessageBox::Show(this, "Package: " + file + "\nFailed to extract to: " + to, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
void Extract(String ^file)
{
FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
fbd->Description = "Select the path to extract " + file + " to.";
if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
Extract(file, fbd->SelectedPath);
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MultiForm()
{
if (components)
{
delete components;
}
}
private:
void UpdateView();
void UpdatePackages();
CMultiSpkFile *m_pPackage;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Panel^ panel1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::ToolStrip^ toolStrip1;
private: System::Windows::Forms::ToolStripButton^ toolStripButton1;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::ListView^ listView1;
private: System::Windows::Forms::Panel^ panel2;
private: System::Windows::Forms::CheckBox^ checkBox1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::ColumnHeader^ columnHeader1;
private: System::Windows::Forms::ColumnHeader^ columnHeader2;
private: System::Windows::Forms::ColumnHeader^ columnHeader3;
private: System::Windows::Forms::ColumnHeader^ columnHeader4;
private: System::Windows::Forms::ColumnHeader^ columnHeader5;
private: System::Windows::Forms::ColumnHeader^ columnHeader6;
private: System::Windows::Forms::ContextMenuStrip^ contextMenuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ addPackageToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1;
private: System::Windows::Forms::ToolStripMenuItem^ removeFileToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ clearAllToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator2;
private: System::Windows::Forms::ToolStripButton^ toolStripButton2;
private: System::Windows::Forms::ToolStripButton^ toolStripButton3;
private: System::Windows::Forms::Panel^ panel3;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator3;
private: System::Windows::Forms::ToolStripButton^ toolStripButton4;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator4;
private: System::Windows::Forms::ToolStripMenuItem^ extractToolStripMenuItem;
private: System::Windows::Forms::Button^ button2;
private: System::ComponentModel::IContainer^ components;
/// <summary>
/// Required designer variable.
/// </summary>
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MultiForm::typeid));
this->label1 = (gcnew System::Windows::Forms::Label());
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripButton3 = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripSeparator3 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->toolStripButton4 = (gcnew System::Windows::Forms::ToolStripButton());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->listView1 = (gcnew System::Windows::Forms::ListView());
this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader5 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader4 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader6 = (gcnew System::Windows::Forms::ColumnHeader());
this->contextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
this->addPackageToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->removeFileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->clearAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStripSeparator4 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->extractToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->panel3 = (gcnew System::Windows::Forms::Panel());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button1 = (gcnew System::Windows::Forms::Button());
this->panel2 = (gcnew System::Windows::Forms::Panel());
this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
this->label2 = (gcnew System::Windows::Forms::Label());
this->panel1->SuspendLayout();
this->toolStrip1->SuspendLayout();
this->groupBox1->SuspendLayout();
this->contextMenuStrip1->SuspendLayout();
this->panel3->SuspendLayout();
this->panel2->SuspendLayout();
this->SuspendLayout();
//
// label1
//
this->label1->Dock = System::Windows::Forms::DockStyle::Left;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(5, 5);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(157, 21);
this->label1->TabIndex = 0;
this->label1->Text = L"Multi Pack Name";
//
// panel1
//
this->panel1->Controls->Add(this->textBox1);
this->panel1->Controls->Add(this->label1);
this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
this->panel1->Location = System::Drawing::Point(0, 31);
this->panel1->Name = L"panel1";
this->panel1->Padding = System::Windows::Forms::Padding(5);
this->panel1->Size = System::Drawing::Size(596, 31);
this->panel1->TabIndex = 1;
//
// textBox1
//
this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill;
this->textBox1->Location = System::Drawing::Point(162, 5);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(429, 20);
this->textBox1->TabIndex = 1;
this->textBox1->TextChanged += gcnew System::EventHandler(this, &MultiForm::textBox1_TextChanged);
//
// toolStrip1
//
this->toolStrip1->GripStyle = System::Windows::Forms::ToolStripGripStyle::Hidden;
this->toolStrip1->ImageScalingSize = System::Drawing::Size(24, 24);
this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(6) {this->toolStripButton1,
this->toolStripSeparator2, this->toolStripButton2, this->toolStripButton3, this->toolStripSeparator3, this->toolStripButton4});
this->toolStrip1->Location = System::Drawing::Point(0, 0);
this->toolStrip1->Name = L"toolStrip1";
this->toolStrip1->Size = System::Drawing::Size(596, 31);
this->toolStrip1->TabIndex = 2;
this->toolStrip1->Text = L"toolStrip1";
//
// toolStripButton1
//
this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton1.Image")));
this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripButton1->Name = L"toolStripButton1";
this->toolStripButton1->Size = System::Drawing::Size(104, 28);
this->toolStripButton1->Text = L"Add Package";
this->toolStripButton1->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton1_Click);
//
// toolStripSeparator2
//
this->toolStripSeparator2->Name = L"toolStripSeparator2";
this->toolStripSeparator2->Size = System::Drawing::Size(6, 31);
//
// toolStripButton2
//
this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton2.Image")));
this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripButton2->Name = L"toolStripButton2";
this->toolStripButton2->Size = System::Drawing::Size(59, 28);
this->toolStripButton2->Text = L"Save";
this->toolStripButton2->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton2_Click);
//
// toolStripButton3
//
this->toolStripButton3->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton3.Image")));
this->toolStripButton3->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripButton3->Name = L"toolStripButton3";
this->toolStripButton3->Size = System::Drawing::Size(75, 28);
this->toolStripButton3->Text = L"Save As";
this->toolStripButton3->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton3_Click);
//
// toolStripSeparator3
//
this->toolStripSeparator3->Name = L"toolStripSeparator3";
this->toolStripSeparator3->Size = System::Drawing::Size(6, 31);
//
// toolStripButton4
//
this->toolStripButton4->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton4.Image")));
this->toolStripButton4->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripButton4->Name = L"toolStripButton4";
this->toolStripButton4->Size = System::Drawing::Size(58, 28);
this->toolStripButton4->Text = L"Split";
this->toolStripButton4->Click += gcnew System::EventHandler(this, &MultiForm::toolStripButton4_Click);
//
// groupBox1
//
this->groupBox1->Controls->Add(this->listView1);
this->groupBox1->Controls->Add(this->panel3);
this->groupBox1->Dock = System::Windows::Forms::DockStyle::Fill;
this->groupBox1->Location = System::Drawing::Point(0, 93);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Padding = System::Windows::Forms::Padding(6);
this->groupBox1->Size = System::Drawing::Size(596, 429);
this->groupBox1->TabIndex = 3;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"Packages";
//
// listView1
//
this->listView1->CheckBoxes = true;
this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(6) {this->columnHeader1, this->columnHeader2,
this->columnHeader3, this->columnHeader5, this->columnHeader4, this->columnHeader6});
this->listView1->ContextMenuStrip = this->contextMenuStrip1;
this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
this->listView1->FullRowSelect = true;
this->listView1->HideSelection = false;
this->listView1->Location = System::Drawing::Point(6, 19);
this->listView1->Name = L"listView1";
this->listView1->Size = System::Drawing::Size(584, 373);
this->listView1->TabIndex = 0;
this->listView1->UseCompatibleStateImageBehavior = false;
this->listView1->View = System::Windows::Forms::View::Details;
this->listView1->ItemChecked += gcnew System::Windows::Forms::ItemCheckedEventHandler(this, &MultiForm::listView1_ItemChecked);
this->listView1->SelectedIndexChanged += gcnew System::EventHandler(this, &MultiForm::listView1_SelectedIndexChanged);
//
// columnHeader1
//
this->columnHeader1->Text = L"Type";
//
// columnHeader2
//
this->columnHeader2->Text = L"Name";
//
// columnHeader3
//
this->columnHeader3->Text = L"Author";
//
// columnHeader5
//
this->columnHeader5->Text = L"Version";
//
// columnHeader4
//
this->columnHeader4->Text = L"Filename";
//
// columnHeader6
//
this->columnHeader6->Text = L"Size";
//
// contextMenuStrip1
//
this->contextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(6) {this->addPackageToolStripMenuItem,
this->toolStripSeparator1, this->removeFileToolStripMenuItem, this->clearAllToolStripMenuItem, this->toolStripSeparator4, this->extractToolStripMenuItem});
this->contextMenuStrip1->Name = L"contextMenuStrip1";
this->contextMenuStrip1->Size = System::Drawing::Size(152, 136);
this->contextMenuStrip1->Opening += gcnew System::ComponentModel::CancelEventHandler(this, &MultiForm::contextMenuStrip1_Opening);
//
// addPackageToolStripMenuItem
//
this->addPackageToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"addPackageToolStripMenuItem.Image")));
this->addPackageToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
this->addPackageToolStripMenuItem->Name = L"addPackageToolStripMenuItem";
this->addPackageToolStripMenuItem->Size = System::Drawing::Size(151, 30);
this->addPackageToolStripMenuItem->Text = L"Add Package";
this->addPackageToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::addPackageToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this->toolStripSeparator1->Name = L"toolStripSeparator1";
this->toolStripSeparator1->Size = System::Drawing::Size(148, 6);
//
// removeFileToolStripMenuItem
//
this->removeFileToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"removeFileToolStripMenuItem.Image")));
this->removeFileToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
this->removeFileToolStripMenuItem->Name = L"removeFileToolStripMenuItem";
this->removeFileToolStripMenuItem->Size = System::Drawing::Size(151, 30);
this->removeFileToolStripMenuItem->Text = L"Remove File";
this->removeFileToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::removeFileToolStripMenuItem_Click);
//
// clearAllToolStripMenuItem
//
this->clearAllToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"clearAllToolStripMenuItem.Image")));
this->clearAllToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
this->clearAllToolStripMenuItem->Name = L"clearAllToolStripMenuItem";
this->clearAllToolStripMenuItem->Size = System::Drawing::Size(151, 30);
this->clearAllToolStripMenuItem->Text = L"Clear All";
this->clearAllToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::clearAllToolStripMenuItem_Click);
//
// toolStripSeparator4
//
this->toolStripSeparator4->Name = L"toolStripSeparator4";
this->toolStripSeparator4->Size = System::Drawing::Size(148, 6);
//
// extractToolStripMenuItem
//
this->extractToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"extractToolStripMenuItem.Image")));
this->extractToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
this->extractToolStripMenuItem->Name = L"extractToolStripMenuItem";
this->extractToolStripMenuItem->Size = System::Drawing::Size(151, 30);
this->extractToolStripMenuItem->Text = L"Extract";
this->extractToolStripMenuItem->Click += gcnew System::EventHandler(this, &MultiForm::extractToolStripMenuItem_Click);
//
// panel3
//
this->panel3->Controls->Add(this->button2);
this->panel3->Controls->Add(this->button1);
this->panel3->Dock = System::Windows::Forms::DockStyle::Bottom;
this->panel3->Location = System::Drawing::Point(6, 392);
this->panel3->Name = L"panel3";
this->panel3->Size = System::Drawing::Size(584, 31);
this->panel3->TabIndex = 1;
//
// button2
//
this->button2->Dock = System::Windows::Forms::DockStyle::Right;
this->button2->Enabled = false;
this->button2->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button2.Image")));
this->button2->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->button2->Location = System::Drawing::Point(265, 0);
this->button2->Name = L"button2";
this->button2->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
this->button2->Size = System::Drawing::Size(143, 31);
this->button2->TabIndex = 1;
this->button2->Text = L"Extract Selected";
this->button2->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->button2->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MultiForm::button2_Click);
//
// button1
//
this->button1->Dock = System::Windows::Forms::DockStyle::Right;
this->button1->Enabled = false;
this->button1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button1.Image")));
this->button1->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->button1->Location = System::Drawing::Point(408, 0);
this->button1->Name = L"button1";
this->button1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
this->button1->Size = System::Drawing::Size(176, 31);
this->button1->TabIndex = 0;
this->button1->Text = L"Remove Selected";
this->button1->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MultiForm::button1_Click);
//
// panel2
//
this->panel2->Controls->Add(this->checkBox1);
this->panel2->Controls->Add(this->label2);
this->panel2->Dock = System::Windows::Forms::DockStyle::Top;
this->panel2->Location = System::Drawing::Point(0, 62);
this->panel2->Name = L"panel2";
this->panel2->Padding = System::Windows::Forms::Padding(5);
this->panel2->Size = System::Drawing::Size(596, 31);
this->panel2->TabIndex = 4;
//
// checkBox1
//
this->checkBox1->AutoSize = true;
this->checkBox1->Dock = System::Windows::Forms::DockStyle::Fill;
this->checkBox1->Location = System::Drawing::Point(162, 5);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(429, 21);
this->checkBox1->TabIndex = 1;
this->checkBox1->UseVisualStyleBackColor = true;
this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &MultiForm::checkBox1_CheckedChanged);
//
// label2
//
this->label2->Dock = System::Windows::Forms::DockStyle::Left;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(5, 5);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(157, 21);
this->label2->TabIndex = 0;
this->label2->Text = L"Allow Selection";
//
// MultiForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(596, 522);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->panel2);
this->Controls->Add(this->panel1);
this->Controls->Add(this->toolStrip1);
this->Name = L"MultiForm";
this->Text = L"MultiForm";
this->Load += gcnew System::EventHandler(this, &MultiForm::MultiForm_Load);
this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &MultiForm::MultiForm_FormClosing);
this->panel1->ResumeLayout(false);
this->panel1->PerformLayout();
this->toolStrip1->ResumeLayout(false);
this->toolStrip1->PerformLayout();
this->groupBox1->ResumeLayout(false);
this->contextMenuStrip1->ResumeLayout(false);
this->panel3->ResumeLayout(false);
this->panel2->ResumeLayout(false);
this->panel2->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void MultiForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void toolStripButton1_Click(System::Object^ sender, System::EventArgs^ e) {
AddPackage();
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
m_pPackage->setName(_S(this->textBox1->Text));
this->UpdateChanged();
}
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
m_pPackage->setSelection(this->checkBox1->Checked);
this->UpdateChanged();
}
private: System::Void contextMenuStrip1_Opening(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) {
Point ^mousePoint = this->listView1->PointToClient(this->listView1->MousePosition);
m_pSelectedItem = this->listView1->GetItemAt(mousePoint->X, mousePoint->Y);
bool show = (m_pSelectedItem) ? true : false;
this->extractToolStripMenuItem->Visible = show;
this->toolStripSeparator1->Visible = show;
this->removeFileToolStripMenuItem->Visible = show;
this->clearAllToolStripMenuItem->Visible = show;
this->toolStripSeparator4->Visible = show;
}
private: System::Void addPackageToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
AddPackage();
}
private: System::Void removeFileToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
if ( !m_pSelectedItem ) return;
m_pPackage->markRemoveFile(_WS(m_pSelectedItem->SubItems[4]->Text));
this->UpdatePackages();
this->UpdateChanged();
}
private: System::Void clearAllToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
if ( !m_pSelectedItem ) return;
m_pPackage->markRemoveAll();
this->UpdatePackages();
this->UpdateChanged();
}
private: System::Void toolStripButton2_Click(System::Object^ sender, System::EventArgs^ e) {
Save();
}
private: System::Void toolStripButton3_Click(System::Object^ sender, System::EventArgs^ e) {
SaveAs();
}
private: System::Void listView1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
this->button1->Enabled = (this->listView1->SelectedItems->Count) ? true : false;
this->button2->Enabled = (this->listView1->SelectedItems->Count) ? true : false;
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
for ( int i = 0; i < this->listView1->SelectedItems->Count; i++ )
{
m_pPackage->markRemoveFile(_WS(this->listView1->SelectedItems[i]->SubItems[4]->Text));
}
this->UpdatePackages();
this->UpdateChanged();
}
private: System::Void listView1_ItemChecked(System::Object^ sender, System::Windows::Forms::ItemCheckedEventArgs^ e) {
if ( m_bLoading ) return;
ListViewItem ^item = e->Item;
if ( item && item->SubItems->Count > 4 )
{
const SMultiSpkFile *ms = m_pPackage->findFile(_S(item->SubItems[4]->Text));
if ( ms )
{
const_cast<SMultiSpkFile *>(ms)->bOn = item->Checked;
m_pPackage->setChanged(true);
this->UpdateChanged();
}
}
}
private: System::Void MultiForm_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e) {
if (m_pPackage->isChanged())
{
String ^name = m_pTabPage->Text;
if ( name[name->Length - 1] == '*' )
name = name->Remove(name->Length - 1);
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);
if ( result == System::Windows::Forms::DialogResult::Cancel )
{
e->Cancel = true;
return;
}
else if ( result == System::Windows::Forms::DialogResult::Yes )
{
if ( !this->CheckSave() )
{
e->Cancel = true;
return;
}
if (m_pPackage->filename().empty())
{
SaveFileDialog ^ofd = gcnew SaveFileDialog();
ofd->Filter = "Multi-Package Files (*.spk)|*.spk";
ofd->FilterIndex = 1;
ofd->RestoreDirectory = true;
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
m_pPackage->setFilename(_S(ofd->FileName));
else
{
e->Cancel = true;
return;
}
}
if (!m_pPackage->writeFile(m_pPackage->filename()))
{
e->Cancel = true;
MessageBox::Show("Unable to save package\n" + _US(m_pPackage->filename()), "Save Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
return;
}
}
}
delete m_pPackage;
m_pPackage = NULL;
}
private: System::Void toolStripButton4_Click(System::Object^ sender, System::EventArgs^ e) {
Split();
}
private: System::Void extractToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
if ( !m_pSelectedItem ) return;
Extract(m_pSelectedItem->SubItems[4]->Text);
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
fbd->Description = "Select the path to extract packages to.";
if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
{
bool success = false;
for ( int i = 0; i < this->listView1->SelectedItems->Count; i++ )
{
if ( m_pPackage->extractFile(_S(this->listView1->SelectedItems[i]->SubItems[4]->Text), _S(fbd->SelectedPath)) )
success = true;
}
if ( success )
MessageBox::Show(this, "Packages have been extracted to:\n" + fbd->SelectedPath, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Information);
else
MessageBox::Show(this, "Failed to extract packages to:\n" + fbd->SelectedPath, "Package Extracted", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
}
};
}