Advertisement
Linkin_Park

OOP_lab6 Form 4

Nov 2nd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.53 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "RomanFigure.h"
  4. #include <msclr\marshal_cppstd.h>
  5.  
  6.  
  7. namespace OOP_lab6 {
  8.  
  9.     using namespace System;
  10.     using namespace System::ComponentModel;
  11.     using namespace System::Collections;
  12.     using namespace System::Windows::Forms;
  13.     using namespace System::Data;
  14.     using namespace System::Drawing;
  15.     using namespace msclr::interop;
  16.  
  17.  
  18.     /// <summary>
  19.     /// Summary for MyForm4
  20.     /// </summary>
  21.     public ref class MyForm4 : public System::Windows::Forms::Form
  22.     {
  23.     public:
  24.         MyForm4(void)
  25.         {
  26.             InitializeComponent();
  27.             //
  28.             //TODO: Add the constructor code here
  29.             //
  30.         }
  31.  
  32.     protected:
  33.         /// <summary>
  34.         /// Clean up any resources being used.
  35.         /// </summary>
  36.         ~MyForm4()
  37.         {
  38.             if (components)
  39.             {
  40.                 delete components;
  41.             }
  42.         }
  43.     private: System::Windows::Forms::Label^  label4;
  44.     protected:
  45.     private: System::Windows::Forms::Label^  label3;
  46.     private: System::Windows::Forms::Label^  label5;
  47.     private: System::Windows::Forms::RichTextBox^  richTextBox3;
  48.     private: System::Windows::Forms::RichTextBox^  richTextBox2;
  49.     private: System::Windows::Forms::RichTextBox^  richTextBox1;
  50.     private: System::Windows::Forms::Button^  button1;
  51.     private: System::Windows::Forms::Label^  label1;
  52.     private: System::Windows::Forms::Label^  label2;
  53.  
  54.     private:
  55.         /// <summary>
  56.         /// Required designer variable.
  57.         /// </summary>
  58.         System::ComponentModel::Container ^components;
  59.  
  60. #pragma region Windows Form Designer generated code
  61.         /// <summary>
  62.         /// Required method for Designer support - do not modify
  63.         /// the contents of this method with the code editor.
  64.         /// </summary>
  65.         void InitializeComponent(void)
  66.         {
  67.             this->label4 = (gcnew System::Windows::Forms::Label());
  68.             this->label3 = (gcnew System::Windows::Forms::Label());
  69.             this->label5 = (gcnew System::Windows::Forms::Label());
  70.             this->richTextBox3 = (gcnew System::Windows::Forms::RichTextBox());
  71.             this->richTextBox2 = (gcnew System::Windows::Forms::RichTextBox());
  72.             this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
  73.             this->button1 = (gcnew System::Windows::Forms::Button());
  74.             this->label1 = (gcnew System::Windows::Forms::Label());
  75.             this->label2 = (gcnew System::Windows::Forms::Label());
  76.             this->SuspendLayout();
  77.             //
  78.             // label4
  79.             //
  80.             this->label4->AutoSize = true;
  81.             this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
  82.             this->label4->Location = System::Drawing::Point(177, 46);
  83.             this->label4->Name = L"label4";
  84.             this->label4->Size = System::Drawing::Size(106, 58);
  85.             this->label4->TabIndex = 31;
  86.             this->label4->Text = L"dec";
  87.             //
  88.             // label3
  89.             //
  90.             this->label3->AutoSize = true;
  91.             this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
  92.             this->label3->Location = System::Drawing::Point(525, 46);
  93.             this->label3->Name = L"label3";
  94.             this->label3->Size = System::Drawing::Size(106, 58);
  95.             this->label3->TabIndex = 30;
  96.             this->label3->Text = L"dec";
  97.             //
  98.             // label5
  99.             //
  100.             this->label5->AutoSize = true;
  101.             this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
  102.             this->label5->Location = System::Drawing::Point(859, 46);
  103.             this->label5->Name = L"label5";
  104.             this->label5->Size = System::Drawing::Size(168, 58);
  105.             this->label5->TabIndex = 29;
  106.             this->label5->Text = L"roman";
  107.             //
  108.             // richTextBox3
  109.             //
  110.             this->richTextBox3->Enabled = false;
  111.             this->richTextBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
  112.             this->richTextBox3->Location = System::Drawing::Point(811, 125);
  113.             this->richTextBox3->Name = L"richTextBox3";
  114.             this->richTextBox3->Size = System::Drawing::Size(257, 51);
  115.             this->richTextBox3->TabIndex = 26;
  116.             this->richTextBox3->Text = L"";
  117.             //
  118.             // richTextBox2
  119.             //
  120.             this->richTextBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
  121.             this->richTextBox2->Location = System::Drawing::Point(438, 125);
  122.             this->richTextBox2->Name = L"richTextBox2";
  123.             this->richTextBox2->Size = System::Drawing::Size(257, 51);
  124.             this->richTextBox2->TabIndex = 25;
  125.             this->richTextBox2->Text = L"";
  126.             this->richTextBox2->TextChanged += gcnew System::EventHandler(this, &MyForm4::richTextBox2_TextChanged);
  127.             //
  128.             // richTextBox1
  129.             //
  130.             this->richTextBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
  131.             this->richTextBox1->Location = System::Drawing::Point(101, 125);
  132.             this->richTextBox1->Name = L"richTextBox1";
  133.             this->richTextBox1->Size = System::Drawing::Size(257, 51);
  134.             this->richTextBox1->TabIndex = 24;
  135.             this->richTextBox1->Text = L"";
  136.             this->richTextBox1->TextChanged += gcnew System::EventHandler(this, &MyForm4::richTextBox1_TextChanged);
  137.             //
  138.             // button1
  139.             //
  140.             this->button1->Location = System::Drawing::Point(463, 429);
  141.             this->button1->Name = L"button1";
  142.             this->button1->Size = System::Drawing::Size(190, 63);
  143.             this->button1->TabIndex = 23;
  144.             this->button1->Text = L"Go back to menu";
  145.             this->button1->UseVisualStyleBackColor = true;
  146.             this->button1->Click += gcnew System::EventHandler(this, &MyForm4::button1_Click);
  147.             //
  148.             // label1
  149.             //
  150.             this->label1->AutoSize = true;
  151.             this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
  152.             this->label1->Location = System::Drawing::Point(375, 118);
  153.             this->label1->Name = L"label1";
  154.             this->label1->Size = System::Drawing::Size(42, 58);
  155.             this->label1->TabIndex = 32;
  156.             this->label1->Text = L"-";
  157.             //
  158.             // label2
  159.             //
  160.             this->label2->AutoSize = true;
  161.             this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
  162.             this->label2->Location = System::Drawing::Point(725, 118);
  163.             this->label2->Name = L"label2";
  164.             this->label2->Size = System::Drawing::Size(54, 58);
  165.             this->label2->TabIndex = 33;
  166.             this->label2->Text = L"=";
  167.             //
  168.             // MyForm4
  169.             //
  170.             this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
  171.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  172.             this->ClientSize = System::Drawing::Size(1161, 529);
  173.             this->Controls->Add(this->label2);
  174.             this->Controls->Add(this->label1);
  175.             this->Controls->Add(this->label4);
  176.             this->Controls->Add(this->label3);
  177.             this->Controls->Add(this->label5);
  178.             this->Controls->Add(this->richTextBox3);
  179.             this->Controls->Add(this->richTextBox2);
  180.             this->Controls->Add(this->richTextBox1);
  181.             this->Controls->Add(this->button1);
  182.             this->Name = L"MyForm4";
  183.             this->Text = L"Substraction";
  184.             this->ResumeLayout(false);
  185.             this->PerformLayout();
  186.  
  187.         }
  188. #pragma endregion
  189.     private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  190.         this->Hide();
  191.     }
  192.  
  193.     private: bool isAllowed(String^ str)
  194.     {
  195.         String^ allowedChar = "0123456789";
  196.  
  197.         for (int i = 0; i < str->Length; i++) {
  198.             if (!~allowedChar->IndexOf(str[i])) {
  199.                 return false;
  200.             }
  201.         }
  202.  
  203.         return true;
  204.     }
  205.  
  206.     private: void substract() {
  207.         String^ text1 = richTextBox1->Text;
  208.         String^ text2 = richTextBox2->Text;
  209.        
  210.         if (text1 != "" && isAllowed(text1) && text2 != "" && isAllowed(text2) &&
  211.             int(System::Convert::ToInt32(text1)) - int(System::Convert::ToInt32(text2)) > 0) {
  212.             RomanFigure temp = int(System::Convert::ToInt32(text1)) - int(System::Convert::ToInt32(text2));
  213.             richTextBox3->Text = marshal_as<String^>(temp.getRoman());
  214.         }
  215.     }
  216.  
  217.     private: System::Void richTextBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
  218.         substract();
  219.     }
  220.  
  221.     private: System::Void richTextBox2_TextChanged(System::Object^  sender, System::EventArgs^  e) {
  222.         substract();
  223.     }
  224. };
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement