Rev 173 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#pragma once#include <spk.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 PluginManager {/// <summary>/// Summary for EditGlobals////// 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 EditGlobals : public System::Windows::Forms::Form{public:EditGlobals(Utils::WStringList *globals){InitializeComponent();_pGlobals = globals;m_pSaved = new Utils::WStringList;UpdateList();}void UpdateList(){this->listView1->Items->Clear();for(auto itr = _pGlobals->begin(); itr != _pGlobals->end(); itr++){ListViewItem ^item = gcnew ListViewItem(_US((*itr)->str));item->SubItems->Add(_US((*itr)->data));this->listView1->Items->Add(item);}this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);}void SetEditedItem(String ^setting, String ^value){for ( int i = 0; i < this->listView1->Items->Count; i++ ){if ( String::Compare(this->listView1->Items[i]->Text, setting, true) == 0 ){this->listView1->Items[i]->SubItems[1]->Text = value;this->listView1->Items[i]->Checked = true;break;}}}void SaveList(){m_pSaved->clear();for ( int i = 0; i < this->listView1->Items->Count; i++ ){if ( !this->listView1->Items[i]->Checked )continue;// compare against savedUtils::WString data = _pGlobals->findString(_WS(this->listView1->Items[i]->Text));if (data.Compare(_WS(this->listView1->Items[i]->SubItems[1]->Text)) )continue;m_pSaved->pushBack(_WS(this->listView1->Items[i]->Text), _WS(this->listView1->Items[i]->SubItems[1]->Text));}}Utils::WStringList *GetSavedSettings() { return m_pSaved; }protected:/// <summary>/// Clean up any resources being used./// </summary>~EditGlobals(){if (components){delete components;}delete m_pSaved;}Utils::WStringList *_pGlobals;Utils::WStringList *m_pSaved;private: System::Windows::Forms::Panel^ panel1;protected:private: System::Windows::Forms::Button^ button2;private: System::Windows::Forms::Button^ button1;private: System::Windows::Forms::ListView^ listView1;private: System::Windows::Forms::ColumnHeader^ columnHeader1;private: System::Windows::Forms::ColumnHeader^ columnHeader2;private:/// <summary>/// Required designer variable./// </summary>System::ComponentModel::Container ^components;#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->panel1 = (gcnew System::Windows::Forms::Panel());this->button2 = (gcnew System::Windows::Forms::Button());this->button1 = (gcnew System::Windows::Forms::Button());this->listView1 = (gcnew System::Windows::Forms::ListView());this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());this->panel1->SuspendLayout();this->SuspendLayout();//// panel1//this->panel1->Controls->Add(this->button2);this->panel1->Controls->Add(this->button1);this->panel1->Dock = System::Windows::Forms::DockStyle::Bottom;this->panel1->Location = System::Drawing::Point(0, 481);this->panel1->Name = L"panel1";this->panel1->Size = System::Drawing::Size(423, 34);this->panel1->TabIndex = 0;//// button2//this->button2->DialogResult = System::Windows::Forms::DialogResult::Cancel;this->button2->Dock = System::Windows::Forms::DockStyle::Right;this->button2->Location = System::Drawing::Point(267, 0);this->button2->Name = L"button2";this->button2->Size = System::Drawing::Size(79, 34);this->button2->TabIndex = 1;this->button2->Text = L"Cancel";this->button2->UseVisualStyleBackColor = true;//// button1//this->button1->DialogResult = System::Windows::Forms::DialogResult::OK;this->button1->Dock = System::Windows::Forms::DockStyle::Right;this->button1->Location = System::Drawing::Point(346, 0);this->button1->Name = L"button1";this->button1->Size = System::Drawing::Size(77, 34);this->button1->TabIndex = 0;this->button1->Text = L"Save";this->button1->UseVisualStyleBackColor = true;this->button1->Click += gcnew System::EventHandler(this, &EditGlobals::button1_Click);//// listView1//this->listView1->CheckBoxes = true;this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(2) {this->columnHeader1, this->columnHeader2});this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;this->listView1->FullRowSelect = true;this->listView1->Location = System::Drawing::Point(0, 0);this->listView1->Name = L"listView1";this->listView1->Size = System::Drawing::Size(423, 481);this->listView1->TabIndex = 1;this->listView1->UseCompatibleStateImageBehavior = false;this->listView1->View = System::Windows::Forms::View::Details;this->listView1->MouseDoubleClick += gcnew System::Windows::Forms::MouseEventHandler(this, &EditGlobals::listView1_MouseDoubleClick);//// columnHeader1//this->columnHeader1->Text = L"Setting";//// columnHeader2//this->columnHeader2->Text = L"Data";//// EditGlobals//this->AcceptButton = this->button1;this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;this->CancelButton = this->button2;this->ClientSize = System::Drawing::Size(423, 515);this->Controls->Add(this->listView1);this->Controls->Add(this->panel1);this->Name = L"EditGlobals";this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;this->Text = L"Edit Globals (double click to change)";this->TopMost = true;this->panel1->ResumeLayout(false);this->ResumeLayout(false);}#pragma endregionprivate: System::Void listView1_MouseDoubleClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {Point ^mousePoint = this->listView1->PointToClient(this->listView1->MousePosition);ListViewItem ^item = this->listView1->GetItemAt(mousePoint->X, mousePoint->Y);if ( item ){InputBox ^input = gcnew InputBox("Enter the value you wish to use for:\n" + item->Text, item->SubItems[1]->Text);if ( input->ShowDialog(this) == Windows::Forms::DialogResult::OK ){item->SubItems[1]->Text = input->GetInput();item->Checked = true;}}}private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {SaveList();}};}