#pragma once


namespace r02_13 {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Label^  label1;
	protected: 
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::Label^  label7;
	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::Windows::Forms::TextBox^  textBox5;
	private: System::Windows::Forms::TextBox^  textBox6;
	private: System::Windows::Forms::TextBox^  textBox7;
	private: System::Windows::Forms::TextBox^  textBox8;
	private: System::Windows::Forms::TextBox^  textBox9;
	private: System::Windows::Forms::TextBox^  textBox10;
	private: System::Windows::Forms::TextBox^  textBox11;
	private: System::Windows::Forms::TextBox^  textBox12;
	private: System::Windows::Forms::TextBox^  textBox13;
	private: System::Windows::Forms::TextBox^  textBox14;
	private: System::Windows::Forms::TextBox^  textBox15;
	private: System::Windows::Forms::TextBox^  textBox16;
	private: System::Windows::Forms::TextBox^  textBox17;
	private: System::Windows::Forms::TextBox^  textBox18;
	private: System::Windows::Forms::TextBox^  textBox19;
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::RadioButton^  radioButton1;
	private: System::Windows::Forms::RadioButton^  radioButton2;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->label7 = (gcnew System::Windows::Forms::Label());
			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());
			this->textBox5 = (gcnew System::Windows::Forms::TextBox());
			this->textBox6 = (gcnew System::Windows::Forms::TextBox());
			this->textBox7 = (gcnew System::Windows::Forms::TextBox());
			this->textBox8 = (gcnew System::Windows::Forms::TextBox());
			this->textBox9 = (gcnew System::Windows::Forms::TextBox());
			this->textBox10 = (gcnew System::Windows::Forms::TextBox());
			this->textBox11 = (gcnew System::Windows::Forms::TextBox());
			this->textBox12 = (gcnew System::Windows::Forms::TextBox());
			this->textBox13 = (gcnew System::Windows::Forms::TextBox());
			this->textBox14 = (gcnew System::Windows::Forms::TextBox());
			this->textBox15 = (gcnew System::Windows::Forms::TextBox());
			this->textBox16 = (gcnew System::Windows::Forms::TextBox());
			this->textBox17 = (gcnew System::Windows::Forms::TextBox());
			this->textBox18 = (gcnew System::Windows::Forms::TextBox());
			this->textBox19 = (gcnew System::Windows::Forms::TextBox());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
			this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
			this->SuspendLayout();
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(12, 96);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(96, 13);
			this->label1->TabIndex = 0;
			this->label1->Text = L"Początek wektora:";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(12, 122);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(84, 13);
			this->label2->TabIndex = 1;
			this->label2->Text = L"Koniec wektora:";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(141, 26);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(51, 13);
			this->label3->TabIndex = 2;
			this->label3->Text = L"Wektor 1";
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(150, 58);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(124, 13);
			this->label4->TabIndex = 3;
			this->label4->Text = L"x                  y                z";
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Location = System::Drawing::Point(312, 58);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(124, 13);
			this->label5->TabIndex = 4;
			this->label5->Text = L"x                  y                z";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Location = System::Drawing::Point(350, 26);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(51, 13);
			this->label6->TabIndex = 5;
			this->label6->Text = L"Wektor 2";
			// 
			// label7
			// 
			this->label7->AutoSize = true;
			this->label7->Location = System::Drawing::Point(12, 181);
			this->label7->Name = L"label7";
			this->label7->Size = System::Drawing::Size(115, 13);
			this->label7->TabIndex = 6;
			this->label7->Text = L"Współrzędne wektora:";
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(140, 80);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(44, 20);
			this->textBox1->TabIndex = 7;
			// 
			// textBox2
			// 
			this->textBox2->Location = System::Drawing::Point(190, 80);
			this->textBox2->Name = L"textBox2";
			this->textBox2->Size = System::Drawing::Size(44, 20);
			this->textBox2->TabIndex = 8;
			// 
			// textBox3
			// 
			this->textBox3->Location = System::Drawing::Point(240, 80);
			this->textBox3->Name = L"textBox3";
			this->textBox3->Size = System::Drawing::Size(44, 20);
			this->textBox3->TabIndex = 9;
			// 
			// textBox4
			// 
			this->textBox4->Location = System::Drawing::Point(140, 106);
			this->textBox4->Name = L"textBox4";
			this->textBox4->Size = System::Drawing::Size(44, 20);
			this->textBox4->TabIndex = 10;
			// 
			// textBox5
			// 
			this->textBox5->Location = System::Drawing::Point(190, 106);
			this->textBox5->Name = L"textBox5";
			this->textBox5->Size = System::Drawing::Size(44, 20);
			this->textBox5->TabIndex = 11;
			// 
			// textBox6
			// 
			this->textBox6->Location = System::Drawing::Point(240, 106);
			this->textBox6->Name = L"textBox6";
			this->textBox6->Size = System::Drawing::Size(44, 20);
			this->textBox6->TabIndex = 12;
			// 
			// textBox7
			// 
			this->textBox7->Location = System::Drawing::Point(303, 80);
			this->textBox7->Name = L"textBox7";
			this->textBox7->Size = System::Drawing::Size(44, 20);
			this->textBox7->TabIndex = 13;
			// 
			// textBox8
			// 
			this->textBox8->Location = System::Drawing::Point(353, 80);
			this->textBox8->Name = L"textBox8";
			this->textBox8->Size = System::Drawing::Size(44, 20);
			this->textBox8->TabIndex = 14;
			// 
			// textBox9
			// 
			this->textBox9->Location = System::Drawing::Point(404, 80);
			this->textBox9->Name = L"textBox9";
			this->textBox9->Size = System::Drawing::Size(44, 20);
			this->textBox9->TabIndex = 15;
			// 
			// textBox10
			// 
			this->textBox10->Location = System::Drawing::Point(303, 106);
			this->textBox10->Name = L"textBox10";
			this->textBox10->Size = System::Drawing::Size(44, 20);
			this->textBox10->TabIndex = 16;
			// 
			// textBox11
			// 
			this->textBox11->Location = System::Drawing::Point(353, 106);
			this->textBox11->Name = L"textBox11";
			this->textBox11->Size = System::Drawing::Size(44, 20);
			this->textBox11->TabIndex = 17;
			// 
			// textBox12
			// 
			this->textBox12->Location = System::Drawing::Point(404, 106);
			this->textBox12->Name = L"textBox12";
			this->textBox12->Size = System::Drawing::Size(44, 20);
			this->textBox12->TabIndex = 18;
			// 
			// textBox13
			// 
			this->textBox13->Location = System::Drawing::Point(140, 173);
			this->textBox13->Name = L"textBox13";
			this->textBox13->Size = System::Drawing::Size(44, 20);
			this->textBox13->TabIndex = 19;
			// 
			// textBox14
			// 
			this->textBox14->Location = System::Drawing::Point(190, 173);
			this->textBox14->Name = L"textBox14";
			this->textBox14->Size = System::Drawing::Size(44, 20);
			this->textBox14->TabIndex = 20;
			// 
			// textBox15
			// 
			this->textBox15->Location = System::Drawing::Point(240, 173);
			this->textBox15->Name = L"textBox15";
			this->textBox15->Size = System::Drawing::Size(44, 20);
			this->textBox15->TabIndex = 21;
			// 
			// textBox16
			// 
			this->textBox16->Location = System::Drawing::Point(303, 174);
			this->textBox16->Name = L"textBox16";
			this->textBox16->Size = System::Drawing::Size(44, 20);
			this->textBox16->TabIndex = 22;
			// 
			// textBox17
			// 
			this->textBox17->Location = System::Drawing::Point(353, 174);
			this->textBox17->Name = L"textBox17";
			this->textBox17->Size = System::Drawing::Size(44, 20);
			this->textBox17->TabIndex = 23;
			// 
			// textBox18
			// 
			this->textBox18->Location = System::Drawing::Point(404, 174);
			this->textBox18->Name = L"textBox18";
			this->textBox18->Size = System::Drawing::Size(44, 20);
			this->textBox18->TabIndex = 24;
			// 
			// textBox19
			// 
			this->textBox19->Location = System::Drawing::Point(121, 224);
			this->textBox19->Multiline = true;
			this->textBox19->Name = L"textBox19";
			this->textBox19->Size = System::Drawing::Size(427, 102);
			this->textBox19->TabIndex = 25;
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(20, 291);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(75, 23);
			this->button1->TabIndex = 26;
			this->button1->Text = L"Licz";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// radioButton1
			// 
			this->radioButton1->AutoSize = true;
			this->radioButton1->Location = System::Drawing::Point(474, 96);
			this->radioButton1->Name = L"radioButton1";
			this->radioButton1->Size = System::Drawing::Size(108, 17);
			this->radioButton1->TabIndex = 27;
			this->radioButton1->TabStop = true;
			this->radioButton1->Text = L"Początek, koniec";
			this->radioButton1->UseVisualStyleBackColor = true;
			this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
			// 
			// radioButton2
			// 
			this->radioButton2->AutoSize = true;
			this->radioButton2->Location = System::Drawing::Point(474, 177);
			this->radioButton2->Name = L"radioButton2";
			this->radioButton2->Size = System::Drawing::Size(130, 17);
			this->radioButton2->TabIndex = 28;
			this->radioButton2->TabStop = true;
			this->radioButton2->Text = L"Współrzędne wektora";
			this->radioButton2->UseVisualStyleBackColor = true;
			this->radioButton2->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton2_CheckedChanged);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(659, 372);
			this->Controls->Add(this->radioButton2);
			this->Controls->Add(this->radioButton1);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->textBox19);
			this->Controls->Add(this->textBox18);
			this->Controls->Add(this->textBox17);
			this->Controls->Add(this->textBox16);
			this->Controls->Add(this->textBox15);
			this->Controls->Add(this->textBox14);
			this->Controls->Add(this->textBox13);
			this->Controls->Add(this->textBox12);
			this->Controls->Add(this->textBox11);
			this->Controls->Add(this->textBox10);
			this->Controls->Add(this->textBox9);
			this->Controls->Add(this->textBox8);
			this->Controls->Add(this->textBox7);
			this->Controls->Add(this->textBox6);
			this->Controls->Add(this->textBox5);
			this->Controls->Add(this->textBox4);
			this->Controls->Add(this->textBox3);
			this->Controls->Add(this->textBox2);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->label7);
			this->Controls->Add(this->label6);
			this->Controls->Add(this->label5);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->label1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
				   if (radioButton1->Checked) {   
 radioButton2->Checked=false;
 textBox4->Enabled=true;textBox1->Enabled=true;
 textBox5->Enabled=true;textBox2->Enabled=true;
 textBox6->Enabled=true;textBox3->Enabled=true;
 textBox8->Enabled=true;textBox7->Enabled=true;
 textBox9->Enabled=true;textBox10->Enabled=true;
 textBox12->Enabled=true;textBox11->Enabled=true; 
 
             textBox13->Enabled=false;   
             textBox14->Enabled=false;   
             textBox15->Enabled=false;   
             textBox16->Enabled=false;   
             textBox17->Enabled=false;   
             textBox18->Enabled=false;
             }

			 }
private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			 if (radioButton2->Checked) { 
        radioButton1->Checked=false;
            textBox4->Enabled=false;textBox1->Enabled=false;
           textBox5->Enabled=false;textBox2->Enabled=false;
        textBox6->Enabled=false;textBox3->Enabled=false;
        textBox8->Enabled=false;textBox7->Enabled=false;
           textBox9->Enabled=false;textBox10->Enabled=false;
             textBox12->Enabled=false;textBox11->Enabled=false;
              textBox13->Enabled=true;;   
             textBox14->Enabled=true;   
             textBox15->Enabled=true;   
             textBox16->Enabled=true;   
             textBox17->Enabled=true;   
             textBox18->Enabled=true;      
                  
             }

		 }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			     System::Single wspi1,wspj1,wspk1; // współrzędne wektora 1
    System::Single wspi2,wspj2,wspk2;// współrzędne wektora 2
    System::Single dlugosc1,dlugosc2;
    System::Single kat;
    System::Single il_skal;
    System::Single il_weki,il_wekj,il_wekk;
    System::Single il_wekdlug;
    // oblicz współrzędne jeżeli podano początek i koniec
 if (radioButton1->Checked) {
       if ((textBox4->Text=="")||(textBox1->Text=="")||(textBox5->Text=="")&&
      (textBox2->Text=="")||(textBox6->Text=="")||(textBox3->Text=="")&&
    (textBox8->Text=="")||(textBox7->Text=="")||(textBox9->Text=="")&&
    (textBox10->Text=="")||(textBox12->Text=="")||(textBox11->Text=="")){
          MessageBox::Show( "Wpisz wszystkie współrzędne punktów", "Błąd",
          MessageBoxButtons::OK, MessageBoxIcon::Exclamation );return;}
                 // oblicz współrzędne
    wspi1=Single::Parse(textBox4->Text)-Single::Parse(textBox1->Text);
    wspj1=Single::Parse(textBox5->Text)-Single::Parse(textBox2->Text);
    wspk1=Single::Parse(textBox6->Text)-Single::Parse(textBox3->Text);
    wspi2=Single::Parse(textBox10->Text)-Single::Parse(textBox7->Text);
    wspj2=Single::Parse(textBox11->Text)-Single::Parse(textBox8->Text);
    wspk2=Single::Parse(textBox12->Text)-Single::Parse(textBox9->Text);
                 // wypisz współrzędne w oknach
    textBox13->Text=wspi1.ToString();
    textBox14->Text=wspj1.ToString();
    textBox15->Text=wspk1.ToString();
    textBox16->Text=wspi2.ToString();
    textBox17->Text=wspj2.ToString();
    textBox18->Text=wspk2.ToString();
             }
          // jeżeli współrzędne podano to je odczytaj
if (radioButton2->Checked) {
    if ((textBox13->Text=="")||(textBox14->Text=="")||(textBox15->Text=="")&&
    (textBox16->Text=="")||(textBox17->Text=="")||(textBox18->Text=="")){
       MessageBox::Show( "Wpisz wszystkie współrzędne wektorów", "Błąd",
       MessageBoxButtons::OK, MessageBoxIcon::Exclamation );return;}
    wspi1=Single::Parse(textBox13->Text);
    wspj1=Single::Parse(textBox14->Text);
    wspk1=Single::Parse(textBox15->Text);
    wspi2=Single::Parse(textBox16->Text);
    wspj2=Single::Parse(textBox17->Text);
    wspk2=Single::Parse(textBox18->Text);       }

             // oblicz długość wektorów
    dlugosc1=Math::Sqrt(wspi1*wspi1+wspj1*wspj1+wspk1*wspk1);
    dlugosc2=Math::Sqrt(wspi2*wspi2+wspj2*wspj2+wspk2*wspk2);
                 // oblicz kąt między wektorami 
            kat=(wspi1*wspi2+wspj1*wspj2+wspk1*wspk2)/(dlugosc1*dlugosc2);
    kat=kat*180/3.14;
             // oblicz iloczyn wektorowy
    il_skal=wspi1*wspi2+wspj1*wspj2+wspk1*wspk2;
    il_weki=wspj1*wspk2-wspk1*wspj2;
    il_wekj=wspk1*wspi2-wspi1-wspk2;
    il_wekk=wspi1*wspj2-wspj1*wspi2;
              il_wekdlug=Math::Sqrt(il_weki*il_weki+il_wekj*il_wekj+il_wekk*il_wekk);
// wypisz wyniki w polu tekstowym
textBox19->AppendText("wektor A długość "+dlugosc1.ToString()+"      wektor B    dlugość "+dlugosc2.ToString()+System::Environment::NewLine);
textBox19->AppendText("Kąt między wektorami "+kat.ToString()+" stopni"+System::Environment::NewLine);
textBox19->AppendText("Iloczyn skalarny"+il_skal.ToString()+System::Environment::NewLine);
textBox19->AppendText("Iloczyn wektorowy współrzędne  "+il_weki.ToString()+"  "+il_wekj.ToString()+"  "+il_wekk.ToString()+System::Environment::NewLine);
textBox19->AppendText("Iloczyn wektorowy dlugość "+il_wekdlug.ToString()+System::Environment::NewLine);

		 }
};
}

