HICONT

MainForm.h

Apr 13th, 2022 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.48 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. long double fact(int N)
  6. {
  7.     if (N < 0)
  8.         return 0;
  9.     if (N == 0)
  10.         return 1;
  11.     else
  12.         return N * fact(N - 1);
  13. }
  14. namespace Project1 {
  15.  
  16.     using namespace System;
  17.     using namespace System::ComponentModel;
  18.     using namespace System::Collections;
  19.     using namespace System::Windows::Forms;
  20.     using namespace System::Data;
  21.     using namespace System::Drawing;
  22.  
  23.     /// <summary>
  24.     /// Сводка для MainForm
  25.     /// </summary>
  26.     public ref class MainForm : public System::Windows::Forms::Form
  27.     {
  28.     public:
  29.         MainForm(void)
  30.         {
  31.             InitializeComponent();
  32.             //
  33.             //TODO: добавьте код конструктора
  34.             //
  35.         }
  36.  
  37.     protected:
  38.         /// <summary>
  39.         /// Освободить все используемые ресурсы.
  40.         /// </summary>
  41.         ~MainForm()
  42.         {
  43.             if (components)
  44.             {
  45.                 delete components;
  46.             }
  47.         }
  48.     private: System::ComponentModel::BackgroundWorker^ backgroundWorker1;
  49.     protected:
  50.     private: System::Windows::Forms::Label^ label1;
  51.     private: System::Windows::Forms::TextBox^ text1;
  52.  
  53.     private: System::Windows::Forms::Label^ label2;
  54.  
  55.     private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel1;
  56.     private: System::Windows::Forms::Button^ button1;
  57.     private: System::Windows::Forms::Label^ label3;
  58.     private: System::Windows::Forms::TextBox^ text2;
  59.     private: System::Windows::Forms::Button^ button3;
  60.     private: System::Windows::Forms::Button^ button2;
  61.     private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel2;
  62.     private: System::Windows::Forms::Button^ button4;
  63.     private: System::Windows::Forms::Button^ button5;
  64.  
  65.     private:
  66.         /// <summary>
  67.         /// Обязательная переменная конструктора.
  68.         /// </summary>
  69.         System::ComponentModel::Container ^components;
  70.  
  71. #pragma region Windows Form Designer generated code
  72.         /// <summary>
  73.         /// Требуемый метод для поддержки конструктора — не изменяйте
  74.         /// содержимое этого метода с помощью редактора кода.
  75.         /// </summary>
  76.         void InitializeComponent(void)
  77.         {
  78.             this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
  79.             this->label1 = (gcnew System::Windows::Forms::Label());
  80.             this->text1 = (gcnew System::Windows::Forms::TextBox());
  81.             this->label2 = (gcnew System::Windows::Forms::Label());
  82.             this->tableLayoutPanel1 = (gcnew System::Windows::Forms::TableLayoutPanel());
  83.             this->button3 = (gcnew System::Windows::Forms::Button());
  84.             this->button1 = (gcnew System::Windows::Forms::Button());
  85.             this->button2 = (gcnew System::Windows::Forms::Button());
  86.             this->label3 = (gcnew System::Windows::Forms::Label());
  87.             this->text2 = (gcnew System::Windows::Forms::TextBox());
  88.             this->tableLayoutPanel2 = (gcnew System::Windows::Forms::TableLayoutPanel());
  89.             this->button4 = (gcnew System::Windows::Forms::Button());
  90.             this->button5 = (gcnew System::Windows::Forms::Button());
  91.             this->tableLayoutPanel1->SuspendLayout();
  92.             this->tableLayoutPanel2->SuspendLayout();
  93.             this->SuspendLayout();
  94.             //
  95.             // label1
  96.             //
  97.             this->label1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
  98.                 | System::Windows::Forms::AnchorStyles::Right));
  99.             this->label1->AutoSize = true;
  100.             this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 16.2F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  101.                 static_cast<System::Byte>(204)));
  102.             this->label1->Location = System::Drawing::Point(12, 9);
  103.             this->label1->Name = L"label1";
  104.             this->label1->Size = System::Drawing::Size(191, 32);
  105.             this->label1->TabIndex = 0;
  106.             this->label1->Text = L"Your numbers";
  107.             //
  108.             // text1
  109.             //
  110.             this->text1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
  111.                 | System::Windows::Forms::AnchorStyles::Right));
  112.             this->text1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  113.                 static_cast<System::Byte>(204)));
  114.             this->text1->Location = System::Drawing::Point(18, 75);
  115.             this->text1->Name = L"text1";
  116.             this->text1->Size = System::Drawing::Size(552, 30);
  117.             this->text1->TabIndex = 1;
  118.             //
  119.             // label2
  120.             //
  121.             this->label2->AutoSize = true;
  122.             this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 16.2F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  123.                 static_cast<System::Byte>(204)));
  124.             this->label2->ForeColor = System::Drawing::Color::Black;
  125.             this->label2->Location = System::Drawing::Point(15, 446);
  126.             this->label2->Name = L"label2";
  127.             this->label2->Size = System::Drawing::Size(152, 32);
  128.             this->label2->TabIndex = 2;
  129.             this->label2->Text = L"Answer    =";
  130.             //
  131.             // tableLayoutPanel1
  132.             //
  133.             this->tableLayoutPanel1->ColumnCount = 3;
  134.             this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent,
  135.                 50)));
  136.             this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute,
  137.                 194)));
  138.             this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute,
  139.                 182)));
  140.             this->tableLayoutPanel1->Controls->Add(this->button3, 2, 0);
  141.             this->tableLayoutPanel1->Controls->Add(this->button1, 0, 0);
  142.             this->tableLayoutPanel1->Controls->Add(this->button2, 1, 0);
  143.             this->tableLayoutPanel1->Location = System::Drawing::Point(18, 159);
  144.             this->tableLayoutPanel1->Name = L"tableLayoutPanel1";
  145.             this->tableLayoutPanel1->RowCount = 1;
  146.             this->tableLayoutPanel1->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50)));
  147.             this->tableLayoutPanel1->Size = System::Drawing::Size(552, 73);
  148.             this->tableLayoutPanel1->TabIndex = 4;
  149.             //
  150.             // button3
  151.             //
  152.             this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 13.8F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  153.                 static_cast<System::Byte>(204)));
  154.             this->button3->Location = System::Drawing::Point(373, 3);
  155.             this->button3->Name = L"button3";
  156.             this->button3->Size = System::Drawing::Size(176, 67);
  157.             this->button3->TabIndex = 7;
  158.             this->button3->Text = L"Subtract";
  159.             this->button3->UseVisualStyleBackColor = true;
  160.             this->button3->Click += gcnew System::EventHandler(this, &MainForm::button3_Click);
  161.             //
  162.             // button1
  163.             //
  164.             this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 13.8F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  165.                 static_cast<System::Byte>(204)));
  166.             this->button1->Location = System::Drawing::Point(3, 3);
  167.             this->button1->Name = L"button1";
  168.             this->button1->Size = System::Drawing::Size(165, 67);
  169.             this->button1->TabIndex = 0;
  170.             this->button1->Text = L"Summing";
  171.             this->button1->UseVisualStyleBackColor = true;
  172.             this->button1->Click += gcnew System::EventHandler(this, &MainForm::button1_Click);
  173.             //
  174.             // button2
  175.             //
  176.             this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 13.8F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  177.                 static_cast<System::Byte>(204)));
  178.             this->button2->Location = System::Drawing::Point(179, 3);
  179.             this->button2->Name = L"button2";
  180.             this->button2->Size = System::Drawing::Size(188, 67);
  181.             this->button2->TabIndex = 7;
  182.             this->button2->Text = L"Multiplicate";
  183.             this->button2->UseVisualStyleBackColor = true;
  184.             this->button2->Click += gcnew System::EventHandler(this, &MainForm::button2_Click);
  185.             //
  186.             // label3
  187.             //
  188.             this->label3->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
  189.                 | System::Windows::Forms::AnchorStyles::Right));
  190.             this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 16.2F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  191.                 static_cast<System::Byte>(204)));
  192.             this->label3->Location = System::Drawing::Point(191, 446);
  193.             this->label3->Name = L"label3";
  194.             this->label3->Size = System::Drawing::Size(241, 220);
  195.             this->label3->TabIndex = 5;
  196.             this->label3->Text = L"label3";
  197.             //
  198.             // text2
  199.             //
  200.             this->text2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
  201.                 | System::Windows::Forms::AnchorStyles::Right));
  202.             this->text2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  203.                 static_cast<System::Byte>(204)));
  204.             this->text2->Location = System::Drawing::Point(18, 111);
  205.             this->text2->Name = L"text2";
  206.             this->text2->Size = System::Drawing::Size(552, 30);
  207.             this->text2->TabIndex = 6;
  208.             //
  209.             // tableLayoutPanel2
  210.             //
  211.             this->tableLayoutPanel2->ColumnCount = 1;
  212.             this->tableLayoutPanel2->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent,
  213.                 50)));
  214.             this->tableLayoutPanel2->Controls->Add(this->button4, 0, 0);
  215.             this->tableLayoutPanel2->Location = System::Drawing::Point(18, 238);
  216.             this->tableLayoutPanel2->Name = L"tableLayoutPanel2";
  217.             this->tableLayoutPanel2->RowCount = 1;
  218.             this->tableLayoutPanel2->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50)));
  219.             this->tableLayoutPanel2->Size = System::Drawing::Size(549, 100);
  220.             this->tableLayoutPanel2->TabIndex = 7;
  221.             //
  222.             // button4
  223.             //
  224.             this->button4->Font = (gcnew System::Drawing::Font(L"Segoe Script", 24, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  225.                 static_cast<System::Byte>(204)));
  226.             this->button4->Location = System::Drawing::Point(3, 3);
  227.             this->button4->Name = L"button4";
  228.             this->button4->Size = System::Drawing::Size(543, 94);
  229.             this->button4->TabIndex = 0;
  230.             this->button4->Text = L"Factorial";
  231.             this->button4->UseVisualStyleBackColor = true;
  232.             this->button4->Click += gcnew System::EventHandler(this, &MainForm::button4_Click);
  233.             //
  234.             // button5
  235.             //
  236.             this->button5->Font = (gcnew System::Drawing::Font(L"Segoe Script", 24, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  237.                 static_cast<System::Byte>(204)));
  238.             this->button5->Location = System::Drawing::Point(21, 341);
  239.             this->button5->Name = L"button5";
  240.             this->button5->Size = System::Drawing::Size(543, 94);
  241.             this->button5->TabIndex = 8;
  242.             this->button5->Text = L"Double ";
  243.             this->button5->UseVisualStyleBackColor = true;
  244.             this->button5->Click += gcnew System::EventHandler(this, &MainForm::button5_Click);
  245.             //
  246.             // MainForm
  247.             //
  248.             this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
  249.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  250.             this->BackColor = System::Drawing::SystemColors::ActiveCaption;
  251.             this->ClientSize = System::Drawing::Size(582, 553);
  252.             this->Controls->Add(this->button5);
  253.             this->Controls->Add(this->tableLayoutPanel2);
  254.             this->Controls->Add(this->text2);
  255.             this->Controls->Add(this->label3);
  256.             this->Controls->Add(this->tableLayoutPanel1);
  257.             this->Controls->Add(this->label2);
  258.             this->Controls->Add(this->text1);
  259.             this->Controls->Add(this->label1);
  260.             this->MaximumSize = System::Drawing::Size(600, 600);
  261.             this->MinimumSize = System::Drawing::Size(600, 600);
  262.             this->Name = L"MainForm";
  263.             this->Text = L"MainForm";
  264.             this->Load += gcnew System::EventHandler(this, &MainForm::MainForm_Load);
  265.             this->tableLayoutPanel1->ResumeLayout(false);
  266.             this->tableLayoutPanel2->ResumeLayout(false);
  267.             this->ResumeLayout(false);
  268.             this->PerformLayout();
  269.  
  270.         }
  271. #pragma endregion
  272. private: System::Void MainForm_Load(System::Object^ sender, System::EventArgs^ e) {
  273.     this->label3->Text = "";
  274. }
  275. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  276.     int i = System::Convert::ToDouble(text1->Text);
  277.     int u = System::Convert::ToDouble(text2->Text);
  278.     int y = i + u;
  279.     label3->Text = System::Convert::ToString(y);
  280. }
  281. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  282.     int i = System::Convert::ToDouble(text1->Text);
  283.     int u = System::Convert::ToDouble(text2->Text);
  284.     int y = i * u;
  285.     label3->Text = System::Convert::ToString(y);
  286. }
  287. private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
  288.     int i = System::Convert::ToDouble(text1->Text);
  289.     int u = System::Convert::ToDouble(text2->Text);
  290.     int y = i - u;
  291.     label3->Text = System::Convert::ToString(y);
  292. }
  293. private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
  294.     int number = System::Convert::ToDouble(text1->Text);
  295.     int number2 = System::Convert::ToDouble(text2->Text);
  296.     double factor = fact(number);
  297.     double factor2 = fact(number2);
  298.     label3->Text = System::Convert::ToString(factor) + " , " + System::Convert::ToString(factor2);
  299. }
  300. private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {
  301.     int i = System::Convert::ToDouble(text1->Text);
  302.     int u = System::Convert::ToDouble(text2->Text);
  303.     int y = 2*i;
  304.     int p = 2 * u;
  305.     label3->Text = System::Convert::ToString(y) + " , " + System::Convert::ToString(p);
  306. }
  307. };
  308. }
Add Comment
Please, Sign In to add comment