Advertisement
eimkasp

C++ Interface functions example

Dec 5th, 2011
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.59 KB | None | 0 0
  1. #pragma once
  2. #include <math.h>
  3. #include <string>
  4.  
  5.  
  6. namespace Interface1 {
  7. double a, r , aps;
  8. const double PI = 3.141592;
  9.  
  10.     using namespace System;
  11.     using namespace System::ComponentModel;
  12.     using namespace System::Collections;
  13.     using namespace System::Windows::Forms;
  14.     using namespace System::Data;
  15.     using namespace System::Drawing;
  16.  
  17.     /// <summary>
  18.     /// Summary for Form1
  19.     ///
  20.     /// WARNING: If you change the name of this class, you will need to change the
  21.     ///          'Resource File Name' property for the managed resource compiler tool
  22.     ///          associated with all .resx files this class depends on.  Otherwise,
  23.     ///          the designers will not be able to interact properly with localized
  24.     ///          resources associated with this form.
  25.     /// </summary>
  26.     public ref class Form1 : public System::Windows::Forms::Form
  27.     {
  28.     public:
  29.         Form1(void)
  30.         {
  31.             InitializeComponent();
  32.             //
  33.             //TODO: Add the constructor code here
  34.             //
  35.         }
  36.  
  37.     protected:
  38.         /// <summary>
  39.         /// Clean up any resources being used.
  40.         /// </summary>
  41.         ~Form1()
  42.         {
  43.             if (components)
  44.             {
  45.                 delete components;
  46.             }
  47.         }
  48.     private: System::Windows::Forms::Label^  label1;
  49.     protected:
  50.  
  51.     private: System::Windows::Forms::TextBox^  textBox1;
  52.     //private: void suma() ;
  53.     private: System::Windows::Forms::Label^  label3;
  54.     private: System::Windows::Forms::Button^  button1;
  55.     private: System::Windows::Forms::PictureBox^  pictureBox1;
  56.     private: System::Windows::Forms::RadioButton^  radioButton1;
  57.     private: System::Windows::Forms::RadioButton^  radioButton2;
  58.     private: System::Windows::Forms::RadioButton^  radioButton3;
  59.     private: System::Windows::Forms::Label^  label2;
  60.     private: System::Windows::Forms::CheckBox^  checkBox1;
  61.  
  62.  
  63.     protected:
  64.  
  65.     protected:
  66.  
  67.     private:
  68.         /// <summary>
  69.         /// Required designer variable.
  70.         /// </summary>
  71.         System::ComponentModel::Container ^components;
  72.  
  73. #pragma region Windows Form Designer generated code
  74.         /// <summary>
  75.         /// Required method for Designer support - do not modify
  76.         /// the contents of this method with the code editor.
  77.         /// </summary>
  78.         void InitializeComponent(void)
  79.         {
  80.             System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
  81.             this->label1 = (gcnew System::Windows::Forms::Label());
  82.             this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  83.             this->label3 = (gcnew System::Windows::Forms::Label());
  84.             this->button1 = (gcnew System::Windows::Forms::Button());
  85.             this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
  86.             this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
  87.             this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
  88.             this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());
  89.             this->label2 = (gcnew System::Windows::Forms::Label());
  90.             this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
  91.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
  92.             this->SuspendLayout();
  93.             //
  94.             // label1
  95.             //
  96.             this->label1->AutoSize = true;
  97.             this->label1->Location = System::Drawing::Point(249, 21);
  98.             this->label1->Name = L"label1";
  99.             this->label1->Size = System::Drawing::Size(97, 17);
  100.             this->label1->TabIndex = 0;
  101.             this->label1->Text = L"Įveskite a dydį";
  102.             this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click_1);
  103.             //
  104.             // textBox1
  105.             //
  106.             this->textBox1->Location = System::Drawing::Point(252, 41);
  107.             this->textBox1->Name = L"textBox1";
  108.             this->textBox1->Size = System::Drawing::Size(100, 22);
  109.             this->textBox1->TabIndex = 2;
  110.             //
  111.             // label3
  112.             //
  113.             this->label3->AutoSize = true;
  114.             this->label3->Location = System::Drawing::Point(12, 149);
  115.             this->label3->Name = L"label3";
  116.             this->label3->Size = System::Drawing::Size(75, 17);
  117.             this->label3->TabIndex = 4;
  118.             this->label3->Text = L"Rezultatas";
  119.             this->label3->Click += gcnew System::EventHandler(this, &Form1::label3_Click);
  120.             //
  121.             // button1
  122.             //
  123.             this->button1->Location = System::Drawing::Point(252, 78);
  124.             this->button1->Name = L"button1";
  125.             this->button1->Size = System::Drawing::Size(100, 41);
  126.             this->button1->TabIndex = 5;
  127.             this->button1->Text = L"Skaičiuoti";
  128.             this->button1->UseVisualStyleBackColor = true;
  129.             this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
  130.             //
  131.             // pictureBox1
  132.             //
  133.             this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
  134.             this->pictureBox1->InitialImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.InitialImage")));
  135.             this->pictureBox1->Location = System::Drawing::Point(15, 21);
  136.             this->pictureBox1->Name = L"pictureBox1";
  137.             this->pictureBox1->Size = System::Drawing::Size(200, 125);
  138.             this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;
  139.             this->pictureBox1->TabIndex = 6;
  140.             this->pictureBox1->TabStop = false;
  141.             //
  142.             // radioButton1
  143.             //
  144.             this->radioButton1->AutoSize = true;
  145.             this->radioButton1->Location = System::Drawing::Point(378, 41);
  146.             this->radioButton1->Name = L"radioButton1";
  147.             this->radioButton1->Size = System::Drawing::Size(93, 21);
  148.             this->radioButton1->TabIndex = 7;
  149.             this->radioButton1->TabStop = true;
  150.             this->radioButton1->Text = L"Metrai (m)";
  151.             this->radioButton1->UseVisualStyleBackColor = true;
  152.             this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
  153.             //
  154.             // radioButton2
  155.             //
  156.             this->radioButton2->AutoSize = true;
  157.             this->radioButton2->Location = System::Drawing::Point(378, 68);
  158.             this->radioButton2->Name = L"radioButton2";
  159.             this->radioButton2->Size = System::Drawing::Size(132, 21);
  160.             this->radioButton2->TabIndex = 8;
  161.             this->radioButton2->TabStop = true;
  162.             this->radioButton2->Text = L"Centimetrai (cm)";
  163.             this->radioButton2->UseVisualStyleBackColor = true;
  164.             //
  165.             // radioButton3
  166.             //
  167.             this->radioButton3->AutoSize = true;
  168.             this->radioButton3->Location = System::Drawing::Point(378, 98);
  169.             this->radioButton3->Name = L"radioButton3";
  170.             this->radioButton3->Size = System::Drawing::Size(53, 21);
  171.             this->radioButton3->TabIndex = 9;
  172.             this->radioButton3->TabStop = true;
  173.             this->radioButton3->Text = L"Kita";
  174.             this->radioButton3->UseVisualStyleBackColor = true;
  175.             //
  176.             // label2
  177.             //
  178.             this->label2->AutoSize = true;
  179.             this->label2->Location = System::Drawing::Point(375, 21);
  180.             this->label2->Name = L"label2";
  181.             this->label2->Size = System::Drawing::Size(121, 17);
  182.             this->label2->TabIndex = 10;
  183.             this->label2->Text = L"Matavimo vienetai";
  184.             //
  185.             // checkBox1
  186.             //
  187.             this->checkBox1->AutoSize = true;
  188.             this->checkBox1->Location = System::Drawing::Point(387, 235);
  189.             this->checkBox1->Name = L"checkBox1";
  190.             this->checkBox1->Size = System::Drawing::Size(123, 21);
  191.             this->checkBox1->TabIndex = 11;
  192.             this->checkBox1->Text = L"Išsaugoti į failą";
  193.             this->checkBox1->UseVisualStyleBackColor = true;
  194.             //
  195.             // Form1
  196.             //
  197.             this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
  198.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  199.             this->ClientSize = System::Drawing::Size(508, 266);
  200.             this->Controls->Add(this->checkBox1);
  201.             this->Controls->Add(this->label2);
  202.             this->Controls->Add(this->radioButton3);
  203.             this->Controls->Add(this->radioButton2);
  204.             this->Controls->Add(this->radioButton1);
  205.             this->Controls->Add(this->pictureBox1);
  206.             this->Controls->Add(this->button1);
  207.             this->Controls->Add(this->label3);
  208.             this->Controls->Add(this->textBox1);
  209.             this->Controls->Add(this->label1);
  210.             this->Name = L"Form1";
  211.             this->Text = L"Eimantas Kasperiūnas ND1";
  212.             this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
  213.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
  214.             this->ResumeLayout(false);
  215.             this->PerformLayout();
  216.  
  217.         }
  218. #pragma endregion
  219.     private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
  220.              }
  221.     private: System::Void label3_Click(System::Object^  sender, System::EventArgs^  e) {
  222.              }
  223. private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  224.              // aprasymo vieta
  225.              string mvnt;
  226.              if(String::IsNullOrEmpty(textBox1->Text)){
  227.                  MessageBox::Show(L"Įvesta neteisinga reikšmė." ,
  228.                      L"Klaida!",
  229.                      MessageBoxButtons::OK,
  230.                      MessageBoxIcon::Exclamation);
  231.              }
  232.              else{;
  233.              nuskaitymas(a);
  234.              if (radioButton1->Checked){
  235.                  rezultatai(mvnt);}
  236.              }
  237.              }
  238. private: System::Void label1_Click_1(System::Object^  sender, System::EventArgs^  e) {
  239.          }
  240. private:void rezultatai(char mvnt) {
  241.              double s = 0;
  242.              label3-> Text=String::Format("Neuzbruksniuotos figuros plotas yra " + plotas(a,r,aps) ) ;
  243.              label3-> Text += "\n";
  244.              // label3-> Text += "666";
  245.             label3->Text += 'mvnt';
  246.             // + "\n" + "Uzbruksniuotos figuros plotas yra " + (pow(a,2) - plotas(a,r,aps) + mat[1,2,3])
  247.          }
  248. private:void nuskaitymas(double & a) {
  249.             a = Convert::ToDouble(textBox1->Text);
  250. }
  251. private:double plotas (double a, double &rombas, double &apskritimas){
  252.     rombas = pow(a,2) - ((a/2)*(a/2))/2*4;
  253.     apskritimas = PI*pow(a/4,2);
  254.     return pow(a,2) - rombas - apskritimas/2;
  255. }
  256. private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
  257.          }
  258. private: System::Void progressBar1_Click(System::Object^  sender, System::EventArgs^  e) {
  259.          }
  260. private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
  261.          }
  262. };
  263. }
  264.  
  265.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement