Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace Лаб13 {
- 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>
- /// Сводка для MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- public:
- MyForm(void)
- {
- InitializeComponent();
- //
- //TODO: добавьте код конструктора
- //
- }
- protected:
- /// <summary>
- /// Освободить все используемые ресурсы.
- /// </summary>
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::PictureBox^ pictureBox1;
- protected:
- private: System::Windows::Forms::PictureBox^ pictureBox2;
- private: System::Windows::Forms::PictureBox^ pictureBox3;
- private: System::Windows::Forms::PictureBox^ pictureBox4;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::Label^ label2;
- protected:
- private:
- /// <summary>
- /// Обязательная переменная конструктора.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Требуемый метод для поддержки конструктора — не изменяйте
- /// содержимое этого метода с помощью редактора кода.
- /// </summary>
- void InitializeComponent(void)
- {
- System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
- this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
- this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());
- this->pictureBox3 = (gcnew System::Windows::Forms::PictureBox());
- this->pictureBox4 = (gcnew System::Windows::Forms::PictureBox());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->label2 = (gcnew System::Windows::Forms::Label());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox2))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox3))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox4))->BeginInit();
- this->SuspendLayout();
- //
- // pictureBox1
- //
- this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox1.Image")));
- this->pictureBox1->Location = System::Drawing::Point(12, 12);
- this->pictureBox1->Name = L"pictureBox1";
- this->pictureBox1->Size = System::Drawing::Size(461, 130);
- this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
- this->pictureBox1->TabIndex = 0;
- this->pictureBox1->TabStop = false;
- //
- // pictureBox2
- //
- this->pictureBox2->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox2.Image")));
- this->pictureBox2->Location = System::Drawing::Point(479, 12);
- this->pictureBox2->Name = L"pictureBox2";
- this->pictureBox2->Size = System::Drawing::Size(232, 44);
- this->pictureBox2->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
- this->pictureBox2->TabIndex = 1;
- this->pictureBox2->TabStop = false;
- //
- // pictureBox3
- //
- this->pictureBox3->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox3.Image")));
- this->pictureBox3->Location = System::Drawing::Point(479, 62);
- this->pictureBox3->Name = L"pictureBox3";
- this->pictureBox3->Size = System::Drawing::Size(219, 38);
- this->pictureBox3->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
- this->pictureBox3->TabIndex = 2;
- this->pictureBox3->TabStop = false;
- //
- // pictureBox4
- //
- this->pictureBox4->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox4.Image")));
- this->pictureBox4->Location = System::Drawing::Point(479, 106);
- this->pictureBox4->Name = L"pictureBox4";
- this->pictureBox4->Size = System::Drawing::Size(241, 36);
- this->pictureBox4->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
- this->pictureBox4->TabIndex = 3;
- this->pictureBox4->TabStop = false;
- //
- // label1
- //
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->label1->Location = System::Drawing::Point(6, 162);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(122, 40);
- this->label1->TabIndex = 4;
- this->label1->Text = L"a = 100";
- //
- // textBox1
- //
- this->textBox1->Cursor = System::Windows::Forms::Cursors::Default;
- this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->textBox1->Location = System::Drawing::Point(12, 205);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(163, 41);
- this->textBox1->TabIndex = 5;
- this->textBox1->Text = L"Введите Х";
- this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
- //
- // label2
- //
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 19, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(204)));
- this->label2->Location = System::Drawing::Point(213, 175);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(485, 57);
- this->label2->TabIndex = 6;
- this->label2->Text = L"f(x) = ";
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(828, 306);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->pictureBox4);
- this->Controls->Add(this->pictureBox3);
- this->Controls->Add(this->pictureBox2);
- this->Controls->Add(this->pictureBox1);
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox2))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox3))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox4))->EndInit();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) { //обработка ввода
- String^ s; //строка в которую мы будем считывать значения из textBox
- try { // с помощью обработки ошибок мы будем проверять, что находится в textBox число или текст
- double x = Double::Parse(textBox1->Text); //если в textBox введено число
- if (x <= 0) { //математические преобразования согласно условию задания
- x = cos(x) + pow(x, 3);
- }
- else if (x > 0 && x <= 100) {
- x = sin(x) * pow(x, 1 / 3);
- }
- else {
- x = 8 + cos(3 * x);
- }
- label2->Text = "f(x) = " + x.ToString();
- }
- catch (FormatException^) { //если в textBox введено всё что угодно, кроме числа
- label2->Text = "f(x) = "; //ничего не выводим, тк значение функции невозможно посчитать
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement