#pragma once
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "NMEA.h"
#include "windows.h"
#include "map_rndf.h"
#include "math.h"

#define DegToRad(deg) ((Math::PI * (deg)) / 180.f)
#define RadToDeg(rad) ((180.f * (rad)) / Math::PI)

namespace DGPSv1 {
	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 System::Text;
	using namespace System::IO::Ports;
	using namespace System::Threading;
	using namespace System::IO;
	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::Timer^  timer1;
	private: System::Windows::Forms::CheckBox^  ck_log;
	private: System::Windows::Forms::ListBox^  listb_read;
	private: System::Windows::Forms::CheckBox^  ck_save_to_file;
	private: System::IO::Ports::SerialPort^  serial_port;
	private: System::Windows::Forms::PictureBox^  pictureBox1;
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::TrackBar^  trackBar1;
	private: System::Windows::Forms::Label^  label9;
	private: System::Windows::Forms::CheckBox^  checkBox13;
	private: System::Windows::Forms::Timer^  timer2;
	private: System::Windows::Forms::TabPage^  tabPage7;
	private: System::Windows::Forms::Button^  button11;
	private: System::Windows::Forms::CheckBox^  checkBox41;
	private: System::Windows::Forms::CheckBox^  checkBox40;
	private: System::Windows::Forms::CheckBox^  checkBox33;
	private: System::Windows::Forms::CheckBox^  checkBox34;
	private: System::Windows::Forms::CheckBox^  checkBox35;
	private: System::Windows::Forms::CheckBox^  checkBox36;
	private: System::Windows::Forms::CheckBox^  checkBox37;
	private: System::Windows::Forms::CheckBox^  checkBox38;
	private: System::Windows::Forms::CheckBox^  checkBox39;
	private: System::Windows::Forms::CheckBox^  checkBox26;
	private: System::Windows::Forms::CheckBox^  checkBox27;
	private: System::Windows::Forms::CheckBox^  checkBox28;
	private: System::Windows::Forms::CheckBox^  checkBox30;
	private: System::Windows::Forms::CheckBox^  checkBox31;
	private: System::Windows::Forms::CheckBox^  checkBox32;
	private: System::Windows::Forms::CheckBox^  checkBox25;
	private: System::Windows::Forms::CheckBox^  checkBox24;
	private: System::Windows::Forms::CheckBox^  checkBox23;
	private: System::Windows::Forms::CheckBox^  checkBox22;
	private: System::Windows::Forms::CheckBox^  checkBox21;
	private: System::Windows::Forms::CheckBox^  checkBox20;
	private: System::Windows::Forms::CheckBox^  checkBox19;
	private: System::Windows::Forms::CheckBox^  checkBox18;
	private: System::Windows::Forms::CheckBox^  checkBox17;
	private: System::Windows::Forms::CheckBox^  checkBox16;
	private: System::Windows::Forms::CheckBox^  checkBox15;
	private: System::Windows::Forms::CheckBox^  checkBox12;
	private: System::Windows::Forms::CheckBox^  checkBox11;
	private: System::Windows::Forms::TabPage^  tabPage6;
	private: System::Windows::Forms::TextBox^  textBox7;
	private: System::Windows::Forms::Button^  button16;
	private: System::Windows::Forms::Button^  button9;
	private: System::Windows::Forms::Button^  button8;
	private: System::Windows::Forms::Button^  button7;
	private: System::Windows::Forms::Button^  button6;
	private: System::Windows::Forms::Button^  button5;
	private: System::Windows::Forms::TextBox^  textBox1;
	private: System::Windows::Forms::Button^  button4;
	private: System::Windows::Forms::Button^  button3;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::ListBox^  listw_read;
	private: System::Windows::Forms::TabPage^  tabPage3;
	private: System::Windows::Forms::Label^  label17;
	private: System::Windows::Forms::Label^  lbl_different;
	private: System::Windows::Forms::Label^  lbl_sat_used;
	private: System::Windows::Forms::Label^  lbl_pos_type;
	private: System::Windows::Forms::Label^  lbl_UTM_Y;
	private: System::Windows::Forms::Label^  lbl_UTM_X;
	private: System::Windows::Forms::Label^  lbl_UTM_zone;
	private: System::Windows::Forms::Label^  lbl_alt;
	private: System::Windows::Forms::Label^  lbl_lon;
	private: System::Windows::Forms::Label^  lbl_lat;
	private: System::Windows::Forms::Label^  lbl_speed_kmh;
	private: System::Windows::Forms::Label^  lbl_date;
	private: System::Windows::Forms::Label^  lbl_time;
	private: System::Windows::Forms::TabPage^  tabPage4;
	private: System::Windows::Forms::Button^  button14;
	private: System::Windows::Forms::CheckBox^  checkBox3;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown2;
	private: System::Windows::Forms::Button^  button12;
	private: System::Windows::Forms::CheckBox^  checkBox10;
	private: System::Windows::Forms::CheckBox^  checkBox8;
	private: System::Windows::Forms::CheckBox^  checkBox2;
	private: System::Windows::Forms::TabPage^  tabPage5;
	private: System::Windows::Forms::Button^  button15;
	private: System::Windows::Forms::Label^  label8;
	private: System::Windows::Forms::TextBox^  textBox6;
	private: System::Windows::Forms::TextBox^  textBox5;
	private: System::Windows::Forms::Label^  lbl_UTM_DifferrentXY;
	private: System::Windows::Forms::Button^  button13;
	private: System::Windows::Forms::CheckBox^  checkBox5;
	private: System::Windows::Forms::CheckBox^  checkBox1;
	private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
	private: System::Windows::Forms::Label^  label10;
	private: System::Windows::Forms::Label^  label11;
	private: System::Windows::Forms::Label^  label12;
	private: System::Windows::Forms::TextBox^  textBox3;
	private: System::Windows::Forms::TextBox^  textBox2;
	private: System::Windows::Forms::TextBox^  textBox4;
	private: System::Windows::Forms::CheckBox^  checkBox7;
	private: System::Windows::Forms::Button^  button10;
	private: System::Windows::Forms::Label^  label13;
	private: System::Windows::Forms::Label^  label14;
	private: System::Windows::Forms::Label^  label15;
	private: System::Windows::Forms::TabPage^  tabPage2;
	private: System::Windows::Forms::CheckBox^  checkBox4;
	private: System::Windows::Forms::TextBox^  txt_write;
	private: System::Windows::Forms::Button^  btn_senddata;
	private: System::Windows::Forms::Label^  label7;
	private: System::Windows::Forms::TabPage^  tabPage1;
	private: System::Windows::Forms::ComboBox^  cmb_Handshaking;
	private: System::Windows::Forms::ComboBox^  cmb_Parity;
	private: System::Windows::Forms::ComboBox^  cmb_StopBits;
	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::Button^  btn_open_port;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::ComboBox^  cmb_DataBits;
	private: System::Windows::Forms::ComboBox^  cmb_BaudRate;
	private: System::Windows::Forms::ComboBox^  cmb_PortName;
	private: System::Windows::Forms::TabControl^  tab_control;
	private: System::Windows::Forms::Button^  button19;
	private: System::Windows::Forms::TextBox^  textBox8;




	protected: 
	private: System::ComponentModel::IContainer^  components;
	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->components = (gcnew System::ComponentModel::Container());
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->serial_port = (gcnew System::IO::Ports::SerialPort(this->components));
			this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
			this->ck_log = (gcnew System::Windows::Forms::CheckBox());
			this->listb_read = (gcnew System::Windows::Forms::ListBox());
			this->ck_save_to_file = (gcnew System::Windows::Forms::CheckBox());
			this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
			this->label9 = (gcnew System::Windows::Forms::Label());
			this->checkBox13 = (gcnew System::Windows::Forms::CheckBox());
			this->timer2 = (gcnew System::Windows::Forms::Timer(this->components));
			this->tabPage7 = (gcnew System::Windows::Forms::TabPage());
			this->button19 = (gcnew System::Windows::Forms::Button());
			this->textBox8 = (gcnew System::Windows::Forms::TextBox());
			this->button11 = (gcnew System::Windows::Forms::Button());
			this->checkBox41 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox40 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox33 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox34 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox35 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox36 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox37 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox38 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox39 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox26 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox27 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox28 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox30 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox31 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox32 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox25 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox24 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox23 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox22 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox21 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox20 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox19 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox18 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox17 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox16 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox15 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox12 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox11 = (gcnew System::Windows::Forms::CheckBox());
			this->tabPage6 = (gcnew System::Windows::Forms::TabPage());
			this->textBox7 = (gcnew System::Windows::Forms::TextBox());
			this->button16 = (gcnew System::Windows::Forms::Button());
			this->button9 = (gcnew System::Windows::Forms::Button());
			this->button8 = (gcnew System::Windows::Forms::Button());
			this->button7 = (gcnew System::Windows::Forms::Button());
			this->button6 = (gcnew System::Windows::Forms::Button());
			this->button5 = (gcnew System::Windows::Forms::Button());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->button4 = (gcnew System::Windows::Forms::Button());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->listw_read = (gcnew System::Windows::Forms::ListBox());
			this->tabPage3 = (gcnew System::Windows::Forms::TabPage());
			this->label17 = (gcnew System::Windows::Forms::Label());
			this->lbl_different = (gcnew System::Windows::Forms::Label());
			this->lbl_sat_used = (gcnew System::Windows::Forms::Label());
			this->lbl_pos_type = (gcnew System::Windows::Forms::Label());
			this->lbl_UTM_Y = (gcnew System::Windows::Forms::Label());
			this->lbl_UTM_X = (gcnew System::Windows::Forms::Label());
			this->lbl_UTM_zone = (gcnew System::Windows::Forms::Label());
			this->lbl_alt = (gcnew System::Windows::Forms::Label());
			this->lbl_lon = (gcnew System::Windows::Forms::Label());
			this->lbl_lat = (gcnew System::Windows::Forms::Label());
			this->lbl_speed_kmh = (gcnew System::Windows::Forms::Label());
			this->lbl_date = (gcnew System::Windows::Forms::Label());
			this->lbl_time = (gcnew System::Windows::Forms::Label());
			this->tabPage4 = (gcnew System::Windows::Forms::TabPage());
			this->button14 = (gcnew System::Windows::Forms::Button());
			this->checkBox3 = (gcnew System::Windows::Forms::CheckBox());
			this->numericUpDown2 = (gcnew System::Windows::Forms::NumericUpDown());
			this->button12 = (gcnew System::Windows::Forms::Button());
			this->checkBox10 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox8 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
			this->tabPage5 = (gcnew System::Windows::Forms::TabPage());
			this->button15 = (gcnew System::Windows::Forms::Button());
			this->label8 = (gcnew System::Windows::Forms::Label());
			this->textBox6 = (gcnew System::Windows::Forms::TextBox());
			this->textBox5 = (gcnew System::Windows::Forms::TextBox());
			this->lbl_UTM_DifferrentXY = (gcnew System::Windows::Forms::Label());
			this->button13 = (gcnew System::Windows::Forms::Button());
			this->checkBox5 = (gcnew System::Windows::Forms::CheckBox());
			this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
			this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
			this->label10 = (gcnew System::Windows::Forms::Label());
			this->label11 = (gcnew System::Windows::Forms::Label());
			this->label12 = (gcnew System::Windows::Forms::Label());
			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
			this->textBox4 = (gcnew System::Windows::Forms::TextBox());
			this->checkBox7 = (gcnew System::Windows::Forms::CheckBox());
			this->button10 = (gcnew System::Windows::Forms::Button());
			this->label13 = (gcnew System::Windows::Forms::Label());
			this->label14 = (gcnew System::Windows::Forms::Label());
			this->label15 = (gcnew System::Windows::Forms::Label());
			this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
			this->checkBox4 = (gcnew System::Windows::Forms::CheckBox());
			this->txt_write = (gcnew System::Windows::Forms::TextBox());
			this->btn_senddata = (gcnew System::Windows::Forms::Button());
			this->label7 = (gcnew System::Windows::Forms::Label());
			this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
			this->cmb_Handshaking = (gcnew System::Windows::Forms::ComboBox());
			this->cmb_Parity = (gcnew System::Windows::Forms::ComboBox());
			this->cmb_StopBits = (gcnew System::Windows::Forms::ComboBox());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->btn_open_port = (gcnew System::Windows::Forms::Button());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->cmb_DataBits = (gcnew System::Windows::Forms::ComboBox());
			this->cmb_BaudRate = (gcnew System::Windows::Forms::ComboBox());
			this->cmb_PortName = (gcnew System::Windows::Forms::ComboBox());
			this->tab_control = (gcnew System::Windows::Forms::TabControl());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->BeginInit();
			this->tabPage7->SuspendLayout();
			this->tabPage6->SuspendLayout();
			this->tabPage3->SuspendLayout();
			this->tabPage4->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown2))->BeginInit();
			this->tabPage5->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->BeginInit();
			this->tabPage2->SuspendLayout();
			this->tabPage1->SuspendLayout();
			this->tab_control->SuspendLayout();
			this->SuspendLayout();
			// 
			// serial_port
			// 
			this->serial_port->DataReceived += gcnew System::IO::Ports::SerialDataReceivedEventHandler(this, &Form1::serial_port_DataReceived);
			// 
			// timer1
			// 
			this->timer1->Enabled = true;
			this->timer1->Interval = 1;
			this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
			// 
			// ck_log
			// 
			this->ck_log->AutoSize = true;
			this->ck_log->Location = System::Drawing::Point(12, 239);
			this->ck_log->Name = L"ck_log";
			this->ck_log->Size = System::Drawing::Size(64, 17);
			this->ck_log->TabIndex = 7;
			this->ck_log->Text = L"Logging";
			this->ck_log->UseVisualStyleBackColor = true;
			this->ck_log->CheckedChanged += gcnew System::EventHandler(this, &Form1::ck_log_CheckedChanged);
			// 
			// listb_read
			// 
			this->listb_read->AllowDrop = true;
			this->listb_read->HorizontalScrollbar = true;
			this->listb_read->Location = System::Drawing::Point(2, 261);
			this->listb_read->Name = L"listb_read";
			this->listb_read->SelectionMode = System::Windows::Forms::SelectionMode::MultiExtended;
			this->listb_read->Size = System::Drawing::Size(738, 186);
			this->listb_read->TabIndex = 15;
			// 
			// ck_save_to_file
			// 
			this->ck_save_to_file->AutoSize = true;
			this->ck_save_to_file->Location = System::Drawing::Point(82, 239);
			this->ck_save_to_file->Name = L"ck_save_to_file";
			this->ck_save_to_file->Size = System::Drawing::Size(59, 17);
			this->ck_save_to_file->TabIndex = 8;
			this->ck_save_to_file->Text = L"Saving";
			this->ck_save_to_file->UseVisualStyleBackColor = true;
			this->ck_save_to_file->CheckedChanged += gcnew System::EventHandler(this, &Form1::ck_save_to_file_CheckedChanged);
			// 
			// pictureBox1
			// 
			this->pictureBox1->Cursor = System::Windows::Forms::Cursors::Hand;
			this->pictureBox1->Location = System::Drawing::Point(295, 3);
			this->pictureBox1->Margin = System::Windows::Forms::Padding(0);
			this->pictureBox1->Name = L"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(445, 226);
			this->pictureBox1->TabIndex = 17;
			this->pictureBox1->TabStop = false;
			this->pictureBox1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_MouseDown);
			this->pictureBox1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_MouseMove);
			this->pictureBox1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::pictureBox1_Paint);
			this->pictureBox1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_MouseUp);
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(665, 232);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(75, 23);
			this->button1->TabIndex = 18;
			this->button1->Text = L"Reset";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// trackBar1
			// 
			this->trackBar1->AllowDrop = true;
			this->trackBar1->AutoSize = false;
			this->trackBar1->BackColor = System::Drawing::SystemColors::ButtonFace;
			this->trackBar1->LargeChange = 1;
			this->trackBar1->Location = System::Drawing::Point(331, 232);
			this->trackBar1->Margin = System::Windows::Forms::Padding(0);
			this->trackBar1->Maximum = 200;
			this->trackBar1->Minimum = 1;
			this->trackBar1->Name = L"trackBar1";
			this->trackBar1->Size = System::Drawing::Size(331, 26);
			this->trackBar1->TabIndex = 19;
			this->trackBar1->TickStyle = System::Windows::Forms::TickStyle::None;
			this->trackBar1->Value = 10;
			this->trackBar1->Scroll += gcnew System::EventHandler(this, &Form1::trackBar1_Scroll);
			// 
			// label9
			// 
			this->label9->AutoSize = true;
			this->label9->Location = System::Drawing::Point(293, 237);
			this->label9->Name = L"label9";
			this->label9->Size = System::Drawing::Size(35, 13);
			this->label9->TabIndex = 20;
			this->label9->Text = L"label9";
			// 
			// checkBox13
			// 
			this->checkBox13->AutoSize = true;
			this->checkBox13->Location = System::Drawing::Point(241, 236);
			this->checkBox13->Name = L"checkBox13";
			this->checkBox13->Size = System::Drawing::Size(47, 17);
			this->checkBox13->TabIndex = 21;
			this->checkBox13->Text = L"Map";
			this->checkBox13->UseVisualStyleBackColor = true;
			this->checkBox13->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox13_CheckedChanged);
			// 
			// timer2
			// 
			this->timer2->Interval = 1;
			this->timer2->Tick += gcnew System::EventHandler(this, &Form1::timer2_Tick);
			// 
			// tabPage7
			// 
			this->tabPage7->Controls->Add(this->button19);
			this->tabPage7->Controls->Add(this->textBox8);
			this->tabPage7->Controls->Add(this->button11);
			this->tabPage7->Controls->Add(this->checkBox41);
			this->tabPage7->Controls->Add(this->checkBox40);
			this->tabPage7->Controls->Add(this->checkBox33);
			this->tabPage7->Controls->Add(this->checkBox34);
			this->tabPage7->Controls->Add(this->checkBox35);
			this->tabPage7->Controls->Add(this->checkBox36);
			this->tabPage7->Controls->Add(this->checkBox37);
			this->tabPage7->Controls->Add(this->checkBox38);
			this->tabPage7->Controls->Add(this->checkBox39);
			this->tabPage7->Controls->Add(this->checkBox26);
			this->tabPage7->Controls->Add(this->checkBox27);
			this->tabPage7->Controls->Add(this->checkBox28);
			this->tabPage7->Controls->Add(this->checkBox30);
			this->tabPage7->Controls->Add(this->checkBox31);
			this->tabPage7->Controls->Add(this->checkBox32);
			this->tabPage7->Controls->Add(this->checkBox25);
			this->tabPage7->Controls->Add(this->checkBox24);
			this->tabPage7->Controls->Add(this->checkBox23);
			this->tabPage7->Controls->Add(this->checkBox22);
			this->tabPage7->Controls->Add(this->checkBox21);
			this->tabPage7->Controls->Add(this->checkBox20);
			this->tabPage7->Controls->Add(this->checkBox19);
			this->tabPage7->Controls->Add(this->checkBox18);
			this->tabPage7->Controls->Add(this->checkBox17);
			this->tabPage7->Controls->Add(this->checkBox16);
			this->tabPage7->Controls->Add(this->checkBox15);
			this->tabPage7->Controls->Add(this->checkBox12);
			this->tabPage7->Controls->Add(this->checkBox11);
			this->tabPage7->Location = System::Drawing::Point(4, 22);
			this->tabPage7->Name = L"tabPage7";
			this->tabPage7->Size = System::Drawing::Size(282, 204);
			this->tabPage7->TabIndex = 6;
			this->tabPage7->Text = L"NMEA";
			this->tabPage7->UseVisualStyleBackColor = true;
			// 
			// button19
			// 
			this->button19->Location = System::Drawing::Point(116, 173);
			this->button19->Name = L"button19";
			this->button19->Size = System::Drawing::Size(80, 23);
			this->button19->TabIndex = 81;
			this->button19->Text = L"Save";
			this->button19->UseVisualStyleBackColor = true;
			this->button19->Click += gcnew System::EventHandler(this, &Form1::button19_Click);
			// 
			// textBox8
			// 
			this->textBox8->Location = System::Drawing::Point(60, 175);
			this->textBox8->Name = L"textBox8";
			this->textBox8->Size = System::Drawing::Size(50, 20);
			this->textBox8->TabIndex = 80;
			this->textBox8->Text = L"1.0";
			// 
			// button11
			// 
			this->button11->Location = System::Drawing::Point(207, 173);
			this->button11->Name = L"button11";
			this->button11->Size = System::Drawing::Size(68, 23);
			this->button11->TabIndex = 79;
			this->button11->Text = L"ALL OFF";
			this->button11->UseVisualStyleBackColor = true;
			this->button11->Click += gcnew System::EventHandler(this, &Form1::button11_Click);
			// 
			// checkBox41
			// 
			this->checkBox41->AutoSize = true;
			this->checkBox41->Location = System::Drawing::Point(6, 10);
			this->checkBox41->Name = L"checkBox41";
			this->checkBox41->Size = System::Drawing::Size(45, 17);
			this->checkBox41->TabIndex = 49;
			this->checkBox41->Text = L"AIM";
			this->checkBox41->UseVisualStyleBackColor = true;
			this->checkBox41->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox41_CheckedChanged);
			// 
			// checkBox40
			// 
			this->checkBox40->AutoSize = true;
			this->checkBox40->Location = System::Drawing::Point(216, 126);
			this->checkBox40->Name = L"checkBox40";
			this->checkBox40->Size = System::Drawing::Size(48, 17);
			this->checkBox40->TabIndex = 75;
			this->checkBox40->Text = L"ZDA";
			this->checkBox40->UseVisualStyleBackColor = true;
			this->checkBox40->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox40_CheckedChanged);
			// 
			// checkBox33
			// 
			this->checkBox33->AutoSize = true;
			this->checkBox33->Location = System::Drawing::Point(216, 102);
			this->checkBox33->Name = L"checkBox33";
			this->checkBox33->Size = System::Drawing::Size(50, 17);
			this->checkBox33->TabIndex = 74;
			this->checkBox33->Text = L"XMG";
			this->checkBox33->UseVisualStyleBackColor = true;
			this->checkBox33->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox33_CheckedChanged);
			// 
			// checkBox34
			// 
			this->checkBox34->AutoSize = true;
			this->checkBox34->Location = System::Drawing::Point(216, 79);
			this->checkBox34->Name = L"checkBox34";
			this->checkBox34->Size = System::Drawing::Size(48, 17);
			this->checkBox34->TabIndex = 73;
			this->checkBox34->Text = L"VTG";
			this->checkBox34->UseVisualStyleBackColor = true;
			this->checkBox34->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox34_CheckedChanged);
			// 
			// checkBox35
			// 
			this->checkBox35->AutoSize = true;
			this->checkBox35->Location = System::Drawing::Point(216, 56);
			this->checkBox35->Name = L"checkBox35";
			this->checkBox35->Size = System::Drawing::Size(50, 17);
			this->checkBox35->TabIndex = 72;
			this->checkBox35->Text = L"UTM";
			this->checkBox35->UseVisualStyleBackColor = true;
			this->checkBox35->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox35_CheckedChanged);
			// 
			// checkBox36
			// 
			this->checkBox36->AutoSize = true;
			this->checkBox36->Location = System::Drawing::Point(216, 33);
			this->checkBox36->Name = L"checkBox36";
			this->checkBox36->Size = System::Drawing::Size(49, 17);
			this->checkBox36->TabIndex = 71;
			this->checkBox36->Text = L"UKO";
			this->checkBox36->UseVisualStyleBackColor = true;
			this->checkBox36->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox36_CheckedChanged);
			// 
			// checkBox37
			// 
			this->checkBox37->AutoSize = true;
			this->checkBox37->Location = System::Drawing::Point(216, 10);
			this->checkBox37->Name = L"checkBox37";
			this->checkBox37->Size = System::Drawing::Size(47, 17);
			this->checkBox37->TabIndex = 70;
			this->checkBox37->Text = L"TTT";
			this->checkBox37->UseVisualStyleBackColor = true;
			this->checkBox37->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox37_CheckedChanged);
			// 
			// checkBox38
			// 
			this->checkBox38->AutoSize = true;
			this->checkBox38->Location = System::Drawing::Point(146, 148);
			this->checkBox38->Name = L"checkBox38";
			this->checkBox38->Size = System::Drawing::Size(49, 17);
			this->checkBox38->TabIndex = 69;
			this->checkBox38->Text = L"TCM";
			this->checkBox38->UseVisualStyleBackColor = true;
			this->checkBox38->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox38_CheckedChanged);
			// 
			// checkBox39
			// 
			this->checkBox39->AutoSize = true;
			this->checkBox39->Location = System::Drawing::Point(146, 125);
			this->checkBox39->Name = L"checkBox39";
			this->checkBox39->Size = System::Drawing::Size(47, 17);
			this->checkBox39->TabIndex = 68;
			this->checkBox39->Text = L"SAT";
			this->checkBox39->UseVisualStyleBackColor = true;
			this->checkBox39->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox39_CheckedChanged);
			// 
			// checkBox26
			// 
			this->checkBox26->AutoSize = true;
			this->checkBox26->Location = System::Drawing::Point(146, 102);
			this->checkBox26->Name = L"checkBox26";
			this->checkBox26->Size = System::Drawing::Size(49, 17);
			this->checkBox26->TabIndex = 67;
			this->checkBox26->Text = L"RRE";
			this->checkBox26->UseVisualStyleBackColor = true;
			this->checkBox26->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox26_CheckedChanged);
			// 
			// checkBox27
			// 
			this->checkBox27->AutoSize = true;
			this->checkBox27->Location = System::Drawing::Point(146, 56);
			this->checkBox27->Name = L"checkBox27";
			this->checkBox27->Size = System::Drawing::Size(47, 17);
			this->checkBox27->TabIndex = 65;
			this->checkBox27->Text = L"PTT";
			this->checkBox27->UseVisualStyleBackColor = true;
			this->checkBox27->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox27_CheckedChanged);
			// 
			// checkBox28
			// 
			this->checkBox28->AutoSize = true;
			this->checkBox28->Location = System::Drawing::Point(6, 177);
			this->checkBox28->Name = L"checkBox28";
			this->checkBox28->Size = System::Drawing::Size(48, 17);
			this->checkBox28->TabIndex = 77;
			this->checkBox28->Text = L"PER";
			this->checkBox28->UseVisualStyleBackColor = true;
			this->checkBox28->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox28_CheckedChanged);
			// 
			// checkBox30
			// 
			this->checkBox30->AutoSize = true;
			this->checkBox30->Location = System::Drawing::Point(146, 10);
			this->checkBox30->Name = L"checkBox30";
			this->checkBox30->Size = System::Drawing::Size(47, 17);
			this->checkBox30->TabIndex = 63;
			this->checkBox30->Text = L"LTN";
			this->checkBox30->UseVisualStyleBackColor = true;
			this->checkBox30->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox30_CheckedChanged);
			// 
			// checkBox31
			// 
			this->checkBox31->AutoSize = true;
			this->checkBox31->Location = System::Drawing::Point(76, 148);
			this->checkBox31->Name = L"checkBox31";
			this->checkBox31->Size = System::Drawing::Size(47, 17);
			this->checkBox31->TabIndex = 62;
			this->checkBox31->Text = L"HPL";
			this->checkBox31->UseVisualStyleBackColor = true;
			this->checkBox31->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox31_CheckedChanged);
			// 
			// checkBox32
			// 
			this->checkBox32->AutoSize = true;
			this->checkBox32->Location = System::Drawing::Point(76, 125);
			this->checkBox32->Name = L"checkBox32";
			this->checkBox32->Size = System::Drawing::Size(48, 17);
			this->checkBox32->TabIndex = 61;
			this->checkBox32->Text = L"GXP";
			this->checkBox32->UseVisualStyleBackColor = true;
			this->checkBox32->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox32_CheckedChanged);
			// 
			// checkBox25
			// 
			this->checkBox25->AutoSize = true;
			this->checkBox25->Location = System::Drawing::Point(76, 102);
			this->checkBox25->Name = L"checkBox25";
			this->checkBox25->Size = System::Drawing::Size(48, 17);
			this->checkBox25->TabIndex = 60;
			this->checkBox25->Text = L"GSV";
			this->checkBox25->UseVisualStyleBackColor = true;
			this->checkBox25->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox25_CheckedChanged);
			// 
			// checkBox24
			// 
			this->checkBox24->AutoSize = true;
			this->checkBox24->Location = System::Drawing::Point(76, 79);
			this->checkBox24->Name = L"checkBox24";
			this->checkBox24->Size = System::Drawing::Size(48, 17);
			this->checkBox24->TabIndex = 59;
			this->checkBox24->Text = L"GST";
			this->checkBox24->UseVisualStyleBackColor = true;
			this->checkBox24->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox24_CheckedChanged);
			// 
			// checkBox23
			// 
			this->checkBox23->AutoSize = true;
			this->checkBox23->Location = System::Drawing::Point(76, 56);
			this->checkBox23->Name = L"checkBox23";
			this->checkBox23->Size = System::Drawing::Size(49, 17);
			this->checkBox23->TabIndex = 58;
			this->checkBox23->Text = L"GSN";
			this->checkBox23->UseVisualStyleBackColor = true;
			this->checkBox23->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox23_CheckedChanged);
			// 
			// checkBox22
			// 
			this->checkBox22->AutoSize = true;
			this->checkBox22->Location = System::Drawing::Point(76, 33);
			this->checkBox22->Name = L"checkBox22";
			this->checkBox22->Size = System::Drawing::Size(48, 17);
			this->checkBox22->TabIndex = 57;
			this->checkBox22->Text = L"GSA";
			this->checkBox22->UseVisualStyleBackColor = true;
			this->checkBox22->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox22_CheckedChanged);
			// 
			// checkBox21
			// 
			this->checkBox21->AutoSize = true;
			this->checkBox21->Location = System::Drawing::Point(76, 10);
			this->checkBox21->Name = L"checkBox21";
			this->checkBox21->Size = System::Drawing::Size(49, 17);
			this->checkBox21->TabIndex = 56;
			this->checkBox21->Text = L"GRS";
			this->checkBox21->UseVisualStyleBackColor = true;
			this->checkBox21->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox21_CheckedChanged);
			// 
			// checkBox20
			// 
			this->checkBox20->AutoSize = true;
			this->checkBox20->Location = System::Drawing::Point(6, 148);
			this->checkBox20->Name = L"checkBox20";
			this->checkBox20->Size = System::Drawing::Size(49, 17);
			this->checkBox20->TabIndex = 55;
			this->checkBox20->Text = L"GNS";
			this->checkBox20->UseVisualStyleBackColor = true;
			this->checkBox20->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox20_CheckedChanged);
			// 
			// checkBox19
			// 
			this->checkBox19->AutoSize = true;
			this->checkBox19->Location = System::Drawing::Point(6, 125);
			this->checkBox19->Name = L"checkBox19";
			this->checkBox19->Size = System::Drawing::Size(46, 17);
			this->checkBox19->TabIndex = 54;
			this->checkBox19->Text = L"GLL";
			this->checkBox19->UseVisualStyleBackColor = true;
			this->checkBox19->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox19_CheckedChanged);
			// 
			// checkBox18
			// 
			this->checkBox18->AutoSize = true;
			this->checkBox18->Location = System::Drawing::Point(6, 102);
			this->checkBox18->Name = L"checkBox18";
			this->checkBox18->Size = System::Drawing::Size(49, 17);
			this->checkBox18->TabIndex = 53;
			this->checkBox18->Text = L"GGA";
			this->checkBox18->UseVisualStyleBackColor = true;
			this->checkBox18->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox18_CheckedChanged);
			// 
			// checkBox17
			// 
			this->checkBox17->AutoSize = true;
			this->checkBox17->Location = System::Drawing::Point(6, 79);
			this->checkBox17->Name = L"checkBox17";
			this->checkBox17->Size = System::Drawing::Size(49, 17);
			this->checkBox17->TabIndex = 52;
			this->checkBox17->Text = L"GDC";
			this->checkBox17->UseVisualStyleBackColor = true;
			this->checkBox17->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox17_CheckedChanged);
			// 
			// checkBox16
			// 
			this->checkBox16->AutoSize = true;
			this->checkBox16->Location = System::Drawing::Point(6, 56);
			this->checkBox16->Name = L"checkBox16";
			this->checkBox16->Size = System::Drawing::Size(50, 17);
			this->checkBox16->TabIndex = 51;
			this->checkBox16->Text = L"DTM";
			this->checkBox16->UseVisualStyleBackColor = true;
			this->checkBox16->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox16_CheckedChanged);
			// 
			// checkBox15
			// 
			this->checkBox15->AutoSize = true;
			this->checkBox15->Location = System::Drawing::Point(6, 33);
			this->checkBox15->Name = L"checkBox15";
			this->checkBox15->Size = System::Drawing::Size(48, 17);
			this->checkBox15->TabIndex = 50;
			this->checkBox15->Text = L"CRT";
			this->checkBox15->UseVisualStyleBackColor = true;
			this->checkBox15->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox15_CheckedChanged);
			// 
			// checkBox12
			// 
			this->checkBox12->AutoSize = true;
			this->checkBox12->Location = System::Drawing::Point(146, 33);
			this->checkBox12->Name = L"checkBox12";
			this->checkBox12->Size = System::Drawing::Size(48, 17);
			this->checkBox12->TabIndex = 64;
			this->checkBox12->Text = L"POS";
			this->checkBox12->UseVisualStyleBackColor = true;
			this->checkBox12->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox12_CheckedChanged);
			// 
			// checkBox11
			// 
			this->checkBox11->AutoSize = true;
			this->checkBox11->Location = System::Drawing::Point(146, 79);
			this->checkBox11->Name = L"checkBox11";
			this->checkBox11->Size = System::Drawing::Size(50, 17);
			this->checkBox11->TabIndex = 66;
			this->checkBox11->Text = L"RMC";
			this->checkBox11->UseVisualStyleBackColor = true;
			this->checkBox11->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox11_CheckedChanged);
			// 
			// tabPage6
			// 
			this->tabPage6->Controls->Add(this->textBox7);
			this->tabPage6->Controls->Add(this->button16);
			this->tabPage6->Controls->Add(this->button9);
			this->tabPage6->Controls->Add(this->button8);
			this->tabPage6->Controls->Add(this->button7);
			this->tabPage6->Controls->Add(this->button6);
			this->tabPage6->Controls->Add(this->button5);
			this->tabPage6->Controls->Add(this->textBox1);
			this->tabPage6->Controls->Add(this->button4);
			this->tabPage6->Controls->Add(this->button3);
			this->tabPage6->Controls->Add(this->button2);
			this->tabPage6->Controls->Add(this->listw_read);
			this->tabPage6->Location = System::Drawing::Point(4, 22);
			this->tabPage6->Name = L"tabPage6";
			this->tabPage6->Size = System::Drawing::Size(282, 204);
			this->tabPage6->TabIndex = 5;
			this->tabPage6->Text = L"Waypoints";
			this->tabPage6->UseVisualStyleBackColor = true;
			// 
			// textBox7
			// 
			this->textBox7->Location = System::Drawing::Point(206, 146);
			this->textBox7->Name = L"textBox7";
			this->textBox7->Size = System::Drawing::Size(72, 20);
			this->textBox7->TabIndex = 11;
			this->textBox7->Text = L"A";
			// 
			// button16
			// 
			this->button16->Location = System::Drawing::Point(120, 145);
			this->button16->Name = L"button16";
			this->button16->Size = System::Drawing::Size(80, 23);
			this->button16->TabIndex = 10;
			this->button16->Text = L"Read_RNDF";
			this->button16->UseVisualStyleBackColor = true;
			this->button16->Click += gcnew System::EventHandler(this, &Form1::button16_Click);
			// 
			// button9
			// 
			this->button9->Location = System::Drawing::Point(120, 33);
			this->button9->Name = L"button9";
			this->button9->Size = System::Drawing::Size(80, 23);
			this->button9->TabIndex = 1;
			this->button9->Text = L"Replace";
			this->button9->UseVisualStyleBackColor = true;
			this->button9->Click += gcnew System::EventHandler(this, &Form1::button9_Click);
			// 
			// button8
			// 
			this->button8->Location = System::Drawing::Point(120, 62);
			this->button8->Name = L"button8";
			this->button8->Size = System::Drawing::Size(79, 23);
			this->button8->TabIndex = 3;
			this->button8->Text = L"Move Up";
			this->button8->UseVisualStyleBackColor = true;
			this->button8->Click += gcnew System::EventHandler(this, &Form1::button8_Click);
			// 
			// button7
			// 
			this->button7->Location = System::Drawing::Point(120, 91);
			this->button7->Name = L"button7";
			this->button7->Size = System::Drawing::Size(80, 23);
			this->button7->TabIndex = 4;
			this->button7->Text = L"Move Down";
			this->button7->UseVisualStyleBackColor = true;
			this->button7->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
			// 
			// button6
			// 
			this->button6->Location = System::Drawing::Point(205, 91);
			this->button6->Name = L"button6";
			this->button6->Size = System::Drawing::Size(73, 23);
			this->button6->TabIndex = 6;
			this->button6->Text = L"Clear All";
			this->button6->UseVisualStyleBackColor = true;
			this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
			// 
			// button5
			// 
			this->button5->Location = System::Drawing::Point(206, 170);
			this->button5->Name = L"button5";
			this->button5->Size = System::Drawing::Size(73, 23);
			this->button5->TabIndex = 8;
			this->button5->Text = L"SaveToFile";
			this->button5->UseVisualStyleBackColor = true;
			this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(120, 7);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(159, 20);
			this->textBox1->TabIndex = 0;
			this->textBox1->Text = L"0;0";
			this->textBox1->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::textBox1_KeyDown);
			// 
			// button4
			// 
			this->button4->Location = System::Drawing::Point(206, 33);
			this->button4->Name = L"button4";
			this->button4->Size = System::Drawing::Size(73, 23);
			this->button4->TabIndex = 2;
			this->button4->Text = L"Insert";
			this->button4->UseVisualStyleBackColor = true;
			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
			// 
			// button3
			// 
			this->button3->Location = System::Drawing::Point(205, 62);
			this->button3->Name = L"button3";
			this->button3->Size = System::Drawing::Size(73, 23);
			this->button3->TabIndex = 5;
			this->button3->Text = L"Delete Select";
			this->button3->UseVisualStyleBackColor = true;
			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(120, 170);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(80, 23);
			this->button2->TabIndex = 7;
			this->button2->Text = L"Read_File";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
			// 
			// listw_read
			// 
			this->listw_read->FormattingEnabled = true;
			this->listw_read->Location = System::Drawing::Point(3, 7);
			this->listw_read->Name = L"listw_read";
			this->listw_read->Size = System::Drawing::Size(111, 186);
			this->listw_read->TabIndex = 9;
			// 
			// tabPage3
			// 
			this->tabPage3->Controls->Add(this->label17);
			this->tabPage3->Controls->Add(this->lbl_different);
			this->tabPage3->Controls->Add(this->lbl_sat_used);
			this->tabPage3->Controls->Add(this->lbl_pos_type);
			this->tabPage3->Controls->Add(this->lbl_UTM_Y);
			this->tabPage3->Controls->Add(this->lbl_UTM_X);
			this->tabPage3->Controls->Add(this->lbl_UTM_zone);
			this->tabPage3->Controls->Add(this->lbl_alt);
			this->tabPage3->Controls->Add(this->lbl_lon);
			this->tabPage3->Controls->Add(this->lbl_lat);
			this->tabPage3->Controls->Add(this->lbl_speed_kmh);
			this->tabPage3->Controls->Add(this->lbl_date);
			this->tabPage3->Controls->Add(this->lbl_time);
			this->tabPage3->Location = System::Drawing::Point(4, 22);
			this->tabPage3->Name = L"tabPage3";
			this->tabPage3->Size = System::Drawing::Size(282, 204);
			this->tabPage3->TabIndex = 2;
			this->tabPage3->Text = L"Position";
			this->tabPage3->UseVisualStyleBackColor = true;
			// 
			// label17
			// 
			this->label17->AutoSize = true;
			this->label17->Location = System::Drawing::Point(3, 168);
			this->label17->Name = L"label17";
			this->label17->Size = System::Drawing::Size(43, 13);
			this->label17->TabIndex = 14;
			this->label17->Text = L"Course:";
			// 
			// lbl_different
			// 
			this->lbl_different->AutoSize = true;
			this->lbl_different->Location = System::Drawing::Point(3, 155);
			this->lbl_different->Name = L"lbl_different";
			this->lbl_different->Size = System::Drawing::Size(50, 13);
			this->lbl_different->TabIndex = 11;
			this->lbl_different->Text = L"Different:";
			// 
			// lbl_sat_used
			// 
			this->lbl_sat_used->AutoSize = true;
			this->lbl_sat_used->Location = System::Drawing::Point(3, 142);
			this->lbl_sat_used->Name = L"lbl_sat_used";
			this->lbl_sat_used->Size = System::Drawing::Size(52, 13);
			this->lbl_sat_used->TabIndex = 10;
			this->lbl_sat_used->Text = L"Used sat:";
			// 
			// lbl_pos_type
			// 
			this->lbl_pos_type->AutoSize = true;
			this->lbl_pos_type->Location = System::Drawing::Point(3, 129);
			this->lbl_pos_type->Name = L"lbl_pos_type";
			this->lbl_pos_type->Size = System::Drawing::Size(40, 13);
			this->lbl_pos_type->TabIndex = 9;
			this->lbl_pos_type->Text = L"DGPS:";
			// 
			// lbl_UTM_Y
			// 
			this->lbl_UTM_Y->AutoSize = true;
			this->lbl_UTM_Y->Location = System::Drawing::Point(3, 116);
			this->lbl_UTM_Y->Name = L"lbl_UTM_Y";
			this->lbl_UTM_Y->Size = System::Drawing::Size(17, 13);
			this->lbl_UTM_Y->TabIndex = 8;
			this->lbl_UTM_Y->Text = L"Y:";
			// 
			// lbl_UTM_X
			// 
			this->lbl_UTM_X->AutoSize = true;
			this->lbl_UTM_X->Location = System::Drawing::Point(3, 103);
			this->lbl_UTM_X->Name = L"lbl_UTM_X";
			this->lbl_UTM_X->Size = System::Drawing::Size(17, 13);
			this->lbl_UTM_X->TabIndex = 7;
			this->lbl_UTM_X->Text = L"X:";
			// 
			// lbl_UTM_zone
			// 
			this->lbl_UTM_zone->AutoSize = true;
			this->lbl_UTM_zone->Location = System::Drawing::Point(3, 90);
			this->lbl_UTM_zone->Name = L"lbl_UTM_zone";
			this->lbl_UTM_zone->Size = System::Drawing::Size(62, 13);
			this->lbl_UTM_zone->TabIndex = 6;
			this->lbl_UTM_zone->Text = L"UTM Zone:";
			// 
			// lbl_alt
			// 
			this->lbl_alt->AutoSize = true;
			this->lbl_alt->Location = System::Drawing::Point(3, 77);
			this->lbl_alt->Name = L"lbl_alt";
			this->lbl_alt->Size = System::Drawing::Size(45, 13);
			this->lbl_alt->TabIndex = 5;
			this->lbl_alt->Text = L"Altitude:";
			// 
			// lbl_lon
			// 
			this->lbl_lon->AutoSize = true;
			this->lbl_lon->Location = System::Drawing::Point(3, 64);
			this->lbl_lon->Name = L"lbl_lon";
			this->lbl_lon->Size = System::Drawing::Size(54, 13);
			this->lbl_lon->TabIndex = 4;
			this->lbl_lon->Text = L"Longitude";
			// 
			// lbl_lat
			// 
			this->lbl_lat->AutoSize = true;
			this->lbl_lat->Location = System::Drawing::Point(3, 51);
			this->lbl_lat->Name = L"lbl_lat";
			this->lbl_lat->Size = System::Drawing::Size(48, 13);
			this->lbl_lat->TabIndex = 3;
			this->lbl_lat->Text = L"Latitude:";
			// 
			// lbl_speed_kmh
			// 
			this->lbl_speed_kmh->AutoSize = true;
			this->lbl_speed_kmh->Location = System::Drawing::Point(3, 38);
			this->lbl_speed_kmh->Name = L"lbl_speed_kmh";
			this->lbl_speed_kmh->Size = System::Drawing::Size(41, 13);
			this->lbl_speed_kmh->TabIndex = 2;
			this->lbl_speed_kmh->Text = L"Speed:";
			// 
			// lbl_date
			// 
			this->lbl_date->AutoSize = true;
			this->lbl_date->Location = System::Drawing::Point(3, 25);
			this->lbl_date->Name = L"lbl_date";
			this->lbl_date->Size = System::Drawing::Size(56, 13);
			this->lbl_date->TabIndex = 1;
			this->lbl_date->Text = L"UTC date:";
			// 
			// lbl_time
			// 
			this->lbl_time->AutoSize = true;
			this->lbl_time->Location = System::Drawing::Point(3, 12);
			this->lbl_time->Name = L"lbl_time";
			this->lbl_time->Size = System::Drawing::Size(54, 13);
			this->lbl_time->TabIndex = 0;
			this->lbl_time->Text = L"UTC time:";
			// 
			// tabPage4
			// 
			this->tabPage4->Controls->Add(this->button14);
			this->tabPage4->Controls->Add(this->checkBox3);
			this->tabPage4->Controls->Add(this->numericUpDown2);
			this->tabPage4->Controls->Add(this->button12);
			this->tabPage4->Controls->Add(this->checkBox10);
			this->tabPage4->Controls->Add(this->checkBox8);
			this->tabPage4->Controls->Add(this->checkBox2);
			this->tabPage4->Location = System::Drawing::Point(4, 22);
			this->tabPage4->Name = L"tabPage4";
			this->tabPage4->Size = System::Drawing::Size(282, 204);
			this->tabPage4->TabIndex = 3;
			this->tabPage4->Text = L"Remote";
			this->tabPage4->UseVisualStyleBackColor = true;
			// 
			// button14
			// 
			this->button14->Location = System::Drawing::Point(113, 178);
			this->button14->Name = L"button14";
			this->button14->Size = System::Drawing::Size(80, 23);
			this->button14->TabIndex = 48;
			this->button14->Text = L"Save";
			this->button14->UseVisualStyleBackColor = true;
			this->button14->Click += gcnew System::EventHandler(this, &Form1::button14_Click);
			// 
			// checkBox3
			// 
			this->checkBox3->AutoSize = true;
			this->checkBox3->Location = System::Drawing::Point(6, 91);
			this->checkBox3->Name = L"checkBox3";
			this->checkBox3->Size = System::Drawing::Size(209, 17);
			this->checkBox3->TabIndex = 47;
			this->checkBox3->Text = L"DYNAMIC MODE REMOTE STATION";
			this->checkBox3->UseVisualStyleBackColor = true;
			this->checkBox3->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox3_CheckedChanged);
			// 
			// numericUpDown2
			// 
			this->numericUpDown2->Location = System::Drawing::Point(221, 88);
			this->numericUpDown2->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {8, 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(47, 20);
			this->numericUpDown2->TabIndex = 46;
			this->numericUpDown2->Tag = L"";
			this->numericUpDown2->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
			this->numericUpDown2->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			// 
			// button12
			// 
			this->button12->Location = System::Drawing::Point(199, 178);
			this->button12->Name = L"button12";
			this->button12->Size = System::Drawing::Size(80, 23);
			this->button12->TabIndex = 24;
			this->button12->Text = L"Reset";
			this->button12->UseVisualStyleBackColor = true;
			this->button12->Click += gcnew System::EventHandler(this, &Form1::button12_Click);
			// 
			// checkBox10
			// 
			this->checkBox10->AutoSize = true;
			this->checkBox10->Location = System::Drawing::Point(6, 68);
			this->checkBox10->Name = L"checkBox10";
			this->checkBox10->Size = System::Drawing::Size(110, 17);
			this->checkBox10->TabIndex = 20;
			this->checkBox10->Text = L"KALMAN FILTER";
			this->checkBox10->UseVisualStyleBackColor = true;
			this->checkBox10->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox10_CheckedChanged);
			// 
			// checkBox8
			// 
			this->checkBox8->AutoSize = true;
			this->checkBox8->Location = System::Drawing::Point(6, 35);
			this->checkBox8->Name = L"checkBox8";
			this->checkBox8->Size = System::Drawing::Size(82, 17);
			this->checkBox8->TabIndex = 19;
			this->checkBox8->Text = L"RTCM,AUT";
			this->checkBox8->UseVisualStyleBackColor = true;
			this->checkBox8->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox8_CheckedChanged);
			// 
			// checkBox2
			// 
			this->checkBox2->AutoSize = true;
			this->checkBox2->Location = System::Drawing::Point(6, 12);
			this->checkBox2->Name = L"checkBox2";
			this->checkBox2->Size = System::Drawing::Size(84, 17);
			this->checkBox2->TabIndex = 18;
			this->checkBox2->Text = L"RTCM,REM";
			this->checkBox2->UseVisualStyleBackColor = true;
			this->checkBox2->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox2_CheckedChanged);
			// 
			// tabPage5
			// 
			this->tabPage5->Controls->Add(this->button15);
			this->tabPage5->Controls->Add(this->label8);
			this->tabPage5->Controls->Add(this->textBox6);
			this->tabPage5->Controls->Add(this->textBox5);
			this->tabPage5->Controls->Add(this->lbl_UTM_DifferrentXY);
			this->tabPage5->Controls->Add(this->button13);
			this->tabPage5->Controls->Add(this->checkBox5);
			this->tabPage5->Controls->Add(this->checkBox1);
			this->tabPage5->Controls->Add(this->numericUpDown1);
			this->tabPage5->Controls->Add(this->label10);
			this->tabPage5->Controls->Add(this->label11);
			this->tabPage5->Controls->Add(this->label12);
			this->tabPage5->Controls->Add(this->textBox3);
			this->tabPage5->Controls->Add(this->textBox2);
			this->tabPage5->Controls->Add(this->textBox4);
			this->tabPage5->Controls->Add(this->checkBox7);
			this->tabPage5->Controls->Add(this->button10);
			this->tabPage5->Controls->Add(this->label13);
			this->tabPage5->Controls->Add(this->label14);
			this->tabPage5->Controls->Add(this->label15);
			this->tabPage5->Location = System::Drawing::Point(4, 22);
			this->tabPage5->Name = L"tabPage5";
			this->tabPage5->Size = System::Drawing::Size(282, 204);
			this->tabPage5->TabIndex = 4;
			this->tabPage5->Tag = L"Lon[ddmm,mmmm]";
			this->tabPage5->Text = L"Base";
			this->tabPage5->UseVisualStyleBackColor = true;
			// 
			// button15
			// 
			this->button15->Location = System::Drawing::Point(113, 178);
			this->button15->Name = L"button15";
			this->button15->Size = System::Drawing::Size(80, 23);
			this->button15->TabIndex = 50;
			this->button15->Text = L"Save";
			this->button15->UseVisualStyleBackColor = true;
			this->button15->Click += gcnew System::EventHandler(this, &Form1::button15_Click);
			// 
			// label8
			// 
			this->label8->AutoSize = true;
			this->label8->Location = System::Drawing::Point(113, 93);
			this->label8->Name = L"label8";
			this->label8->Size = System::Drawing::Size(77, 13);
			this->label8->TabIndex = 49;
			this->label8->Text = L"UTM Y [0.000]";
			// 
			// textBox6
			// 
			this->textBox6->Location = System::Drawing::Point(196, 90);
			this->textBox6->Name = L"textBox6";
			this->textBox6->Size = System::Drawing::Size(82, 20);
			this->textBox6->TabIndex = 48;
			this->textBox6->Tag = L"";
			this->textBox6->Text = L"0,000";
			// 
			// textBox5
			// 
			this->textBox5->Location = System::Drawing::Point(196, 68);
			this->textBox5->Name = L"textBox5";
			this->textBox5->Size = System::Drawing::Size(82, 20);
			this->textBox5->TabIndex = 47;
			this->textBox5->Tag = L"";
			this->textBox5->Text = L"0,000";
			// 
			// lbl_UTM_DifferrentXY
			// 
			this->lbl_UTM_DifferrentXY->AutoSize = true;
			this->lbl_UTM_DifferrentXY->Location = System::Drawing::Point(113, 71);
			this->lbl_UTM_DifferrentXY->Name = L"lbl_UTM_DifferrentXY";
			this->lbl_UTM_DifferrentXY->Size = System::Drawing::Size(77, 13);
			this->lbl_UTM_DifferrentXY->TabIndex = 46;
			this->lbl_UTM_DifferrentXY->Text = L"UTM X [0.000]";
			// 
			// button13
			// 
			this->button13->Location = System::Drawing::Point(3, 111);
			this->button13->Name = L"button13";
			this->button13->Size = System::Drawing::Size(276, 23);
			this->button13->TabIndex = 45;
			this->button13->Text = L"Auto reading longitude,  latitude, altitude from GPS";
			this->button13->UseVisualStyleBackColor = true;
			this->button13->Click += gcnew System::EventHandler(this, &Form1::button13_Click);
			// 
			// checkBox5
			// 
			this->checkBox5->AutoSize = true;
			this->checkBox5->Location = System::Drawing::Point(6, 159);
			this->checkBox5->Name = L"checkBox5";
			this->checkBox5->Size = System::Drawing::Size(57, 17);
			this->checkBox5->TabIndex = 34;
			this->checkBox5->Text = L"RTCM";
			this->checkBox5->UseVisualStyleBackColor = true;
			this->checkBox5->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox5_CheckedChanged);
			// 
			// checkBox1
			// 
			this->checkBox1->AutoSize = true;
			this->checkBox1->Location = System::Drawing::Point(6, 139);
			this->checkBox1->Name = L"checkBox1";
			this->checkBox1->Size = System::Drawing::Size(191, 17);
			this->checkBox1->TabIndex = 37;
			this->checkBox1->Text = L"DYNAMIC MODE BASE STATION";
			this->checkBox1->UseVisualStyleBackColor = true;
			this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
			// 
			// numericUpDown1
			// 
			this->numericUpDown1->Location = System::Drawing::Point(203, 138);
			this->numericUpDown1->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) {8, 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(74, 20);
			this->numericUpDown1->TabIndex = 36;
			this->numericUpDown1->Tag = L"";
			this->numericUpDown1->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
			this->numericUpDown1->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
			// 
			// label10
			// 
			this->label10->AutoSize = true;
			this->label10->Location = System::Drawing::Point(314, 47);
			this->label10->Name = L"label10";
			this->label10->Size = System::Drawing::Size(21, 13);
			this->label10->TabIndex = 44;
			this->label10->Text = L"[m]";
			// 
			// label11
			// 
			this->label11->AutoSize = true;
			this->label11->Location = System::Drawing::Point(314, 26);
			this->label11->Name = L"label11";
			this->label11->Size = System::Drawing::Size(17, 13);
			this->label11->TabIndex = 43;
			this->label11->Text = L"[°]";
			// 
			// label12
			// 
			this->label12->AutoSize = true;
			this->label12->Location = System::Drawing::Point(314, 4);
			this->label12->Name = L"label12";
			this->label12->Size = System::Drawing::Size(17, 13);
			this->label12->TabIndex = 42;
			this->label12->Text = L"[°]";
			// 
			// textBox3
			// 
			this->textBox3->Location = System::Drawing::Point(197, 0);
			this->textBox3->Name = L"textBox3";
			this->textBox3->Size = System::Drawing::Size(82, 20);
			this->textBox3->TabIndex = 29;
			this->textBox3->Tag = L"";
			this->textBox3->Text = L"0000,00000";
			// 
			// textBox2
			// 
			this->textBox2->Location = System::Drawing::Point(197, 23);
			this->textBox2->Name = L"textBox2";
			this->textBox2->Size = System::Drawing::Size(82, 20);
			this->textBox2->TabIndex = 30;
			this->textBox2->Text = L"00000,00000";
			// 
			// textBox4
			// 
			this->textBox4->Location = System::Drawing::Point(197, 47);
			this->textBox4->Name = L"textBox4";
			this->textBox4->Size = System::Drawing::Size(81, 20);
			this->textBox4->TabIndex = 32;
			this->textBox4->Text = L"00000,00";
			// 
			// checkBox7
			// 
			this->checkBox7->AutoSize = true;
			this->checkBox7->Location = System::Drawing::Point(6, 21);
			this->checkBox7->Name = L"checkBox7";
			this->checkBox7->Size = System::Drawing::Size(77, 30);
			this->checkBox7->TabIndex = 33;
			this->checkBox7->Text = L"POSITION\r\nWGS-84\r\n";
			this->checkBox7->UseVisualStyleBackColor = true;
			this->checkBox7->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox7_CheckedChanged);
			// 
			// button10
			// 
			this->button10->Location = System::Drawing::Point(199, 178);
			this->button10->Name = L"button10";
			this->button10->Size = System::Drawing::Size(80, 23);
			this->button10->TabIndex = 41;
			this->button10->Text = L"Reset";
			this->button10->UseVisualStyleBackColor = true;
			this->button10->Click += gcnew System::EventHandler(this, &Form1::button10_Click);
			// 
			// label13
			// 
			this->label13->AutoSize = true;
			this->label13->Location = System::Drawing::Point(117, 47);
			this->label13->Name = L"label13";
			this->label13->Size = System::Drawing::Size(73, 13);
			this->label13->TabIndex = 40;
			this->label13->Text = L"Alt [aaaaa.aa]";
			// 
			// label14
			// 
			this->label14->AutoSize = true;
			this->label14->Location = System::Drawing::Point(82, 3);
			this->label14->Name = L"label14";
			this->label14->Size = System::Drawing::Size(108, 13);
			this->label14->TabIndex = 39;
			this->label14->Text = L"Lat [dddmm.mmmmm]";
			// 
			// label15
			// 
			this->label15->AutoSize = true;
			this->label15->Location = System::Drawing::Point(85, 26);
			this->label15->Name = L"label15";
			this->label15->Size = System::Drawing::Size(105, 13);
			this->label15->TabIndex = 35;
			this->label15->Text = L"Lon [ddmm.mmmmm]";
			// 
			// tabPage2
			// 
			this->tabPage2->Controls->Add(this->checkBox4);
			this->tabPage2->Controls->Add(this->txt_write);
			this->tabPage2->Controls->Add(this->btn_senddata);
			this->tabPage2->Controls->Add(this->label7);
			this->tabPage2->Location = System::Drawing::Point(4, 22);
			this->tabPage2->Name = L"tabPage2";
			this->tabPage2->Padding = System::Windows::Forms::Padding(3);
			this->tabPage2->Size = System::Drawing::Size(282, 204);
			this->tabPage2->TabIndex = 1;
			this->tabPage2->Text = L"Write";
			this->tabPage2->UseVisualStyleBackColor = true;
			// 
			// checkBox4
			// 
			this->checkBox4->AutoCheck = false;
			this->checkBox4->AutoSize = true;
			this->checkBox4->Location = System::Drawing::Point(9, 49);
			this->checkBox4->Name = L"checkBox4";
			this->checkBox4->Size = System::Drawing::Size(80, 17);
			this->checkBox4->TabIndex = 2;
			this->checkBox4->Text = L"non-accept";
			this->checkBox4->UseVisualStyleBackColor = true;
			// 
			// txt_write
			// 
			this->txt_write->Location = System::Drawing::Point(9, 19);
			this->txt_write->Name = L"txt_write";
			this->txt_write->Size = System::Drawing::Size(267, 20);
			this->txt_write->TabIndex = 0;
			this->txt_write->Text = L"$PASHS,NME,POS,A,ON";
			this->txt_write->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::txt_write_KeyDown);
			// 
			// btn_senddata
			// 
			this->btn_senddata->Location = System::Drawing::Point(201, 45);
			this->btn_senddata->Name = L"btn_senddata";
			this->btn_senddata->Size = System::Drawing::Size(75, 23);
			this->btn_senddata->TabIndex = 1;
			this->btn_senddata->Text = L"->Send";
			this->btn_senddata->UseVisualStyleBackColor = true;
			this->btn_senddata->Click += gcnew System::EventHandler(this, &Form1::Send_data_Click);
			// 
			// label7
			// 
			this->label7->AutoSize = true;
			this->label7->Location = System::Drawing::Point(6, 3);
			this->label7->Name = L"label7";
			this->label7->Size = System::Drawing::Size(30, 13);
			this->label7->TabIndex = 0;
			this->label7->Text = L"Data";
			// 
			// tabPage1
			// 
			this->tabPage1->Controls->Add(this->cmb_Handshaking);
			this->tabPage1->Controls->Add(this->cmb_Parity);
			this->tabPage1->Controls->Add(this->cmb_StopBits);
			this->tabPage1->Controls->Add(this->label6);
			this->tabPage1->Controls->Add(this->label5);
			this->tabPage1->Controls->Add(this->label4);
			this->tabPage1->Controls->Add(this->btn_open_port);
			this->tabPage1->Controls->Add(this->label3);
			this->tabPage1->Controls->Add(this->label2);
			this->tabPage1->Controls->Add(this->label1);
			this->tabPage1->Controls->Add(this->cmb_DataBits);
			this->tabPage1->Controls->Add(this->cmb_BaudRate);
			this->tabPage1->Controls->Add(this->cmb_PortName);
			this->tabPage1->Location = System::Drawing::Point(4, 22);
			this->tabPage1->Name = L"tabPage1";
			this->tabPage1->Padding = System::Windows::Forms::Padding(3);
			this->tabPage1->Size = System::Drawing::Size(282, 204);
			this->tabPage1->TabIndex = 0;
			this->tabPage1->Text = L"Port";
			this->tabPage1->UseVisualStyleBackColor = true;
			// 
			// cmb_Handshaking
			// 
			this->cmb_Handshaking->FormattingEnabled = true;
			this->cmb_Handshaking->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"None", L"XOnXOff", L"RequestToSend", L"RequestToSendXOnXOff"});
			this->cmb_Handshaking->Location = System::Drawing::Point(156, 130);
			this->cmb_Handshaking->Name = L"cmb_Handshaking";
			this->cmb_Handshaking->Size = System::Drawing::Size(111, 21);
			this->cmb_Handshaking->TabIndex = 5;
			this->cmb_Handshaking->Text = L"None";
			// 
			// cmb_Parity
			// 
			this->cmb_Parity->FormattingEnabled = true;
			this->cmb_Parity->Items->AddRange(gcnew cli::array< System::Object^  >(5) {L"None", L"Odd", L"Even", L"Mark", L"Space"});
			this->cmb_Parity->Location = System::Drawing::Point(156, 22);
			this->cmb_Parity->Name = L"cmb_Parity";
			this->cmb_Parity->Size = System::Drawing::Size(111, 21);
			this->cmb_Parity->TabIndex = 3;
			this->cmb_Parity->Text = L"None";
			// 
			// cmb_StopBits
			// 
			this->cmb_StopBits->FormattingEnabled = true;
			this->cmb_StopBits->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"1", L"1.5", L"2"});
			this->cmb_StopBits->Location = System::Drawing::Point(156, 73);
			this->cmb_StopBits->Name = L"cmb_StopBits";
			this->cmb_StopBits->Size = System::Drawing::Size(111, 21);
			this->cmb_StopBits->TabIndex = 4;
			this->cmb_StopBits->Text = L"1";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Location = System::Drawing::Point(153, 110);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(70, 13);
			this->label6->TabIndex = 9;
			this->label6->Text = L"Handshaking";
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Location = System::Drawing::Point(153, 57);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(49, 13);
			this->label5->TabIndex = 8;
			this->label5->Text = L"Stop Bits";
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(153, 3);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(33, 13);
			this->label4->TabIndex = 7;
			this->label4->Text = L"Parity";
			// 
			// btn_open_port
			// 
			this->btn_open_port->Location = System::Drawing::Point(19, 166);
			this->btn_open_port->Name = L"btn_open_port";
			this->btn_open_port->Size = System::Drawing::Size(248, 23);
			this->btn_open_port->TabIndex = 6;
			this->btn_open_port->Text = L"Open";
			this->btn_open_port->UseVisualStyleBackColor = true;
			this->btn_open_port->Click += gcnew System::EventHandler(this, &Form1::btn_open_port_Click);
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(16, 110);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(50, 13);
			this->label3->TabIndex = 6;
			this->label3->Text = L"Data Bits";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(16, 57);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(58, 13);
			this->label2->TabIndex = 5;
			this->label2->Text = L"Baud Rate";
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(16, 3);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(35, 13);
			this->label1->TabIndex = 4;
			this->label1->Text = L"Name";
			// 
			// cmb_DataBits
			// 
			this->cmb_DataBits->FormattingEnabled = true;
			this->cmb_DataBits->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"5", L"6", L"7", L"8"});
			this->cmb_DataBits->Location = System::Drawing::Point(19, 130);
			this->cmb_DataBits->Name = L"cmb_DataBits";
			this->cmb_DataBits->Size = System::Drawing::Size(111, 21);
			this->cmb_DataBits->TabIndex = 2;
			this->cmb_DataBits->Text = L"8";
			// 
			// cmb_BaudRate
			// 
			this->cmb_BaudRate->FormattingEnabled = true;
			this->cmb_BaudRate->Items->AddRange(gcnew cli::array< System::Object^  >(13) {L"300", L"600", L"1200", L"2400", L"4800", L"9600", 
				L"14400", L"19200", L"28800", L"38400", L"56000", L"57600", L"115200"});
			this->cmb_BaudRate->Location = System::Drawing::Point(19, 73);
			this->cmb_BaudRate->Name = L"cmb_BaudRate";
			this->cmb_BaudRate->Size = System::Drawing::Size(111, 21);
			this->cmb_BaudRate->TabIndex = 1;
			this->cmb_BaudRate->Text = L"9600";
			// 
			// cmb_PortName
			// 
			this->cmb_PortName->FormattingEnabled = true;
			this->cmb_PortName->Items->AddRange(gcnew cli::array< System::Object^  >(9) {L"COM1", L"COM2", L"COM3", L"COM4", L"COM5", 
				L"COM6", L"COM7", L"COM8", L"COM9"});
			this->cmb_PortName->Location = System::Drawing::Point(19, 22);
			this->cmb_PortName->Name = L"cmb_PortName";
			this->cmb_PortName->Size = System::Drawing::Size(111, 21);
			this->cmb_PortName->TabIndex = 0;
			this->cmb_PortName->Text = L"COM1";
			// 
			// tab_control
			// 
			this->tab_control->Controls->Add(this->tabPage1);
			this->tab_control->Controls->Add(this->tabPage2);
			this->tab_control->Controls->Add(this->tabPage5);
			this->tab_control->Controls->Add(this->tabPage4);
			this->tab_control->Controls->Add(this->tabPage3);
			this->tab_control->Controls->Add(this->tabPage6);
			this->tab_control->Controls->Add(this->tabPage7);
			this->tab_control->Location = System::Drawing::Point(2, 3);
			this->tab_control->Name = L"tab_control";
			this->tab_control->SelectedIndex = 0;
			this->tab_control->Size = System::Drawing::Size(290, 230);
			this->tab_control->TabIndex = 0;
			this->tab_control->Selecting += gcnew System::Windows::Forms::TabControlCancelEventHandler(this, &Form1::tab_control_Selecting);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
			this->ClientSize = System::Drawing::Size(293, 257);
			this->Controls->Add(this->checkBox13);
			this->Controls->Add(this->label9);
			this->Controls->Add(this->trackBar1);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->pictureBox1);
			this->Controls->Add(this->ck_save_to_file);
			this->Controls->Add(this->listb_read);
			this->Controls->Add(this->ck_log);
			this->Controls->Add(this->tab_control);
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
			this->Name = L"Form1";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"Differential GPS TM";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->trackBar1))->EndInit();
			this->tabPage7->ResumeLayout(false);
			this->tabPage7->PerformLayout();
			this->tabPage6->ResumeLayout(false);
			this->tabPage6->PerformLayout();
			this->tabPage3->ResumeLayout(false);
			this->tabPage3->PerformLayout();
			this->tabPage4->ResumeLayout(false);
			this->tabPage4->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown2))->EndInit();
			this->tabPage5->ResumeLayout(false);
			this->tabPage5->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->EndInit();
			this->tabPage2->ResumeLayout(false);
			this->tabPage2->PerformLayout();
			this->tabPage1->ResumeLayout(false);
			this->tabPage1->PerformLayout();
			this->tab_control->ResumeLayout(false);
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

// globalni promenne 
static String^ retezec;

static array<System::String^,1>^ List;

static double distance1=0; // vzdalenost od bodu
static double distance2=0; // vzdalenost celkova

static int px=0;
static int py=0;
static int pxdr=0;
static int pydr=0;
static int rx =0;
static int ry = 0;
static int korx;
static int kory;

static bool down=0;
static bool move=0;

// decode NMEA
static int pos_type, sat_used;
static double UTC_time,lat,lon;
static char lat_sector,lon_sector;
static int UTM_zone_num;
static char UTM_zone_char;

static float site_ID,alt,course,speed_knots,speed_ver,PDOP,HDOP,VDOP,TDOP;
//static char* id_firmware;
static char stat_pos;
static int UTC_date;
static bool save=0;

// UTM
static double UTC_hms;
static double UTM_X,UTM_Y,height_antenna;
static int fix_ind;
static int number_sat_used;
// VTG
static float course_north,course_mag_north,speed_kmh;

static Encoding^ ascii = Encoding::ASCII;
static Encoding^ unicode = Encoding::Unicode;


static float a;
static float b;
static int f=0;

static bool state =  0;
static bool state1 = 0; // kvuli testovani zda existuje port a rychlost, na ktere se da komunikovat
static bool state2 = 0; // povoleni cteni z ListBoxu do mapy
static int  state3 = 0; // kvuli potvrzovani zda se veta akceptovala
static bool state4 = 0; // zamceni pristupu TabPage dokud neni otevren port

static double X=0; // rozdily v UTM souradnicich odectene od BASE station
static double Y=0;

static double XXX = 0; //souradnice X UTM base station  - zjistim si to po zaskrtnuti POS u BASE
static double YYY = 0; //souradnice Y UTM base station  


private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
		 {	
			
			


		//	Form1::Text = actual_angle.ToString("0.0°");

			 List = serial_port->GetPortNames();	// zjisti aktualne pouzivane porty
			 cmb_PortName->Items->Clear();
			 cmb_PortName->Items->AddRange(List);	
			 if (List->Length > 0)
				cmb_PortName->Text = List[0]; 	
			 else cmb_PortName->Text = "";
			 label9->Text = Convert::ToString(trackBar1->Value);
		 }
private: System::Void btn_open_port_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (List->Length == 0) 
						 MessageBox::Show("You must have connect a device.", "Open Port",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
			 if ((!serial_port->IsOpen)&&(List->Length >0))
			 {   
						   
			// PortName
				 serial_port->PortName = cmb_PortName->Text;
			// BaudRate
				 serial_port->BaudRate = Convert::ToUInt32(cmb_BaudRate->Text);
		    // DataBits 
				 serial_port->DataBits = Convert::ToUInt32(cmb_DataBits->Text);
			// Parity
				 if (cmb_Parity->Text == "None") serial_port->Parity = Parity::None;
				 if (cmb_Parity->Text == "Even") serial_port->Parity = Parity::Even;
				 if (cmb_Parity->Text == "Mark") serial_port->Parity = Parity::Mark;
				 if (cmb_Parity->Text == "Space") serial_port->Parity = Parity::Space;
				 if (cmb_Parity->Text == "Odd") serial_port->Parity = Parity::Odd;
			// StopBits				 
				 if (cmb_StopBits->Text == "1")		serial_port->StopBits = StopBits::One;
				 if (cmb_StopBits->Text == "1.5")	serial_port->StopBits = StopBits::OnePointFive;
				 if (cmb_StopBits->Text == "2")		serial_port->StopBits = StopBits::Two;
			// Handshaking
				 if (cmb_Handshaking->Text == "None") serial_port->Handshake = Handshake::None;
				 if (cmb_Handshaking->Text == "XOnXOff") serial_port->Handshake = Handshake::XOnXOff;
				 if (cmb_Handshaking->Text == "RequestToSend") serial_port->Handshake = Handshake::RequestToSend;
				 if (cmb_Handshaking->Text == "RequestToSendXOnXOff") serial_port->Handshake = Handshake::RequestToSendXOnXOff;

				 serial_port->Open();
				 state4 = 1;	 

				 btn_open_port->Text = "Close";
			 }
			 else
			 {
       			serial_port->Close();
				state4 = 0;
				btn_open_port->Text = "Open";
				
			 }
		 }
private: System::Void serial_port_DataReceived(System::Object^  sender, System::IO::Ports::SerialDataReceivedEventArgs^  e) 
		 {
			   retezec = serial_port->ReadLine();
			   array<Byte>^unicodeBytes = unicode->GetBytes( retezec );
			   array<Byte>^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes );
			   char *str = new char[asciiBytes->GetLength(0) + 1];
			   for( int i = 0 ; i < asciiBytes->GetLength(0) ; i++ )
					str[i] = (char)asciiBytes[i];
			   char buffer[500]={0};
			   char *start = (char*)strchr(str,'$');
			   char *end = (char*)strchr(str,'*');
			   if ((start != NULL)&&(end != NULL)) strncpy_s(buffer,start,end-start);
			   char A='\0';
						   
			   //********** decode NMEA *********//
			   
			   // $PASHR,POS,d1,d2,m1,m2,c1,m3,c2,f1,f2,f3,f4,f5,f6,f7,f8,f9,s*cc	
				if (sscanf( buffer,"$PASHR,POS,%d,%d,%lf,%lf,%c,%lf,%c,%f,%f,%f,%f,%f,%f,%f,%f,%f,%4s",
											   &pos_type,&sat_used,&UTC_time,&lat,&lat_sector,&lon,&lon_sector,&alt)//,
																		  // &site_ID,&course,&speed_knots,&speed_ver,&PDOP,&HDOP,&VDOP,&TDOP)
																							  ==8)
				{}
				// $GPRMC,m1,c2,m3,c4,m5,c6,f7,f8,d9,f10,c11,d12*hh
				if (sscanf(buffer,"$GPRMC,%lf,%c,%lf,%c,%lf,%c,%f,%f,%d",
					&UTC_time,&stat_pos,&lat,&lat_sector,&lon,&lon_sector,&speed_knots,&course,&UTC_date)//,......  
																							  ==9)
				{}
			
				 //$PASHR,UTM,m1,m2,f3,f4,d5,d6,f7,f8,m,f9,m,d10,s11*hh
				if (sscanf( buffer,"$PASHR,UTM,%lf,%d%c,%lf,%lf,%d,%d,%f,%f,",
					&UTC_hms,&UTM_zone_num,&UTM_zone_char,&UTM_X,&UTM_Y,&fix_ind,&number_sat_used,&HDOP,&height_antenna)//,......  
																								==9)
				{
	   			    X = UTM_X - XXX;
					Y = UTM_Y - YYY;
					pictureBox1->Invalidate();
				}
				//$GPVTG,f1,c2,f3,c4,f5,c6,f7,c8,
				if (sscanf( buffer,"$GPVTG,%f,T,%f,M,%f,N,%f",
					&course_north,&course_mag_north,&speed_knots,&speed_kmh)//,......  
																								==7)
				{}

				//$PASHR,CRT,d1,d2,m1,m2,m3,m4,f2,f3,f4,f5,f6,f7,f8,f9,f10,s*cc
				//if (sscanf(buffer,"$PASHR,CRT,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%f,%f,%f,%f"))

			    state =	1;
     	 }

private: System::Void Send_data_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (serial_port->IsOpen) 
			 {
				 serial_port->WriteLine(txt_write->Text+"\r\n");
				 state3 = 10;
			 }
			 else
				 MessageBox::Show("You must have a open port.", "Open Port",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
		 }
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) 
		 {
				
			 if (state == 1) // je umozneno aktualizovat udaje
				{

				if (state3 != 0)
					{
						if ((retezec[0] == '$')&&(retezec[1] == 'P')&&(retezec[2] == 'A')&&(retezec[3] == 'S')&&(retezec[4] == 'H')&&(retezec[5] == 'R')&&(retezec[6] == ',')&&(retezec[7] == 'A')&&(retezec[8] == 'C')&&(retezec[9] == 'K'))
							
							switch (state3)
							{
							    case 2:	{ checkBox7->Checked = true;break;}
								case 3: { checkBox5->Checked = true;break;}
								case 4: { checkBox1->Checked = true;break;}
								case 5: { checkBox3->Checked = true;break;}
								case 6:	{ checkBox2->Checked = true;break;}
							    case 7:	{ checkBox8->Checked = true;break;}
								case 8: { checkBox10->Checked = true;break;}
								case 10: { checkBox4->Checked = true;checkBox4->Text = "accept";break;}
								
							}
						else
							switch (state3)
							{
							    case 2:	{ checkBox7->Checked = false;break;}
								case 3: { checkBox5->Checked = false;break;}
								case 4: { checkBox1->Checked = false;break;}
								case 5: { checkBox3->Checked = false;break;}
								case 6:	{ checkBox2->Checked = false;break;}
							    case 7:	{ checkBox8->Checked = false;break;}
								case 8: { checkBox10->Checked = false;break;}
								case 10: { checkBox4->Checked = false;checkBox4->Text = "non-accept";break;}
							
							}

					 state3 = 0;
					}


				 if (listb_read->Items->Count > 13) listb_read->Items->Clear();
				 
				 listb_read->Items->Add(retezec);
 		   
				 if (retezec->Length > 1)
					 {
						
						lbl_time->Text = UTC_time.ToString("UTC time: 00:00:00",nullptr);
						lbl_date->Text = UTC_date.ToString("UTC date: 00/00/00",nullptr);
						lbl_speed_kmh->Text = speed_kmh.ToString("Speed: 0.0 km/h",nullptr); 
											
						lbl_lat->Text = lat.ToString("Latitude: 00°00.00000") +"' " + Convert::ToChar(lat_sector);
						lbl_lon->Text = lon.ToString("Longitude: 000°00.00000") +"' "+Convert::ToChar(lon_sector);
						lbl_alt->Text = alt.ToString("Altitude: 0.00 m");

						lbl_UTM_zone->Text = "Zone UTM: "+ Convert::ToString(UTM_zone_num)+ Convert::ToChar(UTM_zone_char);
						lbl_UTM_X->Text = UTM_X.ToString("X: 0.0000 m");
						lbl_UTM_Y->Text = UTM_Y.ToString("Y: 0.0000 m");

						lbl_sat_used->Text = sat_used.ToString("Used sat: 0");
					
						if (pos_type == 1)	lbl_pos_type->Text = "DGPS: active";
						else lbl_pos_type->Text = "DGPS: no active"; 
						lbl_different->Text ="X="+ X.ToString("0.000")+";Y="+Y.ToString("0.000");
						label17->Text = "Course: "+ course.ToString("000.00°");
						
						
						
						
						if (save == 1)
							{   
								StreamWriter^ sw = gcnew StreamWriter("GPSstream.txt",true,Encoding::ASCII );
								sw->WriteLine(retezec);
								sw->Close();
							}

					 }
				}
			 state = 0;
				
		 }
private: System::Void ck_log_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {	
			 if (ck_log->Checked != true) 
				 Form1::Height = 291;
			 else 	
				 Form1::Height = 489;

		 }
private: System::Void ck_save_to_file_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (serial_port->IsOpen) 

				 if (ck_save_to_file->Checked == false)
				 {	
					 StreamWriter^ sw = gcnew StreamWriter("GPSstream.txt",true,Encoding::ASCII );
					 sw->WriteLine(UTC_time.ToString("******** END TIME 00:00:00")+ UTC_date.ToString(" DATE 00/00/00 ************"));
					 sw->Close();
					 save = 0; 
				 }
				 else
				 {
					StreamWriter^ sw = gcnew StreamWriter("GPSstream.txt",true,Encoding::ASCII );
					sw->WriteLine(UTC_time.ToString("******** START TIME 00:00:00")+ UTC_date.ToString(" DATE 00/00/00 **********"));
					sw->Close();
					save = 1;
				 }	
			   else
				 ck_save_to_file->Checked = false;
		 }

private: System::Void kresli_sipku(System::Drawing::Graphics^ kam,Pen^ barva,float smer,float x, float y)
	 {
		 if (smer == -1)
			 return;

		float xs2 = 20.f*(float)Math::Sin(DegToRad(smer));
		float ys2 = 20.f*(float)Math::Cos(DegToRad(smer));
			 
		kam->DrawLine(barva,x,y,x+xs2,y-ys2);
		kam->DrawLine(barva,x+xs2,y-ys2,x+xs2-(float)Math::Sin(DegToRad(smer+30))*10,y-ys2+10*(float)Math::Cos(DegToRad(smer+30)));
		kam->DrawLine(barva,x+xs2,y-ys2,x+xs2-(float)Math::Sin(DegToRad(smer-30))*10,y-ys2+10*(float)Math::Cos(DegToRad(smer-30)));
		kam->DrawLine(barva,x,y,x-xs2,y+ys2);
	 }

private: System::Void pictureBox1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
		 {

    		e->Graphics->Clear(Color::White);

			Pen^ cerna = gcnew Pen(Color::Black);
			Pen^ cervena = gcnew Pen(Color::Red);
			Pen^ zelena = gcnew Pen(Color::Green,1.8f);

			System::Drawing::Font^ drawFont = gcnew System::Drawing::Font("Arial", 8);
			System::Drawing::Font^ drawFont8 = gcnew System::Drawing::Font("Arial", 8);

			SolidBrush^ drawBrush = gcnew SolidBrush(Color::Black);
			SolidBrush^ drawBrushgreen = gcnew SolidBrush(Color::Green);

			// vykresleni kompasu			 
			 
			 e->Graphics->DrawLine(zelena,pictureBox1->Width - 24,10,pictureBox1->Width -24, 40);  // od zhora dolu
			 e->Graphics->DrawLine(zelena,pictureBox1->Width - 39,25,pictureBox1->Width -9, 25); // zleva doprava
    		 e->Graphics->DrawLine(zelena,pictureBox1->Width - 39,25,pictureBox1->Width - 36, 22); // sipka vlevo
			 e->Graphics->DrawLine(zelena,pictureBox1->Width - 39,25,pictureBox1->Width - 36, 28);  
			 e->Graphics->DrawLine(zelena,pictureBox1->Width -9,25,pictureBox1->Width -12, 22); // sipka vpravo
			 e->Graphics->DrawLine(zelena,pictureBox1->Width -9,25,pictureBox1->Width -12, 28);  
			 e->Graphics->DrawLine(zelena,pictureBox1->Width - 27,37,pictureBox1->Width -24, 40); // sipka dole
			 e->Graphics->DrawLine(zelena,pictureBox1->Width - 21,37,pictureBox1->Width -24, 40);  
			 e->Graphics->DrawLine(zelena,pictureBox1->Width - 27,13,pictureBox1->Width - 24, 10); // sipka nahore
			 e->Graphics->DrawLine(zelena,pictureBox1->Width - 21,13,pictureBox1->Width - 24, 10);  
			 
			 // popsani os kompasu 
			 e->Graphics->DrawString("N",drawFont8,drawBrushgreen,(float)pictureBox1->Width-28,-2);
			 e->Graphics->DrawString("S",drawFont8,drawBrushgreen,(float)pictureBox1->Width-28,40);
			 e->Graphics->DrawString("W",drawFont8,drawBrushgreen,(float)pictureBox1->Width-52,19);
			 e->Graphics->DrawString("E",drawFont8,drawBrushgreen,(float)pictureBox1->Width-9,19);
			
			float x[5000];	// body z Listboxu (souboru) 
			float y[5000];
				
			double XX = X;
			double YY = Y;
				
			if (state2 == 1)
			{
		

			f=0;
			while(f < listw_read->Items->Count)
			{
			   String^  a;
			   a = listw_read->Items[f]->ToString();
			   
			   a = a->Replace(',','.');
			   
			   array<Byte>^unicodeBytes = unicode->GetBytes(a);
			   array<Byte>^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes );
			   
			   char *str = new char[asciiBytes->GetLength(0) + 1];
			  
			   for( int i = 0 ; i < asciiBytes->GetLength(0) ; i++ )
					str[i] = (char)asciiBytes[i];
			   str[asciiBytes->GetLength(0)] = '\0';
			   char buffer[400]={0};
			   strcpy(buffer,str);
			   
			   float x1,y1;
			

			   if (sscanf(buffer,"%f;%f",&x1,&y1)==2)
			   {
				   x[f] = x1;	// prirazeni jednotlivym polozkam ze seznamu souradnice x,y
				   y[f] = y1;
				   f++;
			   }


			}
	
		
			double actual_angle=0;
					
			if (listw_read->Items->Count > 0)
			{
			  	actual_angle =  180/Math::PI * atan2(y[0]+YYY-UTM_Y,x[0]+XXX-UTM_X);
				
				if ((y[0]+YYY-UTM_Y )>= 0)
					{
						if (actual_angle > 90) actual_angle = 360 + (90-actual_angle); 
						else actual_angle = 90 - actual_angle; 
					}	

					else
					  actual_angle = Math::Abs(actual_angle)+90;

			}

			e->Graphics->DrawString("Az["+actual_angle.ToString("0.0°]"),drawFont,drawBrush,2,(float)(pictureBox1->Height)-28-24-12);
			
			
				
			
			if ((move==1)&&(down==1)&&(listw_read->Items->Count > 0)) // soucasne stisknuti tlacitka a pohyb
				{
					pxdr = px - MousePosition.X;
			        pydr = py - MousePosition.Y;
				}
			
					// vzdalenost remote station od prvniho waypointu   
					distance1 = sqrtl(pow(x[0]-X,2)+pow(y[0]-Y ,2));
					
					distance2 = 0;
					for (int i=0;i < listw_read->Items->Count-1;i++)
					{
						// soucet vsech vzdalenosti waypointu	
						distance2 += sqrtl(pow(x[i]-x[i+1],2)+pow(y[i]-y[i+1],2));
					}
					// + pricteni vzdalenosti distance 1;						
					distance2 += distance1;
				//	Form1::Text = distance2.ToString("0.0")+"//"+distance1.ToString("0.00");

					e->Graphics->DrawString("dP["+distance1.ToString("0.0]"),drawFont,drawBrush,2,(float)pictureBox1->Height-28-12);
					e->Graphics->DrawString("dA["+distance2.ToString("0.0]"),drawFont,drawBrush,2,(float)(pictureBox1->Height)-28-24);

					float XX = (float)((MousePosition.X-(Form1::Location.X + pictureBox1->Location.X)-korx-4)*10.0/(float)trackBar1->Value);
					float YY = (float)(-(MousePosition.Y-(Form1::Location.Y + pictureBox1->Location.Y)- kory-30)*10.0/(float)trackBar1->Value);
				
					e->Graphics->DrawString("soc["+Convert::ToString((korx-pictureBox1->Width/2)*0.1*trackBar1->Value)+";"+Convert::ToString((-kory+pictureBox1->Height/2)*0.1*trackBar1->Value)+"]",drawFont,drawBrush,2,(float)pictureBox1->Height-28);
					e->Graphics->DrawString("coor["+ XX.ToString("0.0")+ ";" + YY.ToString("0.0") +"]",drawFont,drawBrush,2.0,(float)(pictureBox1->Height) - 16);


			// prepocet korekce k souradnicim x a y
			 korx = pictureBox1->Width/2-pxdr;
			 kory = pictureBox1->Height/2-pydr;

			// vykresleni souradnic u waypointu
			 for (int i=0;i < listw_read->Items->Count;i++)
				{	
					
					//	e->Graphics->DrawString(Convert::ToString(x[i])+";"+Convert::ToString(y[i]),drawFont8,drawBrush,(float)(x[i]*0.1*trackBar1->Value+korx),(float)(-y[i]*0.1*trackBar1->Value+kory-4));
					
					x[i]*= (float)0.1*trackBar1->Value;
					y[i]*= (float)0.1*trackBar1->Value;
					x[i]+=korx;
					y[i]-=kory;

					// vykreslovani bodu(krizek) do mapy
					int velikost_krizku = 4;
					if ((x[i] < pictureBox1->Width)&&( x[i] > 0 )&&
					    (-y[i] < pictureBox1->Height)&&(-y[i] > 0 ))
						 
					{
					   e->Graphics->DrawLine(cervena,x[i]-velikost_krizku,-y[i],x[i]+velikost_krizku,-y[i]);
					   e->Graphics->DrawLine(cervena,x[i],-y[i]-velikost_krizku,x[i],-y[i]+velikost_krizku);
					}
				}

			//spojeni bodu mezi sebou 
			 for (int i=0;i < listw_read->Items->Count - 1;i++)
					e->Graphics->DrawLine(cerna,x[i],-y[i],x[i+1],-y[i+1]);
			

			// vykresluje souradny system
				e->Graphics->DrawLine(cerna,pictureBox1->Width/2-pxdr,0,pictureBox1->Width/2-pxdr,pictureBox1->Height);
				e->Graphics->DrawLine(cerna,0,pictureBox1->Height/2-pydr,pictureBox1->Width,pictureBox1->Height/2-pydr);
			
			}
					XX = trackBar1->Value*XX*0.1+korx;
					YY = trackBar1->Value*YY*0.1-kory;

					
					
					if (listw_read->Items->Count >0)
					{
						e->Graphics->DrawLine(cervena,(float)XX,(float)-YY,x[0],-y[0]);
					}

					e->Graphics->DrawLine(cervena,(float)XX-7,-(float)YY,(float)XX+7,-(float)YY);
			        e->Graphics->DrawLine(cervena,(float)XX,-(float)YY-7,(float)XX,-(float)YY+7);
					e->Graphics->DrawString(X.ToString("0.0,") +";"+ Y.ToString("0.0"),drawFont8,drawBrush,(float)(X*0.1*trackBar1->Value+korx),(float)(-Y*0.1*trackBar1->Value+kory-4));
					kresli_sipku(e->Graphics,zelena,course,(float)(X*0.1*trackBar1->Value+korx),(float)(-Y*0.1*trackBar1->Value+kory));
					
	
		}
private: System::Void pictureBox1_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 down = 1;  
			 rx = -pxdr;
			 ry = -pydr;
			 px = MousePosition.X+pxdr;
			 py = MousePosition.Y+pydr;
		 }

private: System::Void pictureBox1_MouseMove(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			 move = 1;
			 pictureBox1->Invalidate();
		 }

private: System::Void pictureBox1_MouseUp(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
		 {
			  move = 0;
			  down =0;
		 }

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 // RESET zoom
			 korx = 0;
			 kory = 0;
			 pxdr = 0;			
			 pydr =0;
			 trackBar1->Value = 10;
			 label9->Text = Convert::ToString(trackBar1->Value);
			 pictureBox1->Invalidate();
		 }

private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
            // read from file to table 
    		int rows_file = 0; 
			listw_read->Items->Clear();
            FILE *fr = fopen("waypoints.txt","r");
			if (!fr)
				state2 = 0;
			else
			{
				while (!feof(fr))
				{
					char buffer[30];
					fgets(buffer,30,fr);
					if (sscanf(buffer,"%f;%f",&a,&b)==2)
					{
						listw_read->Items->Add(a.ToString("0.000") + ";" + b.ToString("0.000"));
						rows_file++;
					}
				}
				fclose(fr);
				state2 = 1;
			}
			pictureBox1->Invalidate();
		}
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) 
		 {

			 // Insert  
				
			   String^  b;
			   Encoding^ ascii = Encoding::ASCII;
			   Encoding^ unicode = Encoding::Unicode;
			   b = textBox1->Text;
			   array<Byte>^unicodeBytes = unicode->GetBytes(b);
			   array<Byte>^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes );
			   char *str = new char[asciiBytes->GetLength(0) + 1];
			   for( int i = 0 ; i < asciiBytes->GetLength(0) ; i++ )
					str[i] = (char)asciiBytes[i];
			   str[asciiBytes->GetLength(0)] = '\0';
			   char buffer[400]={0};
			   strcpy(buffer,str);

        	   float xa,ya;
			  			  
			   if ((sscanf(buffer,"%f;%f",&xa,&ya)==2))
			   {
				  				   
				    listw_read->Items->Insert(listw_read->SelectedIndex+1,Convert::ToString(xa)+";"+Convert::ToString(ya));
				    state2 = 1;
				    pictureBox1->Invalidate();
			   }
			   else
				 MessageBox::Show("Example: 12.0;5.9 --> x=12.0, y=5.9", "Error Value",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
		 }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			// delete Select Item[]
			 if (listw_read->SelectedIndex >= 0)	
			 {
				 listw_read->Items->RemoveAt(listw_read->SelectedIndex);
				 state2 =1;
				 pictureBox1->Invalidate();
				
			  }
			 
		 }
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			// save file			
			 StreamWriter^ fw = gcnew StreamWriter("waypoints.txt",false );

			 fw->WriteLine("BASE_UTM: X="+ XXX.ToString()+"; Y="+  YYY.ToString());
			
			 for (int f=0; f < listw_read->Items->Count ;f++)
			 { 
				String^ b =  listw_read->Items[f]->ToString();
				b = b->Replace(',','.');
				if (f!= listw_read->Items->Count-1) 
					fw->WriteLine(b);
				else fw->Write(b);
			 }

			 state2 = 1;
			 pictureBox1->Invalidate();
			 fw->Close();			 
		 }
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) 
		 {	 // Clear
			 listw_read->Items->Clear();
			 state2 = 1;
			 pictureBox1->Invalidate();
		 }
private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e) 
		 {	// Move UP
			if (listw_read->SelectedIndex >= 1)	
			  {
				 String^ c = listw_read->Items[listw_read->SelectedIndex-1]->ToString();
				  listw_read->Items->RemoveAt(listw_read->SelectedIndex-1);
				 listw_read->Items->Insert(listw_read->SelectedIndex+1,c);
				
				 state2 = 1;
				 pictureBox1->Invalidate();
			  }
		 }
private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 // Move DOWN
			 if ((listw_read->SelectedIndex < listw_read->Items->Count-1)&&(listw_read->SelectedIndex >= 0))
			  {
				 String^ c = listw_read->Items[listw_read->SelectedIndex+1]->ToString();
				 listw_read->Items->RemoveAt(listw_read->SelectedIndex+1);
				 listw_read->Items->Insert(listw_read->SelectedIndex,c);
				 state2 = 1;
				 pictureBox1->Invalidate();
			  }
		 }
private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 // REPLACE
			if (listw_read->SelectedIndex >= 0)
			{
				listw_read->Items->Insert(listw_read->SelectedIndex,textBox1->Text);
			    listw_read->Items->RemoveAt(listw_read->SelectedIndex);
				state2 = 1;
				pictureBox1->Invalidate();
			}

		 }

private: System::Void textBox1_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) 
		 {

			 // Posila po stisku enteru hodnoty do tabulky
			 if (e->KeyCode == Keys::Enter)
			 {
			   String^  b;
			   Encoding^ ascii = Encoding::ASCII;
			   Encoding^ unicode = Encoding::Unicode;
			   b = textBox1->Text;
			   array<Byte>^unicodeBytes = unicode->GetBytes(b);
			   array<Byte>^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes );
			   char *str = new char[asciiBytes->GetLength(0) + 1];
			   for( int i = 0 ; i < asciiBytes->GetLength(0) ; i++ )
					str[i] = (char)asciiBytes[i];
			   str[asciiBytes->GetLength(0)] = '\0';
			   char buffer[400]={0};
			   strcpy(buffer,str);

        	   float xa,ya;
			  			  
			   if ((sscanf(buffer,"%f;%f",&xa,&ya)==2))
			   {
				  				   
				    listw_read->Items->Insert(listw_read->SelectedIndex+1,Convert::ToString(xa)+";"+Convert::ToString(ya));
				    state2 = 1;
				    pictureBox1->Invalidate();
			   }
			   else
				 MessageBox::Show("Example: 12.0;5.9 --> x=12.0, y=5.9", "Error Value",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
			  
			 }
		 }
private: System::Void txt_write_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) 
		 {
			 if (e->KeyCode == Keys::Enter)
			 {
				 if (serial_port->IsOpen) 
				 {
					 serial_port->WriteLine(txt_write->Text+"\r\n");
                     state3 = 10;
				 }
				 else
					MessageBox::Show("You must have a open port.", "Open Port",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);	
			 }
		 }
private: System::Void trackBar1_Scroll(System::Object^  sender, System::EventArgs^  e) 
		 {
			 label9->Text = Convert::ToString(trackBar1->Value) + "x zoom";
			 pictureBox1->Invalidate();
		 }

private: System::Void button11_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 serial_port->WriteLine(ALLOFF);
			 
			 checkBox41->Checked = false;
			 checkBox15->Checked = false;
			 checkBox16->Checked = false;
			 checkBox17->Checked = false;
			 checkBox18->Checked = false;
			 checkBox19->Checked = false;
			 checkBox20->Checked = false;
			 checkBox28->Checked = false;
			 checkBox21->Checked = false;
			 checkBox22->Checked = false;
			 checkBox23->Checked = false;
			 checkBox24->Checked = false;
			 checkBox25->Checked = false;
			 checkBox32->Checked = false;
			 checkBox31->Checked = false;
			 checkBox30->Checked = false;
			 checkBox12->Checked = false;
			 checkBox27->Checked = false;
			 checkBox11->Checked = false;
			 checkBox26->Checked = false;
			 checkBox39->Checked = false;
			 checkBox38->Checked = false;
			 checkBox37->Checked = false;
			 checkBox36->Checked = false;
			 checkBox35->Checked = false;
			 checkBox34->Checked = false;
			 checkBox33->Checked = false;
			 checkBox40->Checked = false;

		 }
private: System::Void checkBox41_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
    		if (checkBox41->Checked == true) serial_port->WriteLine(AIMON);
			else serial_port->WriteLine(AIMOFF);

		 }
private: System::Void checkBox15_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox15->Checked == true) serial_port->WriteLine(CRTON);
			 else serial_port->WriteLine(CRTOFF);
		 }
private: System::Void checkBox16_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox16->Checked == true) serial_port->WriteLine(DTMON);
			 else serial_port->WriteLine(DTMOFF);
		 }
private: System::Void checkBox17_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
		 {
			 if (checkBox17->Checked == true) serial_port->WriteLine(GDCON);
			 else serial_port->WriteLine(GDCOFF);
		 }
private: System::Void checkBox18_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			  if (checkBox18->Checked == true) serial_port->WriteLine(GGAON);
			 else serial_port->WriteLine(GGAOFF);
		 }
private: System::Void checkBox19_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
		 {
			 if (checkBox19->Checked == true) serial_port->WriteLine(GLLON);
			 else serial_port->WriteLine(GLLOFF);
		 }
private: System::Void checkBox20_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
		 {
			 if (checkBox20->Checked == true) serial_port->WriteLine(GNSON);
			 else serial_port->WriteLine(GNSOFF);
		 }
private: System::Void checkBox21_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox21->Checked == true) serial_port->WriteLine(GRSON);
			 else serial_port->WriteLine(GRSOFF);
		 }
private: System::Void checkBox22_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox22->Checked == true) serial_port->WriteLine(GSAON);
			 else serial_port->WriteLine(GSAOFF);
		 }
private: System::Void checkBox23_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox23->Checked == true) serial_port->WriteLine(GSNON);
			 else serial_port->WriteLine(GSNOFF);
		 }
private: System::Void checkBox24_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox24->Checked == true) serial_port->WriteLine(GSTON);
			 else serial_port->WriteLine(GSTOFF);
		 }
private: System::Void checkBox25_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox25->Checked == true) serial_port->WriteLine(GSVON);
			 else serial_port->WriteLine(GSVOFF);
		 }
private: System::Void checkBox32_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox32->Checked == true) serial_port->WriteLine(GXPON);
			 else serial_port->WriteLine(GXPOFF);
		 }
private: System::Void checkBox31_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox31->Checked == true) serial_port->WriteLine(HPLON);
			 else serial_port->WriteLine(HPLOFF);
		 }
private: System::Void checkBox30_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox30->Checked == true) serial_port->WriteLine(LTNON);
			 else serial_port->WriteLine(LTNOFF);
		 }
private: System::Void checkBox28_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox28->Checked == true) serial_port->WriteLine("$PASHS,NME,PER," + textBox8->Text+ "\r\n");
		 }
private: System::Void checkBox27_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox27->Checked == true) serial_port->WriteLine(PTTON);
			 else serial_port->WriteLine(PTTOFF);
		 }
private: System::Void checkBox12_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			if (checkBox12->Checked == true) serial_port->WriteLine(POSAON);
			else serial_port->WriteLine(POSAOFF);
		 }
private: System::Void checkBox11_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			if (checkBox11->Checked == true) serial_port->WriteLine(RMCAON);
			else serial_port->WriteLine(RMCAOFF);
		 }
private: System::Void checkBox26_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox26->Checked == true) serial_port->WriteLine(RREON);
			 else serial_port->WriteLine(RREOFF);
		 }
private: System::Void checkBox39_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
           if (checkBox39->Checked == true) serial_port->WriteLine(SATON);
		   else serial_port->WriteLine(SATOFF);
		 }
private: System::Void checkBox38_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox38->Checked == true) serial_port->WriteLine(TCMON);
			 else serial_port->WriteLine(TCMOFF);
		 }
private: System::Void checkBox37_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox37->Checked == true) serial_port->WriteLine(TTTON);
			 else serial_port->WriteLine(TTTOFF);
		 }
private: System::Void checkBox36_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox36->Checked == true) serial_port->WriteLine(UKOON);
			 else serial_port->WriteLine(UKOOFF);
		 }
private: System::Void checkBox35_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
		 {
			 if (checkBox35->Checked == true) serial_port->WriteLine(UTMON);
			 else serial_port->WriteLine(UTMOFF);
		 }
private: System::Void checkBox34_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox34->Checked == true) serial_port->WriteLine(VTGON);
			 else serial_port->WriteLine(VTGOFF);
		 }
private: System::Void checkBox33_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox33->Checked == true) serial_port->WriteLine(XMGON);
			 else serial_port->WriteLine(XMGOFF);
		 }
private: System::Void checkBox40_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox40->Checked == true) serial_port->WriteLine(ZDAON);
			 else serial_port->WriteLine(ZDAOFF);
		 }
private: System::Void checkBox7_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
		        String^ lats = textBox3->Text;
				lats =lats->Replace(',','.');
				String^ lons = textBox2->Text;
				lons = lons->Replace(',','.');
				String^ alts = textBox4->Text;
				alts = alts->Replace(',','.');
			 
		if (checkBox7->Checked == true)
			{
				serial_port->WriteLine("$PASHS,POS,"+lats+",N,"+lons+",E,"+alts+"\r\n");
			    
				XXX = Convert::ToDouble(textBox5->Text); // viz deklarace
				YYY = Convert::ToDouble(textBox6->Text);
				
				state3 = 2;
			}
		 }
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox1->Checked == true)
			{	
				switch ((int)numericUpDown1->Value) // dynamicky rezim
				{   case 1: {serial_port->WriteLine(DYN1);break;}
					case 2: {serial_port->WriteLine(DYN2);break;}
					case 3: {serial_port->WriteLine(DYN3);break;}
					case 4: {serial_port->WriteLine(DYN4);break;}
					case 5: {serial_port->WriteLine(DYN5);break;}
					case 6: {serial_port->WriteLine(DYN6);break;}
					case 7: {serial_port->WriteLine(DYN7);break;}
					default : serial_port->WriteLine(DYN8);
				}
				state3 =4;
			}
		 }
private: System::Void checkBox5_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox5->Checked == true)
			{
				serial_port->WriteLine(RTCM);
				state3 = 3;
			}
		 }

private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 serial_port->WriteLine(RST); // RESET
		 }
private: System::Void checkBox2_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
		 if (checkBox2->Checked == true)
			{
			  serial_port->WriteLine(RTCREMB);
			  state3 = 6;
			}

		 }
private: System::Void checkBox8_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox8->Checked == true)
			{
				serial_port->WriteLine(RTCAUTY);
			    state3 = 7;
			}
		 }
private: System::Void checkBox10_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
		 {
			 if (checkBox10->Checked == true)
			{
				serial_port->WriteLine(KFPON); // zapnuti kalmanova filtru
				state3 = 8;
			}
		 }
private: System::Void checkBox3_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (checkBox3->Checked == true)
			{	
				switch ((int)numericUpDown2->Value)
				{
					case 1: {serial_port->WriteLine(DYN1);break;}
					case 2: {serial_port->WriteLine(DYN2);break;}
					case 3: {serial_port->WriteLine(DYN3);break;}
					case 4: {serial_port->WriteLine(DYN4);break;}
					case 5: {serial_port->WriteLine(DYN5);break;}
					case 6: {serial_port->WriteLine(DYN6);break;}
					case 7: {serial_port->WriteLine(DYN7);break;}
					default : serial_port->WriteLine(DYN8);
				}
			state3 = 5;
			}
			
		 }

private: System::Void button12_Click(System::Object^  sender, System::EventArgs^  e) 
		 {			 
			 serial_port->WriteLine(RST);
		 }
private: System::Void tab_control_Selecting(System::Object^  sender, System::Windows::Forms::TabControlCancelEventArgs^  e) 
		 {
			 if (state4 == 1)
			 {
				 tabPage5->Enabled = true;
			 	 tabPage4->Enabled = true;
				 tabPage7->Enabled = true;
			 }
			 else 
			 {
				 tabPage5->Enabled = false;
			 	 tabPage4->Enabled = false;
				 tabPage7->Enabled = false;
			 }

		 }
private: System::Void button13_Click(System::Object^  sender, System::EventArgs^  e) 
		 {

			 serial_port->WriteLine(POSAON);
			 serial_port->WriteLine(UTMON);
			
			 textBox3->Text = lat.ToString("0000.00000");
			 textBox2->Text = lon.ToString("00000.00000");
			 textBox4->Text = alt.ToString("00000.00");
			 
			 textBox5->Text = Convert::ToString(UTM_X);
			 textBox6->Text = Convert::ToString(UTM_Y);

		 }

private: System::Void checkBox13_CheckedChanged(System::Object^  sender, System::EventArgs^  e)
		 {
			 if (checkBox13->Checked)
			
			 {  
				 Form1::Width = 752;
				 timer2->Enabled = true;
				 pictureBox1->Invalidate();
			 }	
			 
			 else 
			 {
				 Form1::Width = 301;
				 timer2->Enabled = false;
			 }
		 }

private: System::Void button14_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 serial_port->WriteLine(SAVY); // ulozeni 
		 }
private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 serial_port->WriteLine(SAVY);
		 }
private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			  map_init();
			  map_load("rndf.txt");

			  String^  h;
			   h = textBox7->Text;
			   array<Byte>^unicodeBytes = unicode->GetBytes(h);
			   array<Byte>^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes );
			   char *str = new char[asciiBytes->GetLength(0) + 1];
			   for( int i = 0 ; i < asciiBytes->GetLength(0) ; i++ )
					str[i] = (char)asciiBytes[i];
			   str[asciiBytes->GetLength(0)] = '\0';
			   char   buffer[50];
			   strcpy(buffer,str);

			   map_select(buffer);
			  MAPPOINT cesta[5000];
			  int cesta_pocet = map_getpoints(cesta,5000);
			  listw_read->Items->Clear();
			  for (int i=0;i < cesta_pocet; i++)
			  {
				 // Nastaveni souradnic v zasobniku s rozdilem souradnic UTM BaseStation
				listw_read->Items->Add((cesta[i].x-XXX).ToString("0.000") + ";"+(cesta[i].y-YYY).ToString("0.000"));
				


			  }
			  state2 = 1;
			  pictureBox1->Invalidate();
		 }

private: System::Void timer2_Tick(System::Object^  sender, System::EventArgs^  e) 
		 {
			 if (distance1 <= 1)
			 {
				 if (listw_read->Items->Count >0)
					 listw_read->Items->RemoveAt(0);
			 }
			 pictureBox1->Invalidate();
		 }
private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			  if (serial_port->IsOpen) 
			 {
				 serial_port->WriteLine("$PASHS,SPD,A,9"+"\r\n");
				 Sleep(300);
				 serial_port->WriteLine("$PASHS,SPD,B,9"+"\r\n");
				 		 
			 }
			 else
				 MessageBox::Show("You must have a open port.", "Open Port",MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
		 }
private: System::Void button18_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
				 serial_port->WriteLine(SAVY); // 
		 }
private: System::Void button19_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 	 serial_port->WriteLine(SAVY);
		 }
private: System::Void checkBox6_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			    XXX = UTM_X;
			    YYY = UTM_Y;
		 }
private: System::Void radioButton2_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			
		 }
private: System::Void radioButton1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) 
		 {
			
		 }
};
}