#pragma once

#include <cstdint>
#include "funkce.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"


namespace applikace {

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


	/// <summary>
	/// Summary for okno
	/// </summary>
	public ref class okno : public System::Windows::Forms::Form
	{
	public:
		okno(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~okno()
		{
			if (components)
			{
				delete components;
			}
		}

	protected:


	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	private: System::Windows::Forms::ToolStripMenuItem^  souborToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  novýToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  otevřítToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  uložitToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  uložitJakoToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  nápovědaToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  nápovědaToolStripMenuItem1;
	private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
	private: System::Windows::Forms::SaveFileDialog^  saveFileDialog1;
	private: System::Windows::Forms::DataGridView^  dataGridView1;
	private: System::Windows::Forms::Button^  button1;
	public: System::Windows::Forms::ComboBox^  comboBox1;
	private:










	private: System::Windows::Forms::TextBox^  textBox4;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown2;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown3;
	private: System::Windows::Forms::ComboBox^  comboBox2;
	private: System::Windows::Forms::ComboBox^  comboBox3;

















	private: System::ComponentModel::IContainer^  components;

	protected:

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#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->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->souborToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->novýToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->otevřítToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->uložitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->uložitJakoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->nápovědaToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->nápovědaToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
			this->saveFileDialog1 = (gcnew System::Windows::Forms::SaveFileDialog());
			this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
			this->textBox4 = (gcnew System::Windows::Forms::TextBox());
			this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
			this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
			this->numericUpDown3 = (gcnew System::Windows::Forms::NumericUpDown());
			this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
			this->comboBox3 = (gcnew System::Windows::Forms::ComboBox());
			this->menuStrip1->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown3))->BeginInit();
			this->SuspendLayout();
			// 
			// menuStrip1
			// 
			this->menuStrip1->BackColor = System::Drawing::Color::Red;
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {
				this->souborToolStripMenuItem,
					this->nápovědaToolStripMenuItem, this->nápovědaToolStripMenuItem1
			});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(514, 24);
			this->menuStrip1->TabIndex = 1;
			this->menuStrip1->Text = L"menuStrip1";
			// 
			// souborToolStripMenuItem
			// 
			this->souborToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {
				this->novýToolStripMenuItem,
					this->otevřítToolStripMenuItem, this->uložitToolStripMenuItem, this->uložitJakoToolStripMenuItem
			});
			this->souborToolStripMenuItem->Name = L"souborToolStripMenuItem";
			this->souborToolStripMenuItem->Size = System::Drawing::Size(56, 20);
			this->souborToolStripMenuItem->Text = L"soubor";
			// 
			// novýToolStripMenuItem
			// 
			this->novýToolStripMenuItem->Name = L"novýToolStripMenuItem";
			this->novýToolStripMenuItem->Size = System::Drawing::Size(137, 22);
			this->novýToolStripMenuItem->Text = L"nový";
			this->novýToolStripMenuItem->Click += gcnew System::EventHandler(this, &okno::novýToolStripMenuItem_Click);
			// 
			// otevřítToolStripMenuItem
			// 
			this->otevřítToolStripMenuItem->Name = L"otevřítToolStripMenuItem";
			this->otevřítToolStripMenuItem->Size = System::Drawing::Size(137, 22);
			this->otevřítToolStripMenuItem->Text = L"otevřít";
			this->otevřítToolStripMenuItem->Click += gcnew System::EventHandler(this, &okno::otevřítToolStripMenuItem_Click);
			// 
			// uložitToolStripMenuItem
			// 
			this->uložitToolStripMenuItem->Name = L"uložitToolStripMenuItem";
			this->uložitToolStripMenuItem->Size = System::Drawing::Size(137, 22);
			this->uložitToolStripMenuItem->Text = L"uložit";
			this->uložitToolStripMenuItem->Click += gcnew System::EventHandler(this, &okno::uložitToolStripMenuItem_Click);
			// 
			// uložitJakoToolStripMenuItem
			// 
			this->uložitJakoToolStripMenuItem->Name = L"uložitJakoToolStripMenuItem";
			this->uložitJakoToolStripMenuItem->Size = System::Drawing::Size(137, 22);
			this->uložitJakoToolStripMenuItem->Text = L"uložit jako...";
			this->uložitJakoToolStripMenuItem->Click += gcnew System::EventHandler(this, &okno::uložitJakoToolStripMenuItem_Click);
			// 
			// nápovědaToolStripMenuItem
			// 
			this->nápovědaToolStripMenuItem->Name = L"nápovědaToolStripMenuItem";
			this->nápovědaToolStripMenuItem->Size = System::Drawing::Size(52, 20);
			this->nápovědaToolStripMenuItem->Text = L"nahraj";
			this->nápovědaToolStripMenuItem->Click += gcnew System::EventHandler(this, &okno::nápovědaToolStripMenuItem_Click);
			// 
			// nápovědaToolStripMenuItem1
			// 
			this->nápovědaToolStripMenuItem1->Name = L"nápovědaToolStripMenuItem1";
			this->nápovědaToolStripMenuItem1->Size = System::Drawing::Size(71, 20);
			this->nápovědaToolStripMenuItem1->Text = L"nápověda";
			// 
			// openFileDialog1
			// 
			this->openFileDialog1->DefaultExt = L"svazek";
			this->openFileDialog1->Filter = L"data svazků|*.svazek|všechny soubory|*.*";
			// 
			// saveFileDialog1
			// 
			this->saveFileDialog1->DefaultExt = L"svazek";
			this->saveFileDialog1->Filter = L"data svazků|*.svazek";
			// 
			// dataGridView1
			// 
			this->dataGridView1->AllowUserToAddRows = false;
			this->dataGridView1->AllowUserToDeleteRows = false;
			this->dataGridView1->AllowUserToResizeColumns = false;
			this->dataGridView1->AllowUserToResizeRows = false;
			this->dataGridView1->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::AllCells;
			this->dataGridView1->AutoSizeRowsMode = System::Windows::Forms::DataGridViewAutoSizeRowsMode::AllCells;
			this->dataGridView1->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::Sunken;
			this->dataGridView1->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::Sunken;
			this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::DisableResizing;
			this->dataGridView1->Cursor = System::Windows::Forms::Cursors::Cross;
			this->dataGridView1->EditMode = System::Windows::Forms::DataGridViewEditMode::EditProgrammatically;
			this->dataGridView1->GridColor = System::Drawing::Color::Red;
			this->dataGridView1->ImeMode = System::Windows::Forms::ImeMode::Off;
			this->dataGridView1->Location = System::Drawing::Point(0, 50);
			this->dataGridView1->MultiSelect = false;
			this->dataGridView1->Name = L"dataGridView1";
			this->dataGridView1->ReadOnly = true;
			this->dataGridView1->RightToLeft = System::Windows::Forms::RightToLeft::No;
			this->dataGridView1->RowHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::Sunken;
			this->dataGridView1->RowHeadersWidthSizeMode = System::Windows::Forms::DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders;
			this->dataGridView1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
			this->dataGridView1->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
			this->dataGridView1->Size = System::Drawing::Size(514, 360);
			this->dataGridView1->StandardTab = true;
			this->dataGridView1->TabIndex = 7;
			this->dataGridView1->TabStop = false;
			this->dataGridView1->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &okno::dataGridView1_CellContentClick);
			// 
			// button1
			// 
			this->button1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right));
			this->button1->Location = System::Drawing::Point(399, 414);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(103, 36);
			this->button1->TabIndex = 7;
			this->button1->Text = L"přidat";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &okno::button1_Click);
			// 
			// comboBox1
			// 
			this->comboBox1->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->comboBox1->FormattingEnabled = true;
			this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(5) {
				L"1 propojení", L"2 rezistor 220", L"3 rez.+dioda",
					L"4 relé", L"5 spínač"
			});
			this->comboBox1->Location = System::Drawing::Point(56, 423);
			this->comboBox1->Name = L"comboBox1";
			this->comboBox1->Size = System::Drawing::Size(97, 21);
			this->comboBox1->TabIndex = 2;
			// 
			// textBox4
			// 
			this->textBox4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
				static_cast<System::Byte>(238)));
			this->textBox4->Location = System::Drawing::Point(0, 24);
			this->textBox4->MaxLength = 14;
			this->textBox4->Multiline = true;
			this->textBox4->Name = L"textBox4";
			this->textBox4->Size = System::Drawing::Size(514, 30);
			this->textBox4->TabIndex = 7;
			this->textBox4->TabStop = false;
			this->textBox4->TextChanged += gcnew System::EventHandler(this, &okno::textBox4_TextChanged);
			// 
			// numericUpDown1
			// 
			this->numericUpDown1->Location = System::Drawing::Point(230, 424);
			this->numericUpDown1->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 102, 0, 0, 0 });
			this->numericUpDown1->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
			this->numericUpDown1->Name = L"numericUpDown1";
			this->numericUpDown1->Size = System::Drawing::Size(39, 20);
			this->numericUpDown1->TabIndex = 8;
			this->numericUpDown1->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
			// 
			// numericUpDown2
			// 
			this->numericUpDown2->Location = System::Drawing::Point(339, 424);
			this->numericUpDown2->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 102, 0, 0, 0 });
			this->numericUpDown2->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
			this->numericUpDown2->Name = L"numericUpDown2";
			this->numericUpDown2->Size = System::Drawing::Size(39, 20);
			this->numericUpDown2->TabIndex = 9;
			this->numericUpDown2->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
			// 
			// numericUpDown3
			// 
			this->numericUpDown3->Location = System::Drawing::Point(11, 424);
			this->numericUpDown3->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 999, 0, 0, 0 });
			this->numericUpDown3->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
			this->numericUpDown3->Name = L"numericUpDown3";
			this->numericUpDown3->Size = System::Drawing::Size(39, 20);
			this->numericUpDown3->TabIndex = 10;
			this->numericUpDown3->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
			// 
			// comboBox2
			// 
			this->comboBox2->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->comboBox2->FormattingEnabled = true;
			this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^  >(4) { L"A", L"B", L"C", L"D" });
			this->comboBox2->Location = System::Drawing::Point(189, 423);
			this->comboBox2->Name = L"comboBox2";
			this->comboBox2->Size = System::Drawing::Size(35, 21);
			this->comboBox2->TabIndex = 11;
			// 
			// comboBox3
			// 
			this->comboBox3->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->comboBox3->FormattingEnabled = true;
			this->comboBox3->Items->AddRange(gcnew cli::array< System::Object^  >(4) { L"A", L"B", L"C", L"D" });
			this->comboBox3->Location = System::Drawing::Point(298, 423);
			this->comboBox3->Name = L"comboBox3";
			this->comboBox3->Size = System::Drawing::Size(35, 21);
			this->comboBox3->TabIndex = 12;
			// 
			// okno
			// 
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::None;
			this->ClientSize = System::Drawing::Size(514, 462);
			this->Controls->Add(this->comboBox3);
			this->Controls->Add(this->comboBox2);
			this->Controls->Add(this->numericUpDown3);
			this->Controls->Add(this->numericUpDown2);
			this->Controls->Add(this->numericUpDown1);
			this->Controls->Add(this->textBox4);
			this->Controls->Add(this->comboBox1);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->dataGridView1);
			this->Controls->Add(this->menuStrip1);
			this->MainMenuStrip = this->menuStrip1;
			this->MaximizeBox = false;
			this->MaximumSize = System::Drawing::Size(530, 500);
			this->MinimumSize = System::Drawing::Size(530, 500);
			this->Name = L"okno";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"Ammann harness manager";
			this->Load += gcnew System::EventHandler(this, &okno::okno_Load);
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->dataGridView1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown2))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDown3))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}




#pragma endregion
		String^ patth;
		
private: System::Void uložitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 
			 if (saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
			 {
				 String^ patth = System::IO::Path::GetFullPath(saveFileDialog1->FileName);
				 textBox4->Text = System::IO::Path::GetFileName(saveFileDialog1->FileName);
				 zapis_stream(patth);
			 }
			 }
private: System::Void otevřítToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

			 if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
			 {
				 reset_tabulky(dataGridView1);
				 String^ patth = System::IO::Path::GetFullPath(openFileDialog1->FileName);
				 textBox4->Text = System::IO::Path::GetFileName(openFileDialog1->FileName);
				 cteni_stream(patth, textBox4);
				 naplneni_tabulky(dataGridView1);
			 }
}
private: System::Void nápovědaToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 dataGridView1->ColumnCount = 0;
			 naplneni_tabulky(dataGridView1);
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 int formalita;
			 formalita = pridejpolozku(numericUpDown3, comboBox1, comboBox2, numericUpDown1, comboBox3, numericUpDown2, dataGridView1);
			 }
private: System::Void dataGridView1_CellContentClick(System::Object^  sender, System::Windows::Forms::DataGridViewCellEventArgs^  e) {
}
private: System::Void okno_Load(System::Object^  sender, System::EventArgs^  e) {
			 __int8 n;
			 dataGridView1->ColumnCount = 8;
			 dataGridView1->RowCount = 1;
			 array<String^>^ColName = gcnew 	array<String^>{"cislo", "soucastka", "konA", "pinA", "konB", "pinB", "byte1", "byte2"};
			 for (n = 0; n<8; n++)															//cyklus pro pojmenování sloupců
				 this->dataGridView1->Columns[n]->Name = ColName[n];
			

			
	}
private: System::Void novýToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 reset_tabulky(dataGridView1);
			 naplneni_tabulky(dataGridView1);
}
private: System::Void textBox4_TextChanged(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void uložitJakoToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			

			
}
};
}
