NATIJASI:

9-MAVZU: GUI muhitida grafik imkoniyatlar

|
NATIJASI:
9-MAVZU: GUI muhitida grafik imkoniyatlar
|
bet | 3/3 | Sana | 07.07.2024 | Hajmi | 269,98 Kb. | | #266872 |
NATIJASI:
9-MAVZU: GUI muhitida grafik imkoniyatlar.
1-masala: GUI imkoniyatlaridan foydalangan holatda 4 ta label, 1 ta buttom va PictureBox oling va ularga sonlarni
kiritilganda, kiritilgan koordinatalar bo’yicha to’g’ri
chiqiz chizilsin.
Kodi:
NATIJASI:
#pragma once
namespace Draw {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
protected:
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::ColorDialog^ colorDialog1;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::TextBox^ textBox4;
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
(cli::safe_cast(this-
>pictureBox1))->BeginInit();
this->SuspendLayout();
// pictureBox1
this->pictureBox1->BackColor = System::Drawing::SystemColors::ActiveCaption;
this->pictureBox1->Location = System::Drawing::Point(21, 24);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(768, 440);
this->pictureBox1->TabIndex = 1;
this->pictureBox1->TabStop = false;
this->pictureBox1->Paint += gcnew
System::Windows::Forms::PaintEventHandler(this, &Form1::pictureBox1_Paint);
// button1
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15,
System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast(204)));
this->button1->Location = System::Drawing::Point(188, 578);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(358, 41);
this->button1->TabIndex = 2;
this->button1->Text = L"CHIZISH";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
// textBox1
this->textBox1->Location = System::Drawing::Point(24, 522);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(145, 20);
this->textBox1->TabIndex = 3;
// textBox2
this->textBox2->Location = System::Drawing::Point(201, 522);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(145, 20);
this->textBox2->TabIndex = 3;
// textBox3
this->textBox3->Location = System::Drawing::Point(434, 522);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(145, 20);
this->textBox3->TabIndex = 3;
// textBox4
this->textBox4->Location = System::Drawing::Point(634, 522);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(145, 20);
this->textBox4->TabIndex = 3;
// Form1
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(811, 631);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast(this-
>pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->Text = "DrawLine - chiziq chizish";
button1->Text = "CHIZISH";
}
private: System::Void pictureBox1_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e) {
int myPoint[4];
e->Graphics->DrawLine(System::Drawing::Pens::Red,
myPoint[1], myPoint[2], myPoint[3],
myPoint[4]);
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int myPoint[4];
myPoint[1] = Convert::ToInt32(textBox1->Text);
myPoint[2] = Convert::ToInt32(textBox2->Text);
myPoint[3] = Convert::ToInt32(textBox3->Text);
myPoint[4] = Convert::ToInt32(textBox4->Text);
pictureBox1->Refresh();
}
};
}
|
| |