Facebook
From Mature Gibbon, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 137
  1. #pragma once
  2.  
  3. namespace Project9 {
  4.  
  5.         using namespace System;
  6.         using namespace System::ComponentModel;
  7.         using namespace System::Collections;
  8.         using namespace System::Windows::Forms;
  9.         using namespace System::Data;
  10.         using namespace System::Drawing;
  11.  
  12.         /// <summary>
  13.         /// Summary for MyForm
  14.         /// </summary>
  15.         public ref class MyForm : public System::Windows::Forms::Form
  16.         {
  17.         public:
  18.                 MyForm(void)
  19.                 {
  20.                         InitializeComponent();
  21.                         //
  22.                         //TODO: Add the constructor code here
  23.                         //
  24.                 }
  25.  
  26.         protected:
  27.                 /// <summary>
  28.                 /// Clean up any resources being used.
  29.                 /// </summary>
  30.                 ~MyForm()
  31.                 {
  32.                         if (components)
  33.                         {
  34.                                 delete components;
  35.                         }
  36.                 }
  37.         private: System::Windows::Forms::Label^  label1;
  38.         private: System::Windows::Forms::ComboBox^  comboBox1;
  39.         private: System::Windows::Forms::TextBox^  textBox1;
  40.         private: System::Windows::Forms::Button^  button1;
  41.  
  42.         private: System::Windows::Forms::Label^  label2;
  43.         private: System::Windows::Forms::Label^  label3;
  44.         private: System::Windows::Forms::GroupBox^  groupBox1;
  45.         private: System::Windows::Forms::RadioButton^  radioButton4;
  46.         private: System::Windows::Forms::RadioButton^  radioButton3;
  47.         private: System::Windows::Forms::RadioButton^  radioButton2;
  48.         private: System::Windows::Forms::RadioButton^  radioButton1;
  49.  
  50.         private: System::ComponentModel::IContainer^  components;
  51.         protected:
  52.  
  53.         private:
  54.                 /// <summary>
  55.                 /// Required designer variable.
  56.                 /// </summary>
  57.  
  58.  
  59. #pragma region Windows Form Designer generated code
  60.                 /// <summary>
  61.                 /// Required method for Designer support - do not modify
  62.                 /// the contents of this method with the code editor.
  63.                 /// </summary>
  64.                 void InitializeComponent(void)
  65.                 {
  66.                         this->label1 = (gcnew System::Windows::Forms::Label());
  67.                         this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
  68.                         this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  69.                         this->button1 = (gcnew System::Windows::Forms::Button());
  70.                         this->label2 = (gcnew System::Windows::Forms::Label());
  71.                         this->label3 = (gcnew System::Windows::Forms::Label());
  72.                         this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
  73.                         this->radioButton4 = (gcnew System::Windows::Forms::RadioButton());
  74.                         this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());
  75.                         this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
  76.                         this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
  77.                         this->groupBox1->SuspendLayout();
  78.                         this->SuspendLayout();
  79.                         //
  80.                         // label1
  81.                         //
  82.                         this->label1->Location = System::Drawing::Point(52, 74);
  83.                         this->label1->Name = L"label1";
  84.                         this->label1->Size = System::Drawing::Size(174, 16);
  85.                         this->label1->TabIndex = 0;
  86.                         this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
  87.                         //
  88.                         // comboBox1
  89.                         //
  90.                         this->comboBox1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
  91.                         this->comboBox1->FormattingEnabled = true;
  92.                         this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) { L"Euro", L"Dolar", L"Funt" });
  93.                         this->comboBox1->Location = System::Drawing::Point(135, 36);
  94.                         this->comboBox1->Name = L"comboBox1";
  95.                         this->comboBox1->Size = System::Drawing::Size(100, 21);
  96.                         this->comboBox1->TabIndex = 1;
  97.                         this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::comboBox1_SelectedIndexChanged);
  98.                         //
  99.                         // textBox1
  100.                         //
  101.                         this->textBox1->Location = System::Drawing::Point(29, 36);
  102.                         this->textBox1->Name = L"textBox1";
  103.                         this->textBox1->Size = System::Drawing::Size(100, 20);
  104.                         this->textBox1->TabIndex = 2;
  105.                         //
  106.                         // button1
  107.                         //
  108.                         this->button1->Location = System::Drawing::Point(111, 323);
  109.                         this->button1->Name = L"button1";
  110.                         this->button1->Size = System::Drawing::Size(75, 23);
  111.                         this->button1->TabIndex = 3;
  112.                         this->button1->Text = L"Close";
  113.                         this->button1->UseVisualStyleBackColor = true;
  114.                         this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click_1);
  115.                         //
  116.                         // label2
  117.                         //
  118.                         this->label2->AutoSize = true;
  119.                         this->label2->Location = System::Drawing::Point(26, 9);
  120.                         this->label2->Name = L"label2";
  121.                         this->label2->Size = System::Drawing::Size(85, 13);
  122.                         this->label2->TabIndex = 5;
  123.                         this->label2->Text = L"Przelicznik walut";
  124.                         //
  125.                         // label3
  126.                         //
  127.                         this->label3->AutoSize = true;
  128.                         this->label3->Location = System::Drawing::Point(12, 130);
  129.                         this->label3->Name = L"label3";
  130.                         this->label3->Size = System::Drawing::Size(171, 13);
  131.                         this->label3->TabIndex = 6;
  132.                         this->label3->Text = L"Jaki jest symbol chemiczny cynku\?";
  133.                         //
  134.                         // groupBox1
  135.                         //
  136.                         this->groupBox1->Controls->Add(this->radioButton4);
  137.                         this->groupBox1->Controls->Add(this->radioButton3);
  138.                         this->groupBox1->Controls->Add(this->radioButton2);
  139.                         this->groupBox1->Controls->Add(this->radioButton1);
  140.                         this->groupBox1->Location = System::Drawing::Point(12, 162);
  141.                         this->groupBox1->Name = L"groupBox1";
  142.                         this->groupBox1->Size = System::Drawing::Size(105, 127);
  143.                         this->groupBox1->TabIndex = 7;
  144.                         this->groupBox1->TabStop = false;
  145.                         //
  146.                         // radioButton4
  147.                         //
  148.                         this->radioButton4->AutoSize = true;
  149.                         this->radioButton4->Location = System::Drawing::Point(6, 88);
  150.                         this->radioButton4->Name = L"radioButton4";
  151.                         this->radioButton4->Size = System::Drawing::Size(39, 17);
  152.                         this->radioButton4->TabIndex = 3;
  153.                         this->radioButton4->TabStop = true;
  154.                         this->radioButton4->Text = L"Na";
  155.                         this->radioButton4->UseVisualStyleBackColor = true;
  156.                         this->radioButton4->CheckedChanged += gcnew System::EventHandler(this, &MyForm::radioButton4_CheckedChanged);
  157.                         //
  158.                         // radioButton3
  159.                         //
  160.                         this->radioButton3->AutoSize = true;
  161.                         this->radioButton3->Location = System::Drawing::Point(6, 65);
  162.                         this->radioButton3->Name = L"radioButton3";
  163.                         this->radioButton3->Size = System::Drawing::Size(35, 17);
  164.                         this->radioButton3->TabIndex = 2;
  165.                         this->radioButton3->TabStop = true;
  166.                         this->radioButton3->Text = L"Cr";
  167.                         this->radioButton3->UseVisualStyleBackColor = true;
  168.                         this->radioButton3->CheckedChanged += gcnew System::EventHandler(this, &MyForm::radioButton3_CheckedChanged);
  169.                         //
  170.                         // radioButton2
  171.                         //
  172.                         this->radioButton2->AutoSize = true;
  173.                         this->radioButton2->Location = System::Drawing::Point(6, 42);
  174.                         this->radioButton2->Name = L"radioButton2";
  175.                         this->radioButton2->Size = System::Drawing::Size(38, 17);
  176.                         this->radioButton2->TabIndex = 1;
  177.                         this->radioButton2->TabStop = true;
  178.                         this->radioButton2->Text = L"Cu";
  179.                         this->radioButton2->UseVisualStyleBackColor = true;
  180.                         this->radioButton2->CheckedChanged += gcnew System::EventHandler(this, &MyForm::radioButton2_CheckedChanged);
  181.                         //
  182.                         // radioButton1
  183.                         //
  184.                         this->radioButton1->AutoSize = true;
  185.                         this->radioButton1->Location = System::Drawing::Point(6, 19);
  186.                         this->radioButton1->Name = L"radioButton1";
  187.                         this->radioButton1->Size = System::Drawing::Size(38, 17);
  188.                         this->radioButton1->TabIndex = 0;
  189.                         this->radioButton1->TabStop = true;
  190.                         this->radioButton1->Text = L"Zn";
  191.                         this->radioButton1->UseVisualStyleBackColor = true;
  192.                         this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &MyForm::radioButton1_CheckedChanged);
  193.                         //
  194.                         // MyForm
  195.                         //
  196.                         this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  197.                         this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  198.                         this->ClientSize = System::Drawing::Size(312, 358);
  199.                         this->Controls->Add(this->groupBox1);
  200.                         this->Controls->Add(this->label3);
  201.                         this->Controls->Add(this->label2);
  202.                         this->Controls->Add(this->button1);
  203.                         this->Controls->Add(this->textBox1);
  204.                         this->Controls->Add(this->comboBox1);
  205.                         this->Controls->Add(this->label1);
  206.                         this->Name = L"MyForm";
  207.                         this->Text = L"5,7";
  208.                         this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
  209.                         this->groupBox1->ResumeLayout(false);
  210.                         this->groupBox1->PerformLayout();
  211.                         this->ResumeLayout(false);
  212.                         this->PerformLayout();
  213.  
  214.                 }
  215. #pragma endregion
  216.                
  217.         private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
  218.        
  219.                
  220.  
  221.                
  222.                 //if (textBox1->TextLength==0|| textBox1->Text=="0")
  223.                        
  224.                 //{
  225.                        
  226.                        
  227.                                
  228.                                         //MessageBox::Show("Wprowadź wartość", "Uwaga", MessageBoxButtons::OK, MessageBoxIcon::Warning);
  229.                                         //label1->Text = "";
  230.                                
  231.                         //}
  232.                 //else
  233.                 //{
  234.  
  235.                         float a;
  236.                         try
  237.                         {
  238.                                 a = Single::Parse(textBox1->Text);
  239.  
  240.  
  241.                                 switch (comboBox1->SelectedIndex)
  242.                                 {
  243.                                 case 0:
  244.  
  245.                                         label1->Text = (a*4.5).ToString();
  246.                                         break;
  247.  
  248.                                 case 1:
  249.                                         label1->Text = (a*4.2).ToString();
  250.                                         break;
  251.                                 case 2:
  252.                                         label1->Text = (a*5.2).ToString();
  253.                                         break;
  254.                                 }
  255.                         }
  256.  
  257.  
  258.                         catch (FormatException^ e)
  259.                         {
  260.  
  261.                         }
  262.  
  263.                 //}
  264.         }
  265.         private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
  266.                
  267.                 if (textBox1->TextLength == 0)
  268.                 {
  269.                         comboBox1->Enabled = false;
  270.                 }
  271.                 else
  272.                 {
  273.                         comboBox1->Enabled = true;
  274.                
  275.  
  276.  
  277.                         float a;
  278.                         try
  279.                         {
  280.                        
  281.                                
  282.                                
  283.                                 a = Single::Parse(textBox1->Text);
  284.                         switch (comboBox1->SelectedIndex)
  285.                                        
  286.  
  287.  
  288.                                                 {
  289.  
  290.  
  291.                                 case 0:
  292.  
  293.                                         label1->Text = (a*4.5).ToString();
  294.                                         break;
  295.                                 case 1:
  296.                                         label1->Text = (a*4.2).ToString();
  297.                                         break;
  298.                                 case 2:
  299.                                         label1->Text = (a*5.2).ToString();
  300.                                         break;
  301.                                                 }
  302.  
  303.                                        
  304.                         }
  305.  
  306.                         catch (FormatException^ e)
  307.                         {
  308.  
  309.  
  310.  
  311.                         }
  312.                 }
  313.                
  314.         }
  315.        
  316.  
  317.         private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
  318.         }
  319.         private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
  320.                 label3->Text = "1";
  321.         }
  322. private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
  323.         label3->Text = "0";
  324. }
  325. private: System::Void radioButton3_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
  326.         label3->Text = "0";
  327. }
  328. private: System::Void radioButton4_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
  329.         label3->Text = "0";
  330. }
  331.                
  332. private: System::Void button1_Click_1(System::Object^  sender, System::EventArgs^  e) {
  333.         if
  334.                 (MessageBox::Show("Are you sure you want to close this application?", "Close", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes)
  335.         {
  336.                 Application::Exit();
  337.         }
  338. }
  339.  
  340.  
  341. };
  342. }