Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "popUpWindow.h"
- #include <iostream>
- struct element {
- element *_down;
- int _value;
- element *_next;
- };
- element *elementFromTopList, *elementFromBottomList;
- element *prevElementFromTopList = NULL;
- element *prevElementFromBottomList = NULL;
- element *S = NULL, *currentElement = NULL;
- int currentList = -1, linesCount;
- namespace Kursovaya8varWin {
- using namespace std;
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- /// <summary>
- /// Summary for Form1
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Label^ label1;
- protected:
- protected:
- private: System::Windows::Forms::Button^ buttonRight;
- private: System::Windows::Forms::Button^ buttonDown;
- private: System::Windows::Forms::TextBox^ InputTextBox;
- private: System::Windows::Forms::Button^ buttonApply;
- private: System::Windows::Forms::Button^ buttonInStart;
- private: System::Windows::Forms::MenuStrip^ menuStrip1;
- private: System::Windows::Forms::ToolStripMenuItem^ авторToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ выходToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ заданиеToolStripMenuItem;
- protected:
- 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->label1 = (gcnew System::Windows::Forms::Label());
- this->buttonRight = (gcnew System::Windows::Forms::Button());
- this->buttonDown = (gcnew System::Windows::Forms::Button());
- this->InputTextBox = (gcnew System::Windows::Forms::TextBox());
- this->buttonApply = (gcnew System::Windows::Forms::Button());
- this->buttonInStart = (gcnew System::Windows::Forms::Button());
- this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
- this->авторToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->заданиеToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->выходToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->menuStrip1->SuspendLayout();
- this->SuspendLayout();
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->label1->Location = System::Drawing::Point(118, 95);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(0, 24);
- this->label1->TabIndex = 0;
- this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
- //
- // buttonRight
- //
- this->buttonRight->Enabled = false;
- this->buttonRight->Location = System::Drawing::Point(118, 31);
- this->buttonRight->Name = L"buttonRight";
- this->buttonRight->Size = System::Drawing::Size(100, 28);
- this->buttonRight->TabIndex = 3;
- this->buttonRight->Text = L"Вправо >";
- this->buttonRight->UseVisualStyleBackColor = true;
- this->buttonRight->Click += gcnew System::EventHandler(this, &Form1::buttonRight_Click);
- //
- // buttonDown
- //
- this->buttonDown->Enabled = false;
- this->buttonDown->Location = System::Drawing::Point(118, 63);
- this->buttonDown->Name = L"buttonDown";
- this->buttonDown->Size = System::Drawing::Size(100, 27);
- this->buttonDown->TabIndex = 4;
- this->buttonDown->Text = L"Вниз \\/";
- this->buttonDown->UseVisualStyleBackColor = true;
- this->buttonDown->Click += gcnew System::EventHandler(this, &Form1::buttonDown_Click);
- //
- // InputTextBox
- //
- this->InputTextBox->Location = System::Drawing::Point(12, 31);
- this->InputTextBox->Multiline = true;
- this->InputTextBox->Name = L"InputTextBox";
- this->InputTextBox->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
- this->InputTextBox->Size = System::Drawing::Size(100, 215);
- this->InputTextBox->TabIndex = 6;
- 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";
- //
- // buttonApply
- //
- this->buttonApply->Location = System::Drawing::Point(12, 252);
- this->buttonApply->Name = L"buttonApply";
- this->buttonApply->Size = System::Drawing::Size(100, 29);
- this->buttonApply->TabIndex = 7;
- this->buttonApply->Text = L"Сформировать";
- this->buttonApply->UseVisualStyleBackColor = true;
- this->buttonApply->Click += gcnew System::EventHandler(this, &Form1::buttonApply_Click);
- //
- // buttonInStart
- //
- this->buttonInStart->Enabled = false;
- this->buttonInStart->Location = System::Drawing::Point(222, 31);
- this->buttonInStart->Name = L"buttonInStart";
- this->buttonInStart->Size = System::Drawing::Size(100, 28);
- this->buttonInStart->TabIndex = 8;
- this->buttonInStart->Text = L"В начало";
- this->buttonInStart->UseVisualStyleBackColor = true;
- this->buttonInStart->Click += gcnew System::EventHandler(this, &Form1::buttonInStart_Click);
- //
- // menuStrip1
- //
- this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->авторToolStripMenuItem,
- this->заданиеToolStripMenuItem, this->выходToolStripMenuItem});
- this->menuStrip1->Location = System::Drawing::Point(0, 0);
- this->menuStrip1->Name = L"menuStrip1";
- this->menuStrip1->Size = System::Drawing::Size(327, 24);
- this->menuStrip1->TabIndex = 9;
- this->menuStrip1->Text = L"menuStrip1";
- //
- // авторToolStripMenuItem
- //
- this->авторToolStripMenuItem->Name = L"авторToolStripMenuItem";
- this->авторToolStripMenuItem->Size = System::Drawing::Size(52, 20);
- this->авторToolStripMenuItem->Text = L"Автор";
- this->авторToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::авторToolStripMenuItem_Click);
- //
- // заданиеToolStripMenuItem
- //
- this->заданиеToolStripMenuItem->Name = L"заданиеToolStripMenuItem";
- this->заданиеToolStripMenuItem->Size = System::Drawing::Size(64, 20);
- this->заданиеToolStripMenuItem->Text = L"Задание";
- this->заданиеToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::заданиеToolStripMenuItem_Click);
- //
- // выходToolStripMenuItem
- //
- this->выходToolStripMenuItem->Name = L"выходToolStripMenuItem";
- this->выходToolStripMenuItem->Size = System::Drawing::Size(53, 20);
- this->выходToolStripMenuItem->Text = L"Выход";
- this->выходToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::выходToolStripMenuItem_Click);
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(327, 288);
- this->Controls->Add(this->buttonInStart);
- this->Controls->Add(this->buttonApply);
- this->Controls->Add(this->InputTextBox);
- this->Controls->Add(this->buttonDown);
- this->Controls->Add(this->buttonRight);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->menuStrip1);
- this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
- this->MainMenuStrip = this->menuStrip1;
- this->Name = L"Form1";
- this->Text = L"Курсовая работа :: 8 вариант";
- this->menuStrip1->ResumeLayout(false);
- this->menuStrip1->PerformLayout();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- void refreshLabel() {
- label1->Text = System::Convert::ToString(currentElement->_value) + " :: " + (currentList?"Нижний список":"Верхний список");
- }
- private: System::Void buttonApply_Click(System::Object^ sender, System::EventArgs^ e) {
- for (int i = 0; i < InputTextBox->Lines->Length; i++) {
- int currentNumber = System::Convert::ToInt16(InputTextBox->Lines[i]);
- if (currentNumber == 0) {
- break;
- }
- bool isEven = ((i + 1) % 2 == 0);
- if (isEven) {
- elementFromTopList = new element;
- elementFromTopList->_down = prevElementFromBottomList;
- elementFromTopList->_next = prevElementFromTopList;
- elementFromTopList->_value = currentNumber;
- prevElementFromTopList = elementFromTopList;
- S = elementFromTopList;
- currentList = 0;
- } else {
- elementFromBottomList = new element;
- elementFromBottomList->_down = NULL;
- elementFromBottomList->_next = prevElementFromBottomList;
- elementFromBottomList->_value = currentNumber;
- prevElementFromBottomList = elementFromBottomList;
- S = elementFromBottomList;
- currentList = 1;
- }
- linesCount = i;
- }
- currentElement = S;
- refreshLabel();
- buttonRight->Enabled = true;
- buttonDown->Enabled = true;
- buttonInStart->Enabled = true;
- buttonApply->Enabled = false;
- InputTextBox->Enabled = false;
- }
- private: System::Void buttonRight_Click(System::Object^ sender, System::EventArgs^ e) {
- if (currentElement->_next != NULL) {
- currentElement = currentElement->_next;
- }
- refreshLabel();
- }
- private: System::Void buttonDown_Click(System::Object^ sender, System::EventArgs^ e) {
- if (currentElement->_down != NULL) {
- currentElement = currentElement->_down;
- currentList = 1;
- }
- refreshLabel();
- }
- private: System::Void buttonInStart_Click(System::Object^ sender, System::EventArgs^ e) {
- currentElement = S;
- if ((linesCount + 1) % 2 == 0) {
- currentList = 0;
- } else {
- currentList = 1;
- }
- refreshLabel();
- }
- private: System::Void авторToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
- MessageBox::Show("Выполнил студент группы А-43 Ерфилов Роман");
- }
- private: System::Void выходToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
- Application::Exit();
- }
- private: System::Void заданиеToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
- popUpWindow^ popForm = gcnew popUpWindow;
- popForm->Show();
- popForm->Visible = true;
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement