Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <cstdio>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- namespace CppCLRWinformsProjekt {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- int _ticks;
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- }
- protected:
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::MenuStrip^ menuStrip1;
- protected:
- private: System::Windows::Forms::ToolStripMenuItem^ wybórZadaniaToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ zadanie6ToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ zadanie8ToolStripMenuItem;
- private: System::Windows::Forms::ColorDialog^ colorDialog1;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::PictureBox^ pictureBox1;
- private: System::Windows::Forms::Timer^ timer1;
- private: System::ComponentModel::IContainer^ components;
- protected:
- private:
- #pragma region Windows Form Designer generated code
- void InitializeComponent(void)
- {
- this->components = (gcnew System::ComponentModel::Container());
- this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
- this->wybórZadaniaToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->zadanie6ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->zadanie8ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
- this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
- this->menuStrip1->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
- this->SuspendLayout();
- //
- // menuStrip1
- //
- this->menuStrip1->GripMargin = System::Windows::Forms::Padding(2, 2, 0, 2);
- this->menuStrip1->ImageScalingSize = System::Drawing::Size(24, 24);
- this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) { this->wybórZadaniaToolStripMenuItem });
- this->menuStrip1->Location = System::Drawing::Point(0, 0);
- this->menuStrip1->Name = L"menuStrip1";
- this->menuStrip1->Size = System::Drawing::Size(986, 36);
- this->menuStrip1->TabIndex = 2;
- this->menuStrip1->Text = L"menuStrip1";
- //
- // wybórZadaniaToolStripMenuItem
- //
- this->wybórZadaniaToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {
- this->zadanie6ToolStripMenuItem,
- this->zadanie8ToolStripMenuItem
- });
- this->wybórZadaniaToolStripMenuItem->Name = L"wybórZadaniaToolStripMenuItem";
- this->wybórZadaniaToolStripMenuItem->Size = System::Drawing::Size(147, 32);
- this->wybórZadaniaToolStripMenuItem->Text = L"Wybór zadania";
- this->wybórZadaniaToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::wybórZadaniaToolStripMenuItem_Click);
- //
- // zadanie6ToolStripMenuItem
- //
- this->zadanie6ToolStripMenuItem->Name = L"zadanie6ToolStripMenuItem";
- this->zadanie6ToolStripMenuItem->Size = System::Drawing::Size(191, 34);
- this->zadanie6ToolStripMenuItem->Text = L"Zadanie 6";
- this->zadanie6ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::zadanie6ToolStripMenuItem_Click);
- //
- // zadanie8ToolStripMenuItem
- //
- this->zadanie8ToolStripMenuItem->Name = L"zadanie8ToolStripMenuItem";
- this->zadanie8ToolStripMenuItem->Size = System::Drawing::Size(191, 34);
- this->zadanie8ToolStripMenuItem->Text = L"Zadanie 8";
- this->zadanie8ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::zadanie8ToolStripMenuItem_Click);
- //
- // colorDialog1
- //
- this->colorDialog1->AnyColor = true;
- //
- // textBox1
- //
- this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(238)));
- this->textBox1->Location = System::Drawing::Point(318, 163);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(294, 35);
- this->textBox1->TabIndex = 3;
- this->textBox1->Visible = false;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(318, 226);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(294, 103);
- this->button1->TabIndex = 4;
- this->button1->Text = L"Zmień kolor tekstu";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Visible = false;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(318, 89);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(140, 46);
- this->button2->TabIndex = 6;
- this->button2->Text = L"Start";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Visible = false;
- this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(472, 89);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(140, 46);
- this->button3->TabIndex = 7;
- this->button3->Text = L"Stop";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Visible = false;
- this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
- //
- // pictureBox1
- //
- this->pictureBox1->ImageLocation = L"nyan1.bmp";
- this->pictureBox1->Location = System::Drawing::Point(318, 163);
- this->pictureBox1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->pictureBox1->Name = L"pictureBox1";
- this->pictureBox1->Size = System::Drawing::Size(319, 200);
- this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;
- this->pictureBox1->TabIndex = 8;
- this->pictureBox1->TabStop = false;
- this->pictureBox1->Visible = false;
- //
- // timer1
- //
- this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(986, 528);
- this->Controls->Add(this->pictureBox1);
- this->Controls->Add(this->button3);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->menuStrip1);
- this->MainMenuStrip = this->menuStrip1;
- this->Name = L"Form1";
- this->Text = L"Timer Zuzanna Prościak";
- this->menuStrip1->ResumeLayout(false);
- this->menuStrip1->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- if (colorDialog1->ShowDialog() != System::Windows::Forms::DialogResult::Cancel) {
- textBox1->ForeColor = colorDialog1->Color;
- }
- }
- private: System::Void zadanie6ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
- textBox1->Visible = true;
- button1->Visible = true;
- button2->Visible = false;
- button3->Visible = false;
- pictureBox1->Visible = false;
- }
- private: System::Void zadanie8ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
- textBox1->Visible = false;
- button1->Visible = false;
- button2->Visible = true;
- button3->Visible = true;
- pictureBox1->Visible = true;
- }
- private: System::Void wybórZadaniaToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- timer1->Enabled = true;
- timer1->Interval = 1000;
- timer1->Start();
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- timer1->Enabled = false;
- pictureBox1->ImageLocation = "nyan1.bmp";
- }
- private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
- _ticks++;
- if (_ticks % 2 == 0) {
- pictureBox1->ImageLocation = "nyan2.bmp";
- }
- else
- {
- pictureBox1->ImageLocation = "nyan1.bmp";
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment