Rev 180 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
#include "../../common/listviewsorter.h"
namespace SpkExplorer {
/// <summary>
/// Summary for SpkForm
///
/// 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>
public ref class SpkForm : public System::Windows::Forms::Form
{
public:
SpkForm(System::Windows::Forms::Form ^parent, System::Windows::Forms::TabControl ^ctrl, System::Windows::Forms::TabPage ^page, CPackages *packages);
bool ReadSelectedMultiPackage();
bool ReadMultiPackage();
bool IsMultiPackage();
void SetToolButton(ToolStripMenuItem ^menu);
bool IsSelected();
bool IsPackageSelected();
void UpdateView(bool onlyPackage);
System::Windows::Forms::TabControl ^TabControl() { return m_pTabCtrl; }
System::Windows::Forms::TabPage ^TabPage() { return m_pTabPage; }
ToolStripMenuItem ^MenuItem() { return m_pMenuItem; }
bool CheckFilename(System::String ^filename);
void SetMultiPackage(CMultiSpkFile *p, System::String ^filename);
void SetPackage(CBaseFile *p, System::String ^filename);
void AddFile(C_File *file);
void AddMultiFile(SMultiSpkFile *file);
System::String ^GetExtractDir(bool package);
CBaseFile *GetPackage() { return m_pPackage; }
CMultiSpkFile *GetMultiPackage() { return m_pMultiPackage; }
void ChangeView(System::Windows::Forms::View view)
{
this->listView1->View = view;
}
void DroppedFile(C_File *file);
void DraggedFile(C_File *file);
void WritePackage();
bool ReadPackageFiles(bool all);
void PasteFiles(CLinkList<C_File> *list);
void RestoreCut(CLinkList<C_File> *file);
void RemoveItem(ListViewItem ^item);
void RemoveSelected();
void RemoveSelectedPackage();
void ExtractSelected(System::String ^toDir);
void ExtractSelectedPackage(System::String ^toDir);
void ExtractAll(System::String ^toDir);
void ExtractAllPackage(System::String ^toDir);
private: System::Windows::Forms::ContextMenuStrip^ contextMenuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ extractToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ ContextName;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1;
private: System::Windows::Forms::ImageList^ imageList1;
private: System::Windows::Forms::ToolStripMenuItem^ deleteToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator2;
private: System::Windows::Forms::ToolStripMenuItem^ ToolCopy;
private: System::Windows::Forms::ToolStripMenuItem^ ToolPaste;
private: System::Windows::Forms::ToolStripMenuItem^ ToolCut;
private: System::Windows::Forms::SplitContainer^ splitContainer1;
private: System::Windows::Forms::ListView^ listView2;
private: System::Windows::Forms::ColumnHeader^ columnHeader5;
private: System::Windows::Forms::ColumnHeader^ columnHeader6;
private: System::Windows::Forms::ColumnHeader^ columnHeader7;
private: System::Windows::Forms::ColumnHeader^ columnHeader8;
public:
protected:
System::String ^m_sFilename;
/// <summary>
/// Clean up any resources being used.
/// </summary>
~SpkForm();
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::ListView^ listView1;
private:
void AddImage(System::String ^filename, ImageList ^list, System::String ^key);
void SelectedCheck();
void DoExtract(CLinkList<C_File> *list, System::String ^toDir, int game);
void DoPackageExtract(CLinkList<SMultiSpkFile> *list, System::String ^toDir);
void CopyFile();
void CutFile();
void PasteFile();
void DropGetDirectories(String ^dir, Utils::WStringList *list, bool packages);
void RunFile(ListViewItem ^item);
ListViewItem ^FindSelectedItem();
C_File *GetFileFromItem(ListViewItem ^item);
System::Void OpenContextMenu(System::Object ^Sender, CancelEventArgs ^E);
System::Void DragEnterEvent(System::Object ^Sender, DragEventArgs ^E);
System::Void ItemDragEvent(System::Object ^Sender, ItemDragEventArgs ^E);
bool m_bSortingAsc;
int m_iSortingCol;
bool m_bSortingAsc2;
int m_iSortingCol2;
bool m_bLoading;
SMultiSpkFile *m_pSelectedPackage;
CBaseFile *m_pPackage;
CMultiSpkFile *m_pMultiPackage;
System::Windows::Forms::TabControl ^m_pTabCtrl;
System::Windows::Forms::TabPage ^m_pTabPage;
ListViewItem ^m_pListItem;
ToolStripMenuItem ^m_pMenuItem;
CPackages *_pPackages;
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(SpkForm::typeid));
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->columnHeader4 = (gcnew System::Windows::Forms::ColumnHeader());
this->contextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
this->ContextName = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->extractToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->deleteToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->ToolCut = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->ToolCopy = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->ToolPaste = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->imageList1 = (gcnew System::Windows::Forms::ImageList(this->components));
this->splitContainer1 = (gcnew System::Windows::Forms::SplitContainer());
this->listView2 = (gcnew System::Windows::Forms::ListView());
this->columnHeader5 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader6 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader7 = (gcnew System::Windows::Forms::ColumnHeader());
this->columnHeader8 = (gcnew System::Windows::Forms::ColumnHeader());
this->contextMenuStrip1->SuspendLayout();
this->splitContainer1->Panel1->SuspendLayout();
this->splitContainer1->Panel2->SuspendLayout();
this->splitContainer1->SuspendLayout();
this->SuspendLayout();
//
// listView1
//
this->listView1->AllowDrop = true;
this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(5) {this->columnHeader1, this->columnHeader2,
this->columnHeader3, this->columnHeader4, this->columnHeader8});
this->listView1->ContextMenuStrip = this->contextMenuStrip1;
this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
this->listView1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->listView1->FullRowSelect = true;
this->listView1->Location = System::Drawing::Point(0, 0);
this->listView1->Margin = System::Windows::Forms::Padding(20);
this->listView1->Name = L"listView1";
this->listView1->Size = System::Drawing::Size(458, 192);
this->listView1->TabIndex = 0;
this->listView1->TileSize = System::Drawing::Size(64, 64);
this->listView1->UseCompatibleStateImageBehavior = false;
this->listView1->View = System::Windows::Forms::View::Details;
this->listView1->VirtualListSize = 10;
this->listView1->MouseDoubleClick += gcnew System::Windows::Forms::MouseEventHandler(this, &SpkForm::listView1_MouseDoubleClick);
this->listView1->SelectedIndexChanged += gcnew System::EventHandler(this, &SpkForm::listView1_SelectedIndexChanged);
this->listView1->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &SpkForm::listView1_DragDrop);
//
// columnHeader1
//
this->columnHeader1->Text = L"File";
//
// columnHeader2
//
this->columnHeader2->Text = L"Size";
//
// columnHeader3
//
this->columnHeader3->Text = L"Type";
//
// columnHeader4
//
this->columnHeader4->Text = L"Last Modified";
//
// contextMenuStrip1
//
this->contextMenuStrip1->ImageScalingSize = System::Drawing::Size(24, 24);
this->contextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(8) {this->ContextName,
this->toolStripSeparator1, this->extractToolStripMenuItem, this->deleteToolStripMenuItem, this->toolStripSeparator2, this->ToolCut,
this->ToolCopy, this->ToolPaste});
this->contextMenuStrip1->Name = L"contextMenuStrip1";
this->contextMenuStrip1->Size = System::Drawing::Size(118, 196);
//
// ContextName
//
this->ContextName->Name = L"ContextName";
this->ContextName->Size = System::Drawing::Size(117, 30);
this->ContextName->Text = L"Name";
this->ContextName->Click += gcnew System::EventHandler(this, &SpkForm::ContextName_Click);
//
// toolStripSeparator1
//
this->toolStripSeparator1->Name = L"toolStripSeparator1";
this->toolStripSeparator1->Size = System::Drawing::Size(114, 6);
//
// extractToolStripMenuItem
//
this->extractToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"extractToolStripMenuItem.Image")));
this->extractToolStripMenuItem->Name = L"extractToolStripMenuItem";
this->extractToolStripMenuItem->Size = System::Drawing::Size(117, 30);
this->extractToolStripMenuItem->Text = L"Extract";
this->extractToolStripMenuItem->Click += gcnew System::EventHandler(this, &SpkForm::extractToolStripMenuItem_Click);
//
// deleteToolStripMenuItem
//
this->deleteToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"deleteToolStripMenuItem.Image")));
this->deleteToolStripMenuItem->Name = L"deleteToolStripMenuItem";
this->deleteToolStripMenuItem->Size = System::Drawing::Size(117, 30);
this->deleteToolStripMenuItem->Text = L"Delete";
this->deleteToolStripMenuItem->Click += gcnew System::EventHandler(this, &SpkForm::deleteToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this->toolStripSeparator2->Name = L"toolStripSeparator2";
this->toolStripSeparator2->Size = System::Drawing::Size(114, 6);
//
// ToolCut
//
this->ToolCut->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"ToolCut.Image")));
this->ToolCut->Name = L"ToolCut";
this->ToolCut->Size = System::Drawing::Size(117, 30);
this->ToolCut->Text = L"Cut";
this->ToolCut->Click += gcnew System::EventHandler(this, &SpkForm::ToolCut_Click);
//
// ToolCopy
//
this->ToolCopy->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"ToolCopy.Image")));
this->ToolCopy->Name = L"ToolCopy";
this->ToolCopy->Size = System::Drawing::Size(117, 30);
this->ToolCopy->Text = L"Copy";
this->ToolCopy->Click += gcnew System::EventHandler(this, &SpkForm::ToolCopy_Click);
//
// ToolPaste
//
this->ToolPaste->Enabled = false;
this->ToolPaste->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"ToolPaste.Image")));
this->ToolPaste->Name = L"ToolPaste";
this->ToolPaste->Size = System::Drawing::Size(117, 30);
this->ToolPaste->Text = L"Paste";
this->ToolPaste->Click += gcnew System::EventHandler(this, &SpkForm::ToolPaste_Click);
//
// imageList1
//
this->imageList1->ImageStream = (cli::safe_cast<System::Windows::Forms::ImageListStreamer^ >(resources->GetObject(L"imageList1.ImageStream")));
this->imageList1->TransparentColor = System::Drawing::Color::Transparent;
this->imageList1->Images->SetKeyName(0, L"advert.png");
this->imageList1->Images->SetKeyName(1, L"backup.png");
this->imageList1->Images->SetKeyName(2, L"cockpitscene.png");
this->imageList1->Images->SetKeyName(3, L"extras.png");
this->imageList1->Images->SetKeyName(4, L"map.png");
this->imageList1->Images->SetKeyName(5, L"mission.png");
this->imageList1->Images->SetKeyName(6, L"mods.png");
this->imageList1->Images->SetKeyName(7, L"readme.png");
this->imageList1->Images->SetKeyName(8, L"screenshot.png");
this->imageList1->Images->SetKeyName(9, L"script.png");
this->imageList1->Images->SetKeyName(10, L"shipmodel.png");
this->imageList1->Images->SetKeyName(11, L"shipother.png");
this->imageList1->Images->SetKeyName(12, L"shipscene.png");
this->imageList1->Images->SetKeyName(13, L"sound.png");
this->imageList1->Images->SetKeyName(14, L"textfile.png");
this->imageList1->Images->SetKeyName(15, L"uninstall.png");
this->imageList1->Images->SetKeyName(16, L"package");
//
// splitContainer1
//
this->splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill;
this->splitContainer1->Location = System::Drawing::Point(0, 0);
this->splitContainer1->Name = L"splitContainer1";
this->splitContainer1->Orientation = System::Windows::Forms::Orientation::Horizontal;
//
// splitContainer1.Panel1
//
this->splitContainer1->Panel1->Controls->Add(this->listView2);
//
// splitContainer1.Panel2
//
this->splitContainer1->Panel2->Controls->Add(this->listView1);
this->splitContainer1->Size = System::Drawing::Size(458, 391);
this->splitContainer1->SplitterDistance = 195;
this->splitContainer1->TabIndex = 1;
//
// listView2
//
this->listView2->AllowDrop = true;
this->listView2->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(3) {this->columnHeader5, this->columnHeader6,
this->columnHeader7});
this->listView2->ContextMenuStrip = this->contextMenuStrip1;
this->listView2->Dock = System::Windows::Forms::DockStyle::Fill;
this->listView2->FullRowSelect = true;
this->listView2->HideSelection = false;
this->listView2->LargeImageList = this->imageList1;
this->listView2->Location = System::Drawing::Point(0, 0);
this->listView2->Name = L"listView2";
this->listView2->Size = System::Drawing::Size(458, 195);
this->listView2->SmallImageList = this->imageList1;
this->listView2->TabIndex = 0;
this->listView2->UseCompatibleStateImageBehavior = false;
this->listView2->View = System::Windows::Forms::View::Details;
this->listView2->SelectedIndexChanged += gcnew System::EventHandler(this, &SpkForm::listView2_SelectedIndexChanged);
this->listView2->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &SpkForm::listView2_DragDrop);
this->listView2->ColumnClick += gcnew System::Windows::Forms::ColumnClickEventHandler(this, &SpkForm::listView2_ColumnClick);
this->listView2->DragOver += gcnew System::Windows::Forms::DragEventHandler(this, &SpkForm::listView2_DragOver);
//
// columnHeader5
//
this->columnHeader5->Text = L"Filename";
//
// columnHeader6
//
this->columnHeader6->Text = L"File Type";
//
// columnHeader7
//
this->columnHeader7->Text = L"Size";
//
// columnHeader8
//
this->columnHeader8->Text = L"Game";
//
// SpkForm
//
this->AllowDrop = true;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->AutoValidate = System::Windows::Forms::AutoValidate::EnableAllowFocusChange;
this->ClientSize = System::Drawing::Size(458, 391);
this->Controls->Add(this->splitContainer1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Name = L"SpkForm";
this->ShowIcon = false;
this->ShowInTaskbar = false;
this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Hide;
this->Text = L"SpkForm";
this->contextMenuStrip1->ResumeLayout(false);
this->splitContainer1->Panel1->ResumeLayout(false);
this->splitContainer1->Panel2->ResumeLayout(false);
this->splitContainer1->ResumeLayout(false);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void Event_Activated(System::Object^ sender, System::EventArgs^ e);
private: System::Void Event_Closing(System::Object^ sender, CancelEventArgs^ e);
private: System::Void SortList(System::Object ^Sender, ColumnClickEventArgs ^E)
{
if ( E->Column == m_iSortingCol )
{
m_bSortingAsc = !m_bSortingAsc;
this->listView1->ListViewItemSorter = gcnew ListViewItemComparer(E->Column, !m_bSortingAsc);
}
else
{
m_bSortingAsc = true;
this->listView1->ListViewItemSorter = gcnew ListViewItemComparer(E->Column, !m_bSortingAsc);
}
this->listView1->Sort();
m_iSortingCol = E->Column;
}
private: System::Void listView1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
this->SelectedCheck();
}
private: System::Void extractToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
if ( !m_pListItem )
return;
C_File *f = this->GetFileFromItem(m_pListItem);
if ( f )
{
CLinkList<C_File> list;
list.push_back(f);
this->DoExtract(&list, this->GetExtractDir(false), -1);
list.clear();
}
}
private: System::Void ToolCopy_Click(System::Object^ sender, System::EventArgs^ e) {
this->CopyFile();
}
private: System::Void ToolPaste_Click(System::Object^ sender, System::EventArgs^ e) {
this->PasteFile();
}
private: System::Void ToolCut_Click(System::Object^ sender, System::EventArgs^ e) {
this->CutFile();
}
private: System::Void listView1_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e);
private: System::Void ContextName_Click(System::Object^ sender, System::EventArgs^ e) {
this->RunFile(m_pListItem);
}
private: System::Void listView1_MouseDoubleClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
Point ^mousePoint = this->listView1->PointToClient(this->listView1->MousePosition);
this->RunFile(this->listView1->GetItemAt(mousePoint->X, mousePoint->Y));
}
private: System::Void listView2_ColumnClick(System::Object^ sender, System::Windows::Forms::ColumnClickEventArgs^ E) {
if ( E->Column == m_iSortingCol2 )
{
m_bSortingAsc2 = !m_bSortingAsc2;
this->listView2->ListViewItemSorter = gcnew ListViewItemComparer(E->Column, !m_bSortingAsc2);
}
else
{
m_bSortingAsc2 = true;
this->listView2->ListViewItemSorter = gcnew ListViewItemComparer(E->Column, !m_bSortingAsc2);
}
this->listView2->Sort();
m_iSortingCol2 = E->Column;
}
private: System::Void listView2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
this->SelectedCheck();
}
private: System::Void listView2_DragOver(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e) {
e->Effect = DragDropEffects::None;
if ( e->Data->GetDataPresent(DataFormats::FileDrop) )
{
cli::array<String ^> ^a = (cli::array<String ^> ^)e->Data->GetData(DataFormats::FileDrop, false);
int i;
for(i = 0; i < a->Length; i++)
{
if ( String::Compare(IO::FileInfo(a[i]).Extension, ".xsp", true) == 0 || String::Compare(IO::FileInfo(a[i]).Extension, ".spk", true) == 0 )
{
e->Effect = DragDropEffects::Copy;
break;
}
}
}
}
private: System::Void listView2_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e);
private: System::Void deleteToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
if ( !m_pListItem )
return;
this->RemoveItem(m_pListItem);
}
};
}