2
0

dataEditor.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #pragma once
  2. #include "data.h"
  3. #include <cliext/vector>
  4. using namespace System;
  5. using namespace System::ComponentModel;
  6. using namespace System::Collections;
  7. using namespace System::Windows::Forms;
  8. using namespace System::Data;
  9. using namespace System::Drawing;
  10. namespace Wpasuj {
  11. /// <summary>
  12. /// Summary for dataEditor
  13. ///
  14. /// WARNING: If you change the name of this class, you will need to change the
  15. /// 'Resource File Name' property for the managed resource compiler tool
  16. /// associated with all .resx files this class depends on. Otherwise,
  17. /// the designers will not be able to interact properly with localized
  18. /// resources associated with this form.
  19. /// </summary>
  20. public ref class dataEditor : public System::Windows::Forms::Form
  21. {
  22. public:
  23. dataEditor(cliext::vector<CBuildingData^> ^Data)
  24. {
  25. data = Data;
  26. InitializeComponent();
  27. dataGridView1->Rows->Add(data->size());
  28. for (int i=0;i<data->size();i++)
  29. {
  30. dataGridView1->Rows[i]->Cells[0]->Value = data->at(i)->townID;
  31. dataGridView1->Rows[i]->Cells[1]->Value = data->at(i)->ID;
  32. dataGridView1->Rows[i]->Cells[2]->Value = data->at(i)->defname;
  33. dataGridView1->Rows[i]->Cells[3]->Value = data->at(i)->x;
  34. dataGridView1->Rows[i]->Cells[4]->Value = data->at(i)->y;
  35. }
  36. }
  37. private: System::Windows::Forms::DataGridViewTextBoxColumn^ townid;
  38. public:
  39. private: System::Windows::Forms::DataGridViewTextBoxColumn^ buildingID;
  40. private: System::Windows::Forms::DataGridViewTextBoxColumn^ defname;
  41. private: System::Windows::Forms::DataGridViewTextBoxColumn^ x;
  42. private: System::Windows::Forms::DataGridViewTextBoxColumn^ y;
  43. private: System::Windows::Forms::Button^ save;
  44. private: System::Windows::Forms::Button^ clear;
  45. private: System::Windows::Forms::Button^ close;
  46. private:
  47. cliext::vector<CBuildingData^> ^data;
  48. protected:
  49. /// <summary>
  50. /// Clean up any resources being used.
  51. /// </summary>
  52. ~dataEditor()
  53. {
  54. if (components)
  55. {
  56. delete components;
  57. }
  58. }
  59. private: System::Windows::Forms::DataGridView^ dataGridView1;
  60. protected:
  61. protected:
  62. private:
  63. /// <summary>
  64. /// Required designer variable.
  65. /// </summary>
  66. System::ComponentModel::Container ^components;
  67. #pragma region Windows Form Designer generated code
  68. /// <summary>
  69. /// Required method for Designer support - do not modify
  70. /// the contents of this method with the code editor.
  71. /// </summary>
  72. void InitializeComponent(void)
  73. {
  74. this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
  75. this->townid = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  76. this->buildingID = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  77. this->defname = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  78. this->x = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  79. this->y = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
  80. this->save = (gcnew System::Windows::Forms::Button());
  81. this->clear = (gcnew System::Windows::Forms::Button());
  82. this->close = (gcnew System::Windows::Forms::Button());
  83. (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->BeginInit();
  84. this->SuspendLayout();
  85. //
  86. // dataGridView1
  87. //
  88. this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  89. this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(5) {this->townid,
  90. this->buildingID, this->defname, this->x, this->y});
  91. this->dataGridView1->Location = System::Drawing::Point(12, 12);
  92. this->dataGridView1->Name = L"dataGridView1";
  93. this->dataGridView1->Size = System::Drawing::Size(334, 276);
  94. this->dataGridView1->TabIndex = 0;
  95. //
  96. // townid
  97. //
  98. this->townid->HeaderText = L"Town ID";
  99. this->townid->Name = L"townid";
  100. this->townid->Width = 50;
  101. //
  102. // buildingID
  103. //
  104. this->buildingID->HeaderText = L"Building ID";
  105. this->buildingID->Name = L"buildingID";
  106. this->buildingID->Width = 60;
  107. //
  108. // defname
  109. //
  110. this->defname->HeaderText = L"Def name";
  111. this->defname->Name = L"defname";
  112. this->defname->Width = 120;
  113. //
  114. // x
  115. //
  116. this->x->HeaderText = L"X";
  117. this->x->Name = L"x";
  118. this->x->Width = 30;
  119. //
  120. // y
  121. //
  122. this->y->HeaderText = L"Y";
  123. this->y->Name = L"y";
  124. this->y->Width = 30;
  125. //
  126. // save
  127. //
  128. this->save->Location = System::Drawing::Point(12, 294);
  129. this->save->Name = L"save";
  130. this->save->Size = System::Drawing::Size(105, 23);
  131. this->save->TabIndex = 1;
  132. this->save->Text = L"Save changes";
  133. this->save->UseVisualStyleBackColor = true;
  134. this->save->Click += gcnew System::EventHandler(this, &dataEditor::save_Click);
  135. //
  136. // clear
  137. //
  138. this->clear->Location = System::Drawing::Point(248, 294);
  139. this->clear->Name = L"clear";
  140. this->clear->Size = System::Drawing::Size(96, 23);
  141. this->clear->TabIndex = 2;
  142. this->clear->Text = L"Clear changes";
  143. this->clear->UseVisualStyleBackColor = true;
  144. this->clear->Click += gcnew System::EventHandler(this, &dataEditor::clear_Click);
  145. //
  146. // close
  147. //
  148. this->close->Location = System::Drawing::Point(123, 294);
  149. this->close->Name = L"close";
  150. this->close->Size = System::Drawing::Size(119, 23);
  151. this->close->TabIndex = 3;
  152. this->close->Text = L"Close";
  153. this->close->UseVisualStyleBackColor = true;
  154. this->close->Click += gcnew System::EventHandler(this, &dataEditor::close_Click);
  155. //
  156. // dataEditor
  157. //
  158. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  159. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  160. this->ClientSize = System::Drawing::Size(356, 328);
  161. this->Controls->Add(this->close);
  162. this->Controls->Add(this->clear);
  163. this->Controls->Add(this->save);
  164. this->Controls->Add(this->dataGridView1);
  165. this->Name = L"dataEditor";
  166. this->Text = L"dataEditor";
  167. (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit();
  168. this->ResumeLayout(false);
  169. }
  170. #pragma endregion
  171. private: System::Void clear_Click(System::Object^ sender, System::EventArgs^ e) {
  172. for (int i=0;i<data->size();i++)
  173. {
  174. dataGridView1->Rows[i]->Cells[0]->Value = data->at(i)->townID;
  175. dataGridView1->Rows[i]->Cells[1]->Value = data->at(i)->ID;
  176. dataGridView1->Rows[i]->Cells[2]->Value = data->at(i)->defname;
  177. dataGridView1->Rows[i]->Cells[3]->Value = data->at(i)->x;
  178. dataGridView1->Rows[i]->Cells[4]->Value = data->at(i)->y;
  179. }
  180. }
  181. private: System::Void close_Click(System::Object^ sender, System::EventArgs^ e) {
  182. Close();
  183. }
  184. private: System::Void save_Click(System::Object^ sender, System::EventArgs^ e) {
  185. for (int i=0;i<data->size();i++)
  186. {
  187. data->at(i)->townID = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[0]->Value));
  188. data->at(i)->ID = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[1]->Value));
  189. data->at(i)->defname = static_cast<String^>(dataGridView1->Rows[i]->Cells[2]->Value);
  190. data->at(i)->x = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[3]->Value));
  191. data->at(i)->y = Convert::ToInt32( static_cast<String^>(dataGridView1->Rows[i]->Cells[4]->Value));
  192. }
  193. }
  194. };
  195. }