Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "RomanFigure.h"
- #include <msclr\marshal_cppstd.h>
- namespace OOP_lab6 {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- using namespace msclr::interop;
- /// <summary>
- /// Summary for MyForm4
- /// </summary>
- public ref class MyForm4 : public System::Windows::Forms::Form
- {
- public:
- MyForm4(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~MyForm4()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Label^ label4;
- protected:
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Label^ label5;
- private: System::Windows::Forms::RichTextBox^ richTextBox3;
- private: System::Windows::Forms::RichTextBox^ richTextBox2;
- private: System::Windows::Forms::RichTextBox^ richTextBox1;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- 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->label4 = (gcnew System::Windows::Forms::Label());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->label5 = (gcnew System::Windows::Forms::Label());
- this->richTextBox3 = (gcnew System::Windows::Forms::RichTextBox());
- this->richTextBox2 = (gcnew System::Windows::Forms::RichTextBox());
- this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->SuspendLayout();
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
- this->label4->Location = System::Drawing::Point(177, 46);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(106, 58);
- this->label4->TabIndex = 31;
- this->label4->Text = L"dec";
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
- this->label3->Location = System::Drawing::Point(525, 46);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(106, 58);
- this->label3->TabIndex = 30;
- this->label3->Text = L"dec";
- //
- // label5
- //
- this->label5->AutoSize = true;
- this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
- this->label5->Location = System::Drawing::Point(859, 46);
- this->label5->Name = L"label5";
- this->label5->Size = System::Drawing::Size(168, 58);
- this->label5->TabIndex = 29;
- this->label5->Text = L"roman";
- //
- // richTextBox3
- //
- this->richTextBox3->Enabled = false;
- this->richTextBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
- this->richTextBox3->Location = System::Drawing::Point(811, 125);
- this->richTextBox3->Name = L"richTextBox3";
- this->richTextBox3->Size = System::Drawing::Size(257, 51);
- this->richTextBox3->TabIndex = 26;
- this->richTextBox3->Text = L"";
- //
- // richTextBox2
- //
- this->richTextBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
- this->richTextBox2->Location = System::Drawing::Point(438, 125);
- this->richTextBox2->Name = L"richTextBox2";
- this->richTextBox2->Size = System::Drawing::Size(257, 51);
- this->richTextBox2->TabIndex = 25;
- this->richTextBox2->Text = L"";
- this->richTextBox2->TextChanged += gcnew System::EventHandler(this, &MyForm4::richTextBox2_TextChanged);
- //
- // richTextBox1
- //
- this->richTextBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
- this->richTextBox1->Location = System::Drawing::Point(101, 125);
- this->richTextBox1->Name = L"richTextBox1";
- this->richTextBox1->Size = System::Drawing::Size(257, 51);
- this->richTextBox1->TabIndex = 24;
- this->richTextBox1->Text = L"";
- this->richTextBox1->TextChanged += gcnew System::EventHandler(this, &MyForm4::richTextBox1_TextChanged);
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(463, 429);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(190, 63);
- this->button1->TabIndex = 23;
- this->button1->Text = L"Go back to menu";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm4::button1_Click);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
- this->label1->Location = System::Drawing::Point(375, 118);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(42, 58);
- this->label1->TabIndex = 32;
- this->label1->Text = L"-";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
- this->label2->Location = System::Drawing::Point(725, 118);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(54, 58);
- this->label2->TabIndex = 33;
- this->label2->Text = L"=";
- //
- // MyForm4
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(1161, 529);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->label4);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->label5);
- this->Controls->Add(this->richTextBox3);
- this->Controls->Add(this->richTextBox2);
- this->Controls->Add(this->richTextBox1);
- this->Controls->Add(this->button1);
- this->Name = L"MyForm4";
- this->Text = L"Substraction";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- this->Hide();
- }
- private: bool isAllowed(String^ str)
- {
- String^ allowedChar = "0123456789";
- for (int i = 0; i < str->Length; i++) {
- if (!~allowedChar->IndexOf(str[i])) {
- return false;
- }
- }
- return true;
- }
- private: void substract() {
- String^ text1 = richTextBox1->Text;
- String^ text2 = richTextBox2->Text;
- if (text1 != "" && isAllowed(text1) && text2 != "" && isAllowed(text2) &&
- int(System::Convert::ToInt32(text1)) - int(System::Convert::ToInt32(text2)) > 0) {
- RomanFigure temp = int(System::Convert::ToInt32(text1)) - int(System::Convert::ToInt32(text2));
- richTextBox3->Text = marshal_as<String^>(temp.getRoman());
- }
- }
- private: System::Void richTextBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- substract();
- }
- private: System::Void richTextBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- substract();
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement