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 MyForm2
- /// </summary>
- public ref class MyForm2 : public System::Windows::Forms::Form
- {
- public:
- MyForm2(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~MyForm2()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Label^ label2;
- protected:
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::RichTextBox^ richTextBox3;
- private: System::Windows::Forms::RichTextBox^ richTextBox1;
- private: System::Windows::Forms::Button^ button1;
- 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->label2 = (gcnew System::Windows::Forms::Label());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->richTextBox3 = (gcnew System::Windows::Forms::RichTextBox());
- this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->SuspendLayout();
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
- this->label2->Location = System::Drawing::Point(342, 238);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(454, 58);
- this->label2->TabIndex = 15;
- this->label2->Text = L"Output dec number";
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 30));
- this->label1->Location = System::Drawing::Point(342, 29);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(477, 58);
- this->label1->TabIndex = 14;
- this->label1->Text = L"Input roman number";
- //
- // richTextBox3
- //
- this->richTextBox3->Enabled = false;
- this->richTextBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
- this->richTextBox3->Location = System::Drawing::Point(419, 332);
- this->richTextBox3->Name = L"richTextBox3";
- this->richTextBox3->Size = System::Drawing::Size(342, 51);
- this->richTextBox3->TabIndex = 13;
- this->richTextBox3->Text = L"";
- //
- // richTextBox1
- //
- this->richTextBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 20));
- this->richTextBox1->Location = System::Drawing::Point(419, 122);
- this->richTextBox1->Name = L"richTextBox1";
- this->richTextBox1->Size = System::Drawing::Size(342, 51);
- this->richTextBox1->TabIndex = 12;
- this->richTextBox1->Text = L"";
- this->richTextBox1->TextChanged += gcnew System::EventHandler(this, &MyForm2::richTextBox1_TextChanged);
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(488, 437);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(190, 63);
- this->button1->TabIndex = 11;
- this->button1->Text = L"Go back to menu";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm2::button1_Click);
- //
- // MyForm2
- //
- 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->richTextBox3);
- this->Controls->Add(this->richTextBox1);
- this->Controls->Add(this->button1);
- this->Name = L"MyForm2";
- this->Text = L"Roman To Dec";
- 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 = "IVXLCDM ";
- for (int i = 0; i < str->Length; i++) {
- if (!~allowedChar->IndexOf(str[i])) {
- return false;
- }
- }
- return true;
- }
- private: System::Void richTextBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- String^ text = richTextBox1->Text;
- String^ allowedChar = "IVXLCDM ";
- if (text != "" && isAllowed(text)) {
- RomanFigure temp;
- temp.setRoman(marshal_as<std::string>((text)));
- richTextBox3->Text = marshal_as<String^>(std::to_string(temp.getDecimal()));
- }
- }
- };
- }
Add Comment
Please, Sign In to add comment