Advertisement
peterzig

Form1 dla Wojtka

Jun 6th, 2020
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.51 KB | None | 0 0
  1. #pragma once
  2. #include <string>
  3. #include "Form2.h"
  4.  
  5. namespace CppCLRWinformsProjekt {
  6.  
  7.     using namespace System;
  8.     using namespace System::ComponentModel;
  9.     using namespace System::Collections;
  10.     using namespace System::Windows::Forms;
  11.     using namespace System::Data;
  12.     using namespace System::Drawing;
  13.     using namespace std;
  14.  
  15.     int number = 1;
  16.     int wynik = 0;
  17.    
  18.  
  19.     public ref class Form1 : public System::Windows::Forms::Form
  20.     {
  21.     public:
  22.         Form1(void)
  23.         {
  24.             InitializeComponent();
  25.         }
  26.  
  27.     protected:
  28.        
  29.         ~Form1()
  30.         {
  31.             if (components)
  32.             {
  33.                 delete components;
  34.             }
  35.         }
  36.     private: System::Windows::Forms::Button^ button1;
  37.     protected:
  38.     private: System::Windows::Forms::Button^ button2;
  39.     private: System::Windows::Forms::Label^ label1;
  40.     private: System::Windows::Forms::Label^ label2;
  41.     private: System::Windows::Forms::RadioButton^ radioButton1;
  42.     private: System::Windows::Forms::RadioButton^ radioButton2;
  43.     private: System::Windows::Forms::RadioButton^ radioButton3;
  44.  
  45.     private: System::Windows::Forms::Button^ button3;
  46.     private: System::Windows::Forms::MenuStrip^ menuStrip1;
  47.     private: System::Windows::Forms::ToolStripMenuItem^ nowyQuizToolStripMenuItem;
  48.     private: System::Windows::Forms::ToolStripMenuItem^ oAutorzeToolStripMenuItem;
  49.  
  50.  
  51.     private:
  52.        
  53.         System::ComponentModel::Container ^components;
  54.  
  55. #pragma region Windows Form Designer generated code
  56.        
  57.         void InitializeComponent(void)
  58.         {
  59.             this->button1 = (gcnew System::Windows::Forms::Button());
  60.             this->button2 = (gcnew System::Windows::Forms::Button());
  61.             this->label1 = (gcnew System::Windows::Forms::Label());
  62.             this->label2 = (gcnew System::Windows::Forms::Label());
  63.             this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
  64.             this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
  65.             this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());
  66.             this->button3 = (gcnew System::Windows::Forms::Button());
  67.             this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
  68.             this->nowyQuizToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  69.             this->oAutorzeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
  70.             this->menuStrip1->SuspendLayout();
  71.             this->SuspendLayout();
  72.             //
  73.             // button1
  74.             //
  75.             this->button1->Location = System::Drawing::Point(34, 55);
  76.             this->button1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  77.             this->button1->Name = L"button1";
  78.             this->button1->Size = System::Drawing::Size(112, 35);
  79.             this->button1->TabIndex = 0;
  80.             this->button1->Text = L"Poprzednie";
  81.             this->button1->UseVisualStyleBackColor = true;
  82.             this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
  83.             //
  84.             // button2
  85.             //
  86.             this->button2->Location = System::Drawing::Point(154, 55);
  87.             this->button2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  88.             this->button2->Name = L"button2";
  89.             this->button2->Size = System::Drawing::Size(112, 35);
  90.             this->button2->TabIndex = 1;
  91.             this->button2->Text = L"Następne";
  92.             this->button2->UseVisualStyleBackColor = true;
  93.             this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
  94.             //
  95.             // label1
  96.             //
  97.             this->label1->AutoSize = true;
  98.             this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  99.                 static_cast<System::Byte>(238)));
  100.             this->label1->Location = System::Drawing::Point(295, 57);
  101.             this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  102.             this->label1->Name = L"label1";
  103.             this->label1->Size = System::Drawing::Size(136, 33);
  104.             this->label1->TabIndex = 2;
  105.             this->label1->Text = L"Pytanie 1";
  106.             //
  107.             // label2
  108.             //
  109.             this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  110.                 static_cast<System::Byte>(238)));
  111.             this->label2->Location = System::Drawing::Point(36, 117);
  112.             this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  113.             this->label2->Name = L"label2";
  114.             this->label2->Size = System::Drawing::Size(719, 65);
  115.             this->label2->TabIndex = 3;
  116.             this->label2->Text = L"Kliknij aby poznać pytanie";
  117.             this->label2->Click += gcnew System::EventHandler(this, &Form1::label2_Click);
  118.             //
  119.             // radioButton1
  120.             //
  121.             this->radioButton1->AutoSize = true;
  122.             this->radioButton1->Location = System::Drawing::Point(42, 187);
  123.             this->radioButton1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  124.             this->radioButton1->Name = L"radioButton1";
  125.             this->radioButton1->Size = System::Drawing::Size(125, 24);
  126.             this->radioButton1->TabIndex = 4;
  127.             this->radioButton1->TabStop = true;
  128.             this->radioButton1->Text = L"odpowiedź A";
  129.             this->radioButton1->UseVisualStyleBackColor = true;
  130.             this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
  131.             //
  132.             // radioButton2
  133.             //
  134.             this->radioButton2->AutoSize = true;
  135.             this->radioButton2->Location = System::Drawing::Point(42, 221);
  136.             this->radioButton2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  137.             this->radioButton2->Name = L"radioButton2";
  138.             this->radioButton2->Size = System::Drawing::Size(125, 24);
  139.             this->radioButton2->TabIndex = 5;
  140.             this->radioButton2->TabStop = true;
  141.             this->radioButton2->Text = L"odpowiedź B";
  142.             this->radioButton2->UseVisualStyleBackColor = true;
  143.             //
  144.             // radioButton3
  145.             //
  146.             this->radioButton3->AutoSize = true;
  147.             this->radioButton3->Location = System::Drawing::Point(43, 255);
  148.             this->radioButton3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  149.             this->radioButton3->Name = L"radioButton3";
  150.             this->radioButton3->Size = System::Drawing::Size(125, 24);
  151.             this->radioButton3->TabIndex = 6;
  152.             this->radioButton3->TabStop = true;
  153.             this->radioButton3->Text = L"odpowiedź C";
  154.             this->radioButton3->UseVisualStyleBackColor = true;
  155.             //
  156.             // button3
  157.             //
  158.             this->button3->Location = System::Drawing::Point(40, 289);
  159.             this->button3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  160.             this->button3->Name = L"button3";
  161.             this->button3->Size = System::Drawing::Size(112, 35);
  162.             this->button3->TabIndex = 8;
  163.             this->button3->Text = L"OK";
  164.             this->button3->UseVisualStyleBackColor = true;
  165.             this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
  166.             //
  167.             // menuStrip1
  168.             //
  169.             this->menuStrip1->GripMargin = System::Windows::Forms::Padding(2, 2, 0, 2);
  170.             this->menuStrip1->ImageScalingSize = System::Drawing::Size(24, 24);
  171.             this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {
  172.                 this->nowyQuizToolStripMenuItem,
  173.                     this->oAutorzeToolStripMenuItem
  174.             });
  175.             this->menuStrip1->Location = System::Drawing::Point(0, 0);
  176.             this->menuStrip1->Name = L"menuStrip1";
  177.             this->menuStrip1->Size = System::Drawing::Size(892, 33);
  178.             this->menuStrip1->TabIndex = 9;
  179.             this->menuStrip1->Text = L"menuStrip1";
  180.             //
  181.             // nowyQuizToolStripMenuItem
  182.             //
  183.             this->nowyQuizToolStripMenuItem->Name = L"nowyQuizToolStripMenuItem";
  184.             this->nowyQuizToolStripMenuItem->Size = System::Drawing::Size(112, 29);
  185.             this->nowyQuizToolStripMenuItem->Text = L"Nowy quiz";
  186.             this->nowyQuizToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::nowyQuizToolStripMenuItem_Click);
  187.             //
  188.             // oAutorzeToolStripMenuItem
  189.             //
  190.             this->oAutorzeToolStripMenuItem->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
  191.             this->oAutorzeToolStripMenuItem->Name = L"oAutorzeToolStripMenuItem";
  192.             this->oAutorzeToolStripMenuItem->Size = System::Drawing::Size(106, 29);
  193.             this->oAutorzeToolStripMenuItem->Text = L"O autorze";
  194.             this->oAutorzeToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::oAutorzeToolStripMenuItem_Click);
  195.             //
  196.             // Form1
  197.             //
  198.             this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
  199.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  200.             this->ClientSize = System::Drawing::Size(892, 352);
  201.             this->Controls->Add(this->button3);
  202.             this->Controls->Add(this->radioButton3);
  203.             this->Controls->Add(this->radioButton2);
  204.             this->Controls->Add(this->radioButton1);
  205.             this->Controls->Add(this->label2);
  206.             this->Controls->Add(this->label1);
  207.             this->Controls->Add(this->button2);
  208.             this->Controls->Add(this->button1);
  209.             this->Controls->Add(this->menuStrip1);
  210.             this->MainMenuStrip = this->menuStrip1;
  211.             this->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  212.             this->Name = L"Form1";
  213.             this->Text = L"Quiz o psach - Krzysztof Witosiński";
  214.             this->menuStrip1->ResumeLayout(false);
  215.             this->menuStrip1->PerformLayout();
  216.             this->ResumeLayout(false);
  217.             this->PerformLayout();
  218.  
  219.         }
  220.        
  221. #pragma endregion
  222.     private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
  223.         if (number == 1) {
  224.            
  225.             label2->Text = " Rasa wyhodowana we Francji na przełomie XIX i XX w. Psy osiągają masę 8-14 kg, mają duże, stojące uszy";
  226.             radioButton1->Text = "pekińczyk";
  227.             radioButton2->Text = "mops";
  228.             radioButton3->Text = "buldog francuski"; //poprawna odp
  229.         }
  230.         if (number == 2) {
  231.             label2->Text = "Rasa zaliczana do grupy molosów w typie mastifa, pochodząca z Półwyspu Apenińskiego. Pies stróżujący, obronny, tropiący i policyjny";
  232.             radioButton1->Text = "cane corso";//poprawna odp
  233.             radioButton2->Text = "rottweiler";
  234.             radioButton3->Text = "bokser";
  235.         }
  236.         if (number == 3) {
  237.             label2->Text = "Rasa z grupy terierów, wyhodowana w Anglii w połowie XIX w. w wyniku krzyżowania dawnych ras terierów z buldogiem angielskim i dalmatyńczykiem";
  238.             radioButton1->Text = "bulterier";//poprawna odp
  239.             radioButton2->Text = "terier tybetański";
  240.             radioButton3->Text = "foksterier krótkowłosy";
  241.         }
  242.         if (number == 4) {
  243.             label2->Text = "Rasa wyhodowana w Niemczech, znana od XVIII w., początkowo używana do polowań na dziki i niedźwiedzie, a nawet do walk z bykami";
  244.             radioButton1->Text = "bulldog angielski";
  245.             radioButton2->Text = "bokser";//poprawna odp
  246.             radioButton3->Text = "mastif neapolitański";
  247.         }
  248.         if (number == 5) {
  249.             label2->Text = "Rasa zaliczana do psów gończych, wyhodowana w Wielkiej Brytanii przypuszczalnie pod koniec XV wieku";
  250.             radioButton1->Text = "basset";
  251.             radioButton2->Text = "posokowiec bawarski";
  252.             radioButton3->Text = "beagle";//poprawna odp
  253.         }
  254.         if (number == 6) {
  255.             label2->Text = "Niewielki pies pokojowy pochodzenia azjatyckiego";
  256.             radioButton1->Text = "mops";
  257.             radioButton2->Text = "boston terrier";//poprawna odp
  258.             radioButton3->Text = "papillon";
  259.         }
  260.         if (number == 7) {
  261.             label2->Text = "Rasa psów myśliwskich zaliczana do psów gończych, cechująca się znaczną wytrzymałością i wytrwałością w pogoni za zwierzyną";
  262.             radioButton1->Text = "szpic fiński";
  263.             radioButton2->Text = "niemiecki terrier myśliwski";
  264.             radioButton3->Text = "jamnik";//poprawna odp
  265.         }
  266.         if (number == 8) {
  267.             label2->Text = "Rasa zaliczana do grupy molosów, wyhodowana jako pies bojowy i do polowania na duże ssaki";
  268.             radioButton1->Text = "dog argentyński";
  269.             radioButton2->Text = "dog niemiecki";//poprawna odp
  270.             radioButton3->Text = "dog de bordeaux";
  271.         }
  272.         if (number == 9) {
  273.             label2->Text = "Rasa o krępej budowie ciała, krótkich mocnych łapach i żuchwie wysuniętej do przodu pyska";
  274.             radioButton1->Text = "nowofundland";
  275.             radioButton2->Text = "buldog amerykański";
  276.             radioButton3->Text = "buldog angielski";//poprawna odp
  277.         }
  278.         if (number == 10) {
  279.             label2->Text = "Rasa niegdyś używana w trakcie polowań do aportowania ptactwa wodnego, obecnie głównie jako psy ozdobne";
  280.             radioButton1->Text = "pudel";//poprawna odp
  281.             radioButton2->Text = "samojed";
  282.             radioButton3->Text = "chow chow";
  283.         }
  284.         if (number == 11) {
  285.             label2->Text = "Rasa psa myśliwskiego, wykorzystywanego głównie do wystawiania, wypłaszania i aportowania ptactwa";
  286.             radioButton1->Text = "seter angielski";
  287.             radioButton2->Text = "wyżeł niemiecki";//poprawna odp
  288.             radioButton3->Text = "golden retriever";
  289.         }
  290.         if (number == 12) {
  291.             label2->Text = "JRasa wyhodowana w średniowieczu w Meksyku. Wywodzi się od świętego psa Azteków - teechichi";
  292.             radioButton1->Text = "yorkshire terrier";
  293.             radioButton2->Text = "chihuahua";//poprawna odp
  294.             radioButton3->Text = "maltańczyk";
  295.         }
  296.     }
  297. private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
  298.     if (number == 1) {
  299.         if (radioButton1->Checked) {
  300.             MessageBox::Show("Odpowiedź niepoprawna");
  301.         }
  302.         if (radioButton2->Checked) {
  303.             MessageBox::Show("Odpowiedź niepoprawna");
  304.         }
  305.         if (radioButton3->Checked) {
  306.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  307.             wynik += 1;
  308.         }
  309.     }
  310.     if (number == 2) {
  311.         if (radioButton1->Checked) {
  312.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  313.             wynik += 1;
  314.         }
  315.         if (radioButton2->Checked) {
  316.             MessageBox::Show("Odpowiedź niepoprawna");
  317.         }
  318.         if (radioButton3->Checked) {
  319.             MessageBox::Show("Odpowiedź niepoprawna");
  320.         }
  321.     }
  322.     if (number == 3) {
  323.         if (radioButton1->Checked) {
  324.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  325.             wynik += 1;
  326.         }
  327.         if (radioButton2->Checked) {
  328.             MessageBox::Show("Odpowiedź niepoprawna");
  329.         }
  330.         if (radioButton3->Checked) {
  331.             MessageBox::Show("Odpowiedź niepoprawna");
  332.         }
  333.     }
  334.     if (number == 4) {
  335.         if (radioButton1->Checked) {
  336.             MessageBox::Show("Odpowiedź niepoprawna");
  337.         }
  338.         if (radioButton2->Checked) {
  339.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  340.             wynik += 1;
  341.         }
  342.         if (radioButton3->Checked) {
  343.             MessageBox::Show("Odpowiedź niepoprawna");
  344.         }
  345.     }
  346.     if (number == 5) {
  347.         if (radioButton1->Checked) {
  348.             MessageBox::Show("Odpowiedź niepoprawna");
  349.         }
  350.         if (radioButton2->Checked) {
  351.             MessageBox::Show("Odpowiedź niepoprawna");
  352.         }
  353.         if (radioButton3->Checked) {
  354.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  355.             wynik += 1;
  356.         }
  357.     }
  358.     if (number == 6) {
  359.         if (radioButton1->Checked) {
  360.             MessageBox::Show("Odpowiedź niepoprawna");
  361.         }
  362.         if (radioButton2->Checked) {
  363.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  364.             wynik += 1;
  365.         }
  366.         if (radioButton3->Checked) {
  367.             MessageBox::Show("Odpowiedź niepoprawna");
  368.         }
  369.     }
  370.     if (number == 7) {
  371.         if (radioButton1->Checked) {
  372.             MessageBox::Show("Odpowiedź niepoprawna");
  373.         }
  374.         if (radioButton2->Checked) {
  375.             MessageBox::Show("Odpowiedź niepoprawna");
  376.         }
  377.         if (radioButton3->Checked) {
  378.    
  379.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  380.             wynik += 1;
  381.         }
  382.     }
  383.     if (number == 8) {
  384.         if (radioButton1->Checked) {
  385.             MessageBox::Show("Odpowiedź niepoprawna");
  386.         }
  387.         if (radioButton2->Checked) {
  388.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  389.             wynik += 1;
  390.         }
  391.         if (radioButton3->Checked) {
  392.             MessageBox::Show("Odpowiedź niepoprawna");
  393.         }
  394.     }
  395.     if (number == 9) {
  396.         if (radioButton1->Checked) {
  397.             MessageBox::Show("Odpowiedź niepoprawna");
  398.         }
  399.         if (radioButton2->Checked) {
  400.             MessageBox::Show("Odpowiedź niepoprawna");
  401.         }
  402.         if (radioButton3->Checked) {
  403.  
  404.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  405.             wynik += 1;
  406.         }
  407.     }
  408.     if (number == 10) {
  409.         if (radioButton1->Checked) {
  410.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  411.             wynik += 1;
  412.         }
  413.         if (radioButton2->Checked) {
  414.             MessageBox::Show("Odpowiedź niepoprawna");
  415.         }
  416.         if (radioButton3->Checked) {
  417.             MessageBox::Show("Odpowiedź niepoprawna");
  418.         }
  419.     }
  420.     if (number == 11) {
  421.         if (radioButton1->Checked) {
  422.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  423.             wynik += 1;
  424.         }
  425.         if (radioButton2->Checked) {
  426.             MessageBox::Show("Odpowiedź niepoprawna");
  427.         }
  428.         if (radioButton3->Checked) {
  429.             MessageBox::Show("Odpowiedź niepoprawna");
  430.         }
  431.     }
  432.     if (number == 12) {
  433.         if (radioButton1->Checked) {
  434.             MessageBox::Show("Odpowiedź niepoprawna");
  435.         }
  436.         if (radioButton2->Checked) {
  437.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  438.             wynik += 1;
  439.         }
  440.         if (radioButton3->Checked) {
  441.             MessageBox::Show("Odpowiedź niepoprawna");
  442.         }
  443.         MessageBox::Show("Twój wynik quizu: " + wynik + " na 12 możliwych", "Wynik");
  444.     }
  445. }
  446. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  447.     number++;
  448.     label1->Text = "Pytanie " + number;
  449.     label2->Text = "Kliknij aby poznać pytanie";
  450.     radioButton1->Text = "odpowiedź A";
  451.     radioButton2->Text = "odpowiedź B";
  452.     radioButton3->Text = "odpowiedź C";
  453.     radioButton1->Checked = false;
  454.     radioButton2->Checked = false;
  455.     radioButton3->Checked = false;
  456.     if (number >= 12) {
  457.         MessageBox::Show("Dwunaste pytanie jest ostatnie!");
  458.         number = 12;
  459.         label1->Text = "Pytanie " + number;
  460.     }
  461. }
  462. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  463.     number--;
  464.     label1->Text = "Pytanie " + number;
  465.     label2->Text = "Kliknij aby poznać pytanie";
  466.     radioButton1->Text = "odpowiedź A";
  467.     radioButton2->Text = "odpowiedź B";
  468.     radioButton3->Text = "odpowiedź C";
  469.     radioButton1->Checked = false;
  470.     radioButton2->Checked = false;
  471.     radioButton3->Checked = false;
  472.     if (number <= 1) {
  473.         MessageBox::Show("Cofnięto do pierwsze pytanie!");
  474.         number = 1;
  475.         label1->Text = "Pytanie " + number;
  476.     }
  477. }
  478. private: System::Void radioButton1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  479.  
  480. }
  481. private: System::Void oAutorzeToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  482.     Form2^ form2 = gcnew Form2;
  483.     form2->Show();
  484. }
  485. private: System::Void nowyQuizToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
  486.     number = 1;
  487.     label1->Text = "Pytanie " + number;
  488. }
  489. };
  490. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement