Advertisement
Guest User

Untitled

a guest
May 29th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.93 KB | None | 0 0
  1. #pragma once
  2. #include "popUpWindow.h"
  3. #include <iostream>
  4. struct element {
  5. element *_down;
  6. int _value;
  7. element *_next;
  8. };
  9. element *elementFromTopList, *elementFromBottomList;
  10. element *prevElementFromTopList = NULL;
  11. element *prevElementFromBottomList = NULL;
  12. element *S = NULL, *currentElement = NULL;
  13. int currentList = -1, linesCount;
  14.  
  15. namespace Kursovaya8varWin {
  16. using namespace std;
  17. using namespace System;
  18. using namespace System::ComponentModel;
  19. using namespace System::Collections;
  20. using namespace System::Windows::Forms;
  21. using namespace System::Data;
  22. using namespace System::Drawing;
  23.  
  24. /// <summary>
  25. /// Summary for Form1
  26. /// </summary>
  27. public ref class Form1 : public System::Windows::Forms::Form
  28. {
  29. public:
  30. Form1(void)
  31. {
  32. InitializeComponent();
  33. //
  34. //TODO: Add the constructor code here
  35. //
  36. }
  37.  
  38. protected:
  39. /// <summary>
  40. /// Clean up any resources being used.
  41. /// </summary>
  42. ~Form1()
  43. {
  44. if (components)
  45. {
  46. delete components;
  47. }
  48. }
  49. private: System::Windows::Forms::Label^ label1;
  50.  
  51. protected:
  52.  
  53. protected:
  54.  
  55.  
  56. private: System::Windows::Forms::Button^ buttonRight;
  57.  
  58.  
  59. private: System::Windows::Forms::Button^ buttonDown;
  60.  
  61. private: System::Windows::Forms::TextBox^ InputTextBox;
  62. private: System::Windows::Forms::Button^ buttonApply;
  63.  
  64. private: System::Windows::Forms::Button^ buttonInStart;
  65. private: System::Windows::Forms::MenuStrip^ menuStrip1;
  66. private: System::Windows::Forms::ToolStripMenuItem^ авторToolStripMenuItem;
  67. private: System::Windows::Forms::ToolStripMenuItem^ выходToolStripMenuItem;
  68. private: System::Windows::Forms::ToolStripMenuItem^ заданиеToolStripMenuItem;
  69.  
  70.  
  71. protected:
  72.  
  73. private:
  74. /// <summary>
  75. /// Required designer variable.
  76. /// </summary>
  77. System::ComponentModel::Container ^components;
  78.  
  79. #pragma region Windows Form Designer generated code
  80. /// <summary>
  81. /// Required method for Designer support - do not modify
  82. /// the contents of this method with the code editor.
  83. /// </summary>
  84. void InitializeComponent(void)
  85. {
  86. this->label1 = (gcnew System::Windows::Forms::Label());
  87. this->buttonRight = (gcnew System::Windows::Forms::Button());
  88. this->buttonDown = (gcnew System::Windows::Forms::Button());
  89. this->InputTextBox = (gcnew System::Windows::Forms::TextBox());
  90. this->buttonApply = (gcnew System::Windows::Forms::Button());
  91. this->buttonInStart = (gcnew System::Windows::Forms::Button());
  92. this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
  93. this->авторToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  94. this->заданиеToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  95. this->выходToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  96. this->menuStrip1->SuspendLayout();
  97. this->SuspendLayout();
  98. //
  99. // label1
  100. //
  101. this->label1->AutoSize = true;
  102. this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  103. static_cast<System::Byte>(204)));
  104. this->label1->Location = System::Drawing::Point(118, 95);
  105. this->label1->Name = L"label1";
  106. this->label1->Size = System::Drawing::Size(0, 24);
  107. this->label1->TabIndex = 0;
  108. this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
  109. //
  110. // buttonRight
  111. //
  112. this->buttonRight->Enabled = false;
  113. this->buttonRight->Location = System::Drawing::Point(118, 31);
  114. this->buttonRight->Name = L"buttonRight";
  115. this->buttonRight->Size = System::Drawing::Size(100, 28);
  116. this->buttonRight->TabIndex = 3;
  117. this->buttonRight->Text = L"Вправо >";
  118. this->buttonRight->UseVisualStyleBackColor = true;
  119. this->buttonRight->Click += gcnew System::EventHandler(this, &Form1::buttonRight_Click);
  120. //
  121. // buttonDown
  122. //
  123. this->buttonDown->Enabled = false;
  124. this->buttonDown->Location = System::Drawing::Point(118, 63);
  125. this->buttonDown->Name = L"buttonDown";
  126. this->buttonDown->Size = System::Drawing::Size(100, 27);
  127. this->buttonDown->TabIndex = 4;
  128. this->buttonDown->Text = L"Вниз \\/";
  129. this->buttonDown->UseVisualStyleBackColor = true;
  130. this->buttonDown->Click += gcnew System::EventHandler(this, &Form1::buttonDown_Click);
  131. //
  132. // InputTextBox
  133. //
  134. this->InputTextBox->Location = System::Drawing::Point(12, 31);
  135. this->InputTextBox->Multiline = true;
  136. this->InputTextBox->Name = L"InputTextBox";
  137. this->InputTextBox->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
  138. this->InputTextBox->Size = System::Drawing::Size(100, 215);
  139. this->InputTextBox->TabIndex = 6;
  140. this->InputTextBox->Text = L"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n0";
  141. //
  142. // buttonApply
  143. //
  144. this->buttonApply->Location = System::Drawing::Point(12, 252);
  145. this->buttonApply->Name = L"buttonApply";
  146. this->buttonApply->Size = System::Drawing::Size(100, 29);
  147. this->buttonApply->TabIndex = 7;
  148. this->buttonApply->Text = L"Сформировать";
  149. this->buttonApply->UseVisualStyleBackColor = true;
  150. this->buttonApply->Click += gcnew System::EventHandler(this, &Form1::buttonApply_Click);
  151. //
  152. // buttonInStart
  153. //
  154. this->buttonInStart->Enabled = false;
  155. this->buttonInStart->Location = System::Drawing::Point(222, 31);
  156. this->buttonInStart->Name = L"buttonInStart";
  157. this->buttonInStart->Size = System::Drawing::Size(100, 28);
  158. this->buttonInStart->TabIndex = 8;
  159. this->buttonInStart->Text = L"В начало";
  160. this->buttonInStart->UseVisualStyleBackColor = true;
  161. this->buttonInStart->Click += gcnew System::EventHandler(this, &Form1::buttonInStart_Click);
  162. //
  163. // menuStrip1
  164. //
  165. this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->авторToolStripMenuItem,
  166. this->заданиеToolStripMenuItem, this->выходToolStripMenuItem});
  167. this->menuStrip1->Location = System::Drawing::Point(0, 0);
  168. this->menuStrip1->Name = L"menuStrip1";
  169. this->menuStrip1->Size = System::Drawing::Size(327, 24);
  170. this->menuStrip1->TabIndex = 9;
  171. this->menuStrip1->Text = L"menuStrip1";
  172. //
  173. // авторToolStripMenuItem
  174. //
  175. this->авторToolStripMenuItem->Name = L"авторToolStripMenuItem";
  176. this->авторToolStripMenuItem->Size = System::Drawing::Size(52, 20);
  177. this->авторToolStripMenuItem->Text = L"Автор";
  178. this->авторToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::авторToolStripMenuItem_Click);
  179. //
  180. // заданиеToolStripMenuItem
  181. //
  182. this->заданиеToolStripMenuItem->Name = L"заданиеToolStripMenuItem";
  183. this->заданиеToolStripMenuItem->Size = System::Drawing::Size(64, 20);
  184. this->заданиеToolStripMenuItem->Text = L"Задание";
  185. this->заданиеToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::заданиеToolStripMenuItem_Click);
  186. //
  187. // выходToolStripMenuItem
  188. //
  189. this->выходToolStripMenuItem->Name = L"выходToolStripMenuItem";
  190. this->выходToolStripMenuItem->Size = System::Drawing::Size(53, 20);
  191. this->выходToolStripMenuItem->Text = L"Выход";
  192. this->выходToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::выходToolStripMenuItem_Click);
  193. //
  194. // Form1
  195. //
  196. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  197. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  198. this->ClientSize = System::Drawing::Size(327, 288);
  199. this->Controls->Add(this->buttonInStart);
  200. this->Controls->Add(this->buttonApply);
  201. this->Controls->Add(this->InputTextBox);
  202. this->Controls->Add(this->buttonDown);
  203. this->Controls->Add(this->buttonRight);
  204. this->Controls->Add(this->label1);
  205. this->Controls->Add(this->menuStrip1);
  206. this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
  207. this->MainMenuStrip = this->menuStrip1;
  208. this->Name = L"Form1";
  209. this->Text = L"Курсовая работа :: 8 вариант";
  210. this->menuStrip1->ResumeLayout(false);
  211. this->menuStrip1->PerformLayout();
  212. this->ResumeLayout(false);
  213. this->PerformLayout();
  214.  
  215. }
  216. #pragma endregion
  217. void refreshLabel() {
  218. label1->Text = System::Convert::ToString(currentElement->_value) + " :: " + (currentList?"Нижний список":"Верхний список");
  219. }
  220. private: System::Void buttonApply_Click(System::Object^ sender, System::EventArgs^ e) {
  221. for (int i = 0; i < InputTextBox->Lines->Length; i++) {
  222. int currentNumber = System::Convert::ToInt16(InputTextBox->Lines[i]);
  223. if (currentNumber == 0) {
  224. break;
  225. }
  226. bool isEven = ((i + 1) % 2 == 0);
  227. if (isEven) {
  228. elementFromTopList = new element;
  229. elementFromTopList->_down = prevElementFromBottomList;
  230. elementFromTopList->_next = prevElementFromTopList;
  231. elementFromTopList->_value = currentNumber;
  232. prevElementFromTopList = elementFromTopList;
  233. S = elementFromTopList;
  234. currentList = 0;
  235. } else {
  236. elementFromBottomList = new element;
  237. elementFromBottomList->_down = NULL;
  238. elementFromBottomList->_next = prevElementFromBottomList;
  239. elementFromBottomList->_value = currentNumber;
  240. prevElementFromBottomList = elementFromBottomList;
  241. S = elementFromBottomList;
  242. currentList = 1;
  243. }
  244. linesCount = i;
  245. }
  246. currentElement = S;
  247. refreshLabel();
  248. buttonRight->Enabled = true;
  249. buttonDown->Enabled = true;
  250. buttonInStart->Enabled = true;
  251. buttonApply->Enabled = false;
  252. InputTextBox->Enabled = false;
  253. }
  254. private: System::Void buttonRight_Click(System::Object^ sender, System::EventArgs^ e) {
  255. if (currentElement->_next != NULL) {
  256. currentElement = currentElement->_next;
  257. }
  258. refreshLabel();
  259. }
  260. private: System::Void buttonDown_Click(System::Object^ sender, System::EventArgs^ e) {
  261. if (currentElement->_down != NULL) {
  262. currentElement = currentElement->_down;
  263. currentList = 1;
  264. }
  265. refreshLabel();
  266. }
  267. private: System::Void buttonInStart_Click(System::Object^ sender, System::EventArgs^ e) {
  268. currentElement = S;
  269. if ((linesCount + 1) % 2 == 0) {
  270. currentList = 0;
  271. } else {
  272. currentList = 1;
  273. }
  274. refreshLabel();
  275. }
  276. private: System::Void авторToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  277. MessageBox::Show("Выполнил студент группы А-43 Ерфилов Роман");
  278. }
  279. private: System::Void выходToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  280. Application::Exit();
  281. }
  282. private: System::Void заданиеToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  283. popUpWindow^ popForm = gcnew popUpWindow;
  284. popForm->Show();
  285. popForm->Visible = true;
  286. }
  287. };
  288. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement