#pragma once

#include "GPSDataConversions.h"

// To avoid compiler warning about unused parameters.
#pragma warning(disable : 4100)

namespace GPSDataConverter {

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

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

			//System::Globalization::CultureInfo::CurrentCulture->NumberFormat->NumberDecimalSeparator = ".";

			//System::Globalization::CultureInfo^ ci = System::Globalization::CultureInfo::InstalledUICulture;

			//ni = (System::Globalization::NumberFormatInfo^)ci->NumberFormat->Clone();
			//ni->NumberDecimalSeparator = ".";

			try 
			{
				pLatDeg = new int;
				pLongDeg = new int;
				pLatMin = new int;
				pLongMin = new int;
				pLatDecMin = new double;
				pLongDecMin = new double;
				pLatDecSec = new double;
				pLongDecSec = new double;
				pLatDecDeg = new double;
				pLongDecDeg = new double;
				pNorthOrSouth = new char;
				pEastOrWest = new char;
			}
			catch (...) {}

			*pLatDeg = 0;
			*pLongDeg = 0;
			*pLatMin = 0;
			*pLongMin = 0;
			*pLatDecMin = 0;
			*pLongDecMin = 0;
			*pLatDecSec = 0;
			*pLongDecSec = 0;
			*pLatDecDeg = 0;
			*pLongDecDeg = 0;
			*pNorthOrSouth = 'N';
			*pEastOrWest = 'E';

			bUpdating = false;

			SetStyle(
				static_cast<ControlStyles>(ControlStyles::UserPaint | ControlStyles::AllPaintingInWmPaint), 
				true);
			UpdateStyles();
		}
	protected:
		/// <summary>
		/// Clean up unmanaged resources.
		/// </summary>
		!Form1()
		{
			// Finalizer cleans up unmanaged resources.
			// Destructor or garbage collector will
			// clean up managed resources.

			// Clean up code to release unmanaged resources.
			delete pEastOrWest;
			delete pNorthOrSouth;
			delete pLongDecDeg;
			delete pLatDecDeg;
			delete pLongDecSec;
			delete pLatDecSec;
			delete pLongDecMin;
			delete pLatDecMin;
			delete pLongMin;
			delete pLatMin;
			delete pLongDeg;
			delete pLatDeg;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			// Destructor cleans up all resources.

			// Clean up code to release managed resources.
			if (components)
			{
				delete components;
			}

			// To avoid code duplication 
			// call finalizer to release unmanaged resources.
			this->!Form1();
		}
		// Unmanaged resources.
	private: int* pLatDeg;
	private: int* pLongDeg;
	private: int* pLatMin;
	private: int* pLongMin;
	private: double* pLatDecMin;
	private: double* pLongDecMin;
	private: double* pLatDecSec;
	private: double* pLongDecSec;
	private: double* pLatDecDeg;
	private: double* pLongDecDeg;
	private: char* pNorthOrSouth;
	private: char* pEastOrWest;
			 // Managed resources.
	private: bool bUpdating;
	private: System::Globalization::NumberFormatInfo^ ni;
#pragma region Windows Form Designer generated code
	private: System::Windows::Forms::GroupBox^  latitudeGroupBox;
	private: System::Windows::Forms::Label^  latDirLabel;
	private: System::Windows::Forms::TextBox^  latDirTextBox;
	private: System::Windows::Forms::Label^  latMinLabel;
	private: System::Windows::Forms::TextBox^  latMinTextBox;
	private: System::Windows::Forms::Label^  latDecSecLabel;
	private: System::Windows::Forms::TextBox^  latDecSecTextBox;
	private: System::Windows::Forms::Label^  latDecMinLabel;
	private: System::Windows::Forms::TextBox^  latDecMinTextBox;
	private: System::Windows::Forms::Label^  latDegLabel;
	private: System::Windows::Forms::TextBox^  latDegTextBox;
	private: System::Windows::Forms::Label^  latDecDegLabel;
	private: System::Windows::Forms::TextBox^  latDecDegTextBox;
	private: System::Windows::Forms::GroupBox^  longitudeGroupBox;
	private: System::Windows::Forms::Label^  longDirLabel;
	private: System::Windows::Forms::TextBox^  longDirTextBox;
	private: System::Windows::Forms::Label^  longMinLabel;
	private: System::Windows::Forms::TextBox^  longMinTextBox;
	private: System::Windows::Forms::Label^  longDecSecLabel;
	private: System::Windows::Forms::TextBox^  longDecSecTextBox;
	private: System::Windows::Forms::Label^  longDecMinLabel;
	private: System::Windows::Forms::TextBox^  longDecMinTextBox;
	private: System::Windows::Forms::Label^  longDegLabel;
	private: System::Windows::Forms::TextBox^  longDegTextBox;
	private: System::Windows::Forms::Label^  longDecDegLabel;
	private: System::Windows::Forms::TextBox^  longDecDegTextBox;
	private: System::ComponentModel::IContainer^  components;

	protected: 

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

#pragma endregion

#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)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->latitudeGroupBox = (gcnew System::Windows::Forms::GroupBox());
			this->latDirLabel = (gcnew System::Windows::Forms::Label());
			this->latDirTextBox = (gcnew System::Windows::Forms::TextBox());
			this->latMinLabel = (gcnew System::Windows::Forms::Label());
			this->latMinTextBox = (gcnew System::Windows::Forms::TextBox());
			this->latDecSecLabel = (gcnew System::Windows::Forms::Label());
			this->latDecSecTextBox = (gcnew System::Windows::Forms::TextBox());
			this->latDecMinLabel = (gcnew System::Windows::Forms::Label());
			this->latDecMinTextBox = (gcnew System::Windows::Forms::TextBox());
			this->latDegLabel = (gcnew System::Windows::Forms::Label());
			this->latDegTextBox = (gcnew System::Windows::Forms::TextBox());
			this->latDecDegLabel = (gcnew System::Windows::Forms::Label());
			this->latDecDegTextBox = (gcnew System::Windows::Forms::TextBox());
			this->longitudeGroupBox = (gcnew System::Windows::Forms::GroupBox());
			this->longDirLabel = (gcnew System::Windows::Forms::Label());
			this->longDirTextBox = (gcnew System::Windows::Forms::TextBox());
			this->longMinLabel = (gcnew System::Windows::Forms::Label());
			this->longMinTextBox = (gcnew System::Windows::Forms::TextBox());
			this->longDecSecLabel = (gcnew System::Windows::Forms::Label());
			this->longDecSecTextBox = (gcnew System::Windows::Forms::TextBox());
			this->longDecMinLabel = (gcnew System::Windows::Forms::Label());
			this->longDecMinTextBox = (gcnew System::Windows::Forms::TextBox());
			this->longDegLabel = (gcnew System::Windows::Forms::Label());
			this->longDegTextBox = (gcnew System::Windows::Forms::TextBox());
			this->longDecDegLabel = (gcnew System::Windows::Forms::Label());
			this->longDecDegTextBox = (gcnew System::Windows::Forms::TextBox());
			this->latitudeGroupBox->SuspendLayout();
			this->longitudeGroupBox->SuspendLayout();
			this->SuspendLayout();
			// 
			// latitudeGroupBox
			// 
			this->latitudeGroupBox->Controls->Add(this->latDirLabel);
			this->latitudeGroupBox->Controls->Add(this->latDirTextBox);
			this->latitudeGroupBox->Controls->Add(this->latMinLabel);
			this->latitudeGroupBox->Controls->Add(this->latMinTextBox);
			this->latitudeGroupBox->Controls->Add(this->latDecSecLabel);
			this->latitudeGroupBox->Controls->Add(this->latDecSecTextBox);
			this->latitudeGroupBox->Controls->Add(this->latDecMinLabel);
			this->latitudeGroupBox->Controls->Add(this->latDecMinTextBox);
			this->latitudeGroupBox->Controls->Add(this->latDegLabel);
			this->latitudeGroupBox->Controls->Add(this->latDegTextBox);
			this->latitudeGroupBox->Controls->Add(this->latDecDegLabel);
			this->latitudeGroupBox->Controls->Add(this->latDecDegTextBox);
			this->latitudeGroupBox->Location = System::Drawing::Point(12, 14);
			this->latitudeGroupBox->Name = L"latitudeGroupBox";
			this->latitudeGroupBox->Size = System::Drawing::Size(280, 143);
			this->latitudeGroupBox->TabIndex = 4;
			this->latitudeGroupBox->TabStop = false;
			this->latitudeGroupBox->Text = L"Latitude";
			// 
			// latDirLabel
			// 
			this->latDirLabel->Location = System::Drawing::Point(218, 94);
			this->latDirLabel->Name = L"latDirLabel";
			this->latDirLabel->Size = System::Drawing::Size(50, 13);
			this->latDirLabel->TabIndex = 13;
			this->latDirLabel->Text = L"Direction";
			// 
			// latDirTextBox
			// 
			this->latDirTextBox->Location = System::Drawing::Point(221, 110);
			this->latDirTextBox->Name = L"latDirTextBox";
			this->latDirTextBox->Size = System::Drawing::Size(50, 20);
			this->latDirTextBox->TabIndex = 12;
			this->latDirTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::latDirTextBox_TextChanged);
			// 
			// latMinLabel
			// 
			this->latMinLabel->Location = System::Drawing::Point(62, 55);
			this->latMinLabel->Name = L"latMinLabel";
			this->latMinLabel->Size = System::Drawing::Size(50, 13);
			this->latMinLabel->TabIndex = 7;
			this->latMinLabel->Text = L"Minutes";
			// 
			// latMinTextBox
			// 
			this->latMinTextBox->Location = System::Drawing::Point(65, 71);
			this->latMinTextBox->Name = L"latMinTextBox";
			this->latMinTextBox->Size = System::Drawing::Size(50, 20);
			this->latMinTextBox->TabIndex = 6;
			this->latMinTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::latMinTextBox_TextChanged);
			// 
			// latDecSecLabel
			// 
			this->latDecSecLabel->Location = System::Drawing::Point(118, 55);
			this->latDecSecLabel->Name = L"latDecSecLabel";
			this->latDecSecLabel->Size = System::Drawing::Size(100, 13);
			this->latDecSecLabel->TabIndex = 9;
			this->latDecSecLabel->Text = L"Decimal seconds";
			// 
			// latDecSecTextBox
			// 
			this->latDecSecTextBox->Location = System::Drawing::Point(121, 71);
			this->latDecSecTextBox->Name = L"latDecSecTextBox";
			this->latDecSecTextBox->Size = System::Drawing::Size(150, 20);
			this->latDecSecTextBox->TabIndex = 8;
			this->latDecSecTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::latDecSecTextBox_TextChanged);
			// 
			// latDecMinLabel
			// 
			this->latDecMinLabel->Location = System::Drawing::Point(62, 94);
			this->latDecMinLabel->Name = L"latDecMinLabel";
			this->latDecMinLabel->Size = System::Drawing::Size(100, 13);
			this->latDecMinLabel->TabIndex = 11;
			this->latDecMinLabel->Text = L"Decimal minutes";
			// 
			// latDecMinTextBox
			// 
			this->latDecMinTextBox->Location = System::Drawing::Point(65, 110);
			this->latDecMinTextBox->Name = L"latDecMinTextBox";
			this->latDecMinTextBox->Size = System::Drawing::Size(150, 20);
			this->latDecMinTextBox->TabIndex = 10;
			this->latDecMinTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::latDecMinTextBox_TextChanged);
			// 
			// latDegLabel
			// 
			this->latDegLabel->Location = System::Drawing::Point(6, 55);
			this->latDegLabel->Name = L"latDegLabel";
			this->latDegLabel->Size = System::Drawing::Size(50, 13);
			this->latDegLabel->TabIndex = 5;
			this->latDegLabel->Text = L"Degrees";
			// 
			// latDegTextBox
			// 
			this->latDegTextBox->Location = System::Drawing::Point(9, 71);
			this->latDegTextBox->Name = L"latDegTextBox";
			this->latDegTextBox->Size = System::Drawing::Size(50, 20);
			this->latDegTextBox->TabIndex = 4;
			this->latDegTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::latDegTextBox_TextChanged);
			// 
			// latDecDegLabel
			// 
			this->latDecDegLabel->Location = System::Drawing::Point(6, 16);
			this->latDecDegLabel->Name = L"latDecDegLabel";
			this->latDecDegLabel->Size = System::Drawing::Size(100, 13);
			this->latDecDegLabel->TabIndex = 3;
			this->latDecDegLabel->Text = L"Decimal degrees";
			// 
			// latDecDegTextBox
			// 
			this->latDecDegTextBox->Location = System::Drawing::Point(9, 32);
			this->latDecDegTextBox->Name = L"latDecDegTextBox";
			this->latDecDegTextBox->Size = System::Drawing::Size(150, 20);
			this->latDecDegTextBox->TabIndex = 2;
			this->latDecDegTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::latDecDegTextBox_TextChanged);
			// 
			// longitudeGroupBox
			// 
			this->longitudeGroupBox->Controls->Add(this->longDirLabel);
			this->longitudeGroupBox->Controls->Add(this->longDirTextBox);
			this->longitudeGroupBox->Controls->Add(this->longMinLabel);
			this->longitudeGroupBox->Controls->Add(this->longMinTextBox);
			this->longitudeGroupBox->Controls->Add(this->longDecSecLabel);
			this->longitudeGroupBox->Controls->Add(this->longDecSecTextBox);
			this->longitudeGroupBox->Controls->Add(this->longDecMinLabel);
			this->longitudeGroupBox->Controls->Add(this->longDecMinTextBox);
			this->longitudeGroupBox->Controls->Add(this->longDegLabel);
			this->longitudeGroupBox->Controls->Add(this->longDegTextBox);
			this->longitudeGroupBox->Controls->Add(this->longDecDegLabel);
			this->longitudeGroupBox->Controls->Add(this->longDecDegTextBox);
			this->longitudeGroupBox->Location = System::Drawing::Point(300, 14);
			this->longitudeGroupBox->Name = L"longitudeGroupBox";
			this->longitudeGroupBox->Size = System::Drawing::Size(280, 143);
			this->longitudeGroupBox->TabIndex = 14;
			this->longitudeGroupBox->TabStop = false;
			this->longitudeGroupBox->Text = L"Longitude";
			// 
			// longDirLabel
			// 
			this->longDirLabel->Location = System::Drawing::Point(218, 94);
			this->longDirLabel->Name = L"longDirLabel";
			this->longDirLabel->Size = System::Drawing::Size(50, 13);
			this->longDirLabel->TabIndex = 13;
			this->longDirLabel->Text = L"Direction";
			// 
			// longDirTextBox
			// 
			this->longDirTextBox->Location = System::Drawing::Point(221, 110);
			this->longDirTextBox->Name = L"longDirTextBox";
			this->longDirTextBox->Size = System::Drawing::Size(50, 20);
			this->longDirTextBox->TabIndex = 12;
			this->longDirTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::longDirTextBox_TextChanged);
			// 
			// longMinLabel
			// 
			this->longMinLabel->Location = System::Drawing::Point(62, 55);
			this->longMinLabel->Name = L"longMinLabel";
			this->longMinLabel->Size = System::Drawing::Size(50, 13);
			this->longMinLabel->TabIndex = 7;
			this->longMinLabel->Text = L"Minutes";
			// 
			// longMinTextBox
			// 
			this->longMinTextBox->Location = System::Drawing::Point(65, 71);
			this->longMinTextBox->Name = L"longMinTextBox";
			this->longMinTextBox->Size = System::Drawing::Size(50, 20);
			this->longMinTextBox->TabIndex = 6;
			this->longMinTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::longMinTextBox_TextChanged);
			// 
			// longDecSecLabel
			// 
			this->longDecSecLabel->Location = System::Drawing::Point(118, 55);
			this->longDecSecLabel->Name = L"longDecSecLabel";
			this->longDecSecLabel->Size = System::Drawing::Size(100, 13);
			this->longDecSecLabel->TabIndex = 9;
			this->longDecSecLabel->Text = L"Decimal seconds";
			// 
			// longDecSecTextBox
			// 
			this->longDecSecTextBox->Location = System::Drawing::Point(121, 71);
			this->longDecSecTextBox->Name = L"longDecSecTextBox";
			this->longDecSecTextBox->Size = System::Drawing::Size(150, 20);
			this->longDecSecTextBox->TabIndex = 8;
			this->longDecSecTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::longDecSecTextBox_TextChanged);
			// 
			// longDecMinLabel
			// 
			this->longDecMinLabel->Location = System::Drawing::Point(62, 94);
			this->longDecMinLabel->Name = L"longDecMinLabel";
			this->longDecMinLabel->Size = System::Drawing::Size(100, 13);
			this->longDecMinLabel->TabIndex = 11;
			this->longDecMinLabel->Text = L"Decimal minutes";
			// 
			// longDecMinTextBox
			// 
			this->longDecMinTextBox->Location = System::Drawing::Point(65, 110);
			this->longDecMinTextBox->Name = L"longDecMinTextBox";
			this->longDecMinTextBox->Size = System::Drawing::Size(150, 20);
			this->longDecMinTextBox->TabIndex = 10;
			this->longDecMinTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::longDecMinTextBox_TextChanged);
			// 
			// longDegLabel
			// 
			this->longDegLabel->Location = System::Drawing::Point(6, 55);
			this->longDegLabel->Name = L"longDegLabel";
			this->longDegLabel->Size = System::Drawing::Size(50, 13);
			this->longDegLabel->TabIndex = 5;
			this->longDegLabel->Text = L"Degrees";
			// 
			// longDegTextBox
			// 
			this->longDegTextBox->Location = System::Drawing::Point(9, 71);
			this->longDegTextBox->Name = L"longDegTextBox";
			this->longDegTextBox->Size = System::Drawing::Size(50, 20);
			this->longDegTextBox->TabIndex = 4;
			this->longDegTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::longDegTextBox_TextChanged);
			// 
			// longDecDegLabel
			// 
			this->longDecDegLabel->Location = System::Drawing::Point(6, 16);
			this->longDecDegLabel->Name = L"longDecDegLabel";
			this->longDecDegLabel->Size = System::Drawing::Size(100, 13);
			this->longDecDegLabel->TabIndex = 3;
			this->longDecDegLabel->Text = L"Decimal degrees";
			// 
			// longDecDegTextBox
			// 
			this->longDecDegTextBox->Location = System::Drawing::Point(9, 32);
			this->longDecDegTextBox->Name = L"longDecDegTextBox";
			this->longDecDegTextBox->Size = System::Drawing::Size(150, 20);
			this->longDecDegTextBox->TabIndex = 2;
			this->longDecDegTextBox->TextChanged += gcnew System::EventHandler(this, &Form1::longDecDegTextBox_TextChanged);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(592, 169);
			this->Controls->Add(this->longitudeGroupBox);
			this->Controls->Add(this->latitudeGroupBox);
			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"GPS data conversions";
			this->latitudeGroupBox->ResumeLayout(false);
			this->latitudeGroupBox->PerformLayout();
			this->longitudeGroupBox->ResumeLayout(false);
			this->longitudeGroupBox->PerformLayout();
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void UpdateValues(void) {

				 latDecDegTextBox->Text = System::Double(*pLatDecDeg).ToString();
				 latDegTextBox->Text = System::Int32(*pLatDeg).ToString();
				 latDecMinTextBox->Text = System::Double(*pLatDecMin).ToString();
				 latMinTextBox->Text = System::Int32(*pLatMin).ToString();
				 latDecSecTextBox->Text = System::Double(*pLatDecSec).ToString();
				 latDirTextBox->Text = System::Char(*pNorthOrSouth).ToString();

				 longDecDegTextBox->Text = System::Double(*pLongDecDeg).ToString();
				 longDegTextBox->Text = System::Int32(*pLongDeg).ToString();
				 longDecMinTextBox->Text = System::Double(*pLongDecMin).ToString();
				 longMinTextBox->Text = System::Int32(*pLongMin).ToString();
				 longDecSecTextBox->Text = System::Double(*pLongDecSec).ToString();
				 longDirTextBox->Text = System::Char(*pEastOrWest).ToString();
			 }
	private: System::Void latDecDegTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLatDecDeg = Convert::ToDouble(latDecDegTextBox->Text);
						 GPSLatitudeDecDeg2DegMinDecSec(*pLatDecDeg, pLatDeg, pLatMin, pLatDecSec, pNorthOrSouth);
						 GPSLatitudeDecDeg2DegDecMin(*pLatDecDeg, pLatDeg, pLatDecMin, pNorthOrSouth);
						 latDegTextBox->Text = System::Int32(*pLatDeg).ToString();
						 latDecMinTextBox->Text = System::Double(*pLatDecMin).ToString();
						 latMinTextBox->Text = System::Int32(*pLatMin).ToString();
						 latDecSecTextBox->Text = System::Double(*pLatDecSec).ToString();
						 latDirTextBox->Text = System::Char(*pNorthOrSouth).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void longDecDegTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLongDecDeg = Convert::ToDouble(longDecDegTextBox->Text);
						 GPSLongitudeDecDeg2DegMinDecSec(*pLongDecDeg, pLongDeg, pLongMin, pLongDecSec, pEastOrWest);
						 GPSLongitudeDecDeg2DegDecMin(*pLongDecDeg, pLongDeg, pLongDecMin, pEastOrWest);
						 longDegTextBox->Text = System::Int32(*pLongDeg).ToString();
						 longDecMinTextBox->Text = System::Double(*pLongDecMin).ToString();
						 longMinTextBox->Text = System::Int32(*pLongMin).ToString();
						 longDecSecTextBox->Text = System::Double(*pLongDecSec).ToString();
						 longDirTextBox->Text = System::Char(*pEastOrWest).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void latDegTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLatDeg = Convert::ToInt32(latDegTextBox->Text);
						 GPSLatitudeDegDecMin2DecDeg(*pLatDeg, *pLatDecMin, *pNorthOrSouth, pLatDecDeg);
						 latDecDegTextBox->Text = System::Double(*pLatDecDeg).ToString();
						 latDecMinTextBox->Text = System::Double(*pLatDecMin).ToString();
						 latMinTextBox->Text = System::Int32(*pLatMin).ToString();
						 latDecSecTextBox->Text = System::Double(*pLatDecSec).ToString();
						 latDirTextBox->Text = System::Char(*pNorthOrSouth).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void longDegTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLongDeg = Convert::ToInt32(longDegTextBox->Text);
						 GPSLongitudeDegDecMin2DecDeg(*pLongDeg, *pLongDecMin, *pEastOrWest, pLongDecDeg);
						 longDecDegTextBox->Text = System::Double(*pLongDecDeg).ToString();
						 longDecMinTextBox->Text = System::Double(*pLongDecMin).ToString();
						 longMinTextBox->Text = System::Int32(*pLongMin).ToString();
						 longDecSecTextBox->Text = System::Double(*pLongDecSec).ToString();
						 longDirTextBox->Text = System::Char(*pEastOrWest).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void latMinTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLatMin = Convert::ToInt32(latMinTextBox->Text);
						 GPSLatitudeDegMinDecSec2DecDeg(*pLatDeg, *pLatMin, *pLatDecSec, *pNorthOrSouth, pLatDecDeg);
						 GPSLatitudeDecDeg2DegDecMin(*pLatDecDeg, pLatDeg, pLatDecMin, pNorthOrSouth);
						 latDecDegTextBox->Text = System::Double(*pLatDecDeg).ToString();
						 latDegTextBox->Text = System::Int32(*pLatDeg).ToString();
						 latDecMinTextBox->Text = System::Double(*pLatDecMin).ToString();
						 latDecSecTextBox->Text = System::Double(*pLatDecSec).ToString();
						 latDirTextBox->Text = System::Char(*pNorthOrSouth).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void longMinTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLongMin = Convert::ToInt32(longMinTextBox->Text);
						 GPSLongitudeDegMinDecSec2DecDeg(*pLongDeg, *pLongMin, *pLongDecSec, *pEastOrWest, pLongDecDeg);
						 GPSLongitudeDecDeg2DegDecMin(*pLongDecDeg, pLongDeg, pLongDecMin, pEastOrWest);
						 longDecDegTextBox->Text = System::Double(*pLongDecDeg).ToString();
						 longDegTextBox->Text = System::Int32(*pLongDeg).ToString();
						 longDecMinTextBox->Text = System::Double(*pLongDecMin).ToString();
						 longDecSecTextBox->Text = System::Double(*pLongDecSec).ToString();
						 longDirTextBox->Text = System::Char(*pEastOrWest).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void latDecSecTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLatDecSec = Convert::ToDouble(latDecSecTextBox->Text);
						 GPSLatitudeDegMinDecSec2DecDeg(*pLatDeg, *pLatMin, *pLatDecSec, *pNorthOrSouth, pLatDecDeg);
						 GPSLatitudeDecDeg2DegDecMin(*pLatDecDeg, pLatDeg, pLatDecMin, pNorthOrSouth);
						 latDecDegTextBox->Text = System::Double(*pLatDecDeg).ToString();
						 latDegTextBox->Text = System::Int32(*pLatDeg).ToString();
						 latDecMinTextBox->Text = System::Double(*pLatDecMin).ToString();
						 latMinTextBox->Text = System::Int32(*pLatMin).ToString();
						 latDirTextBox->Text = System::Char(*pNorthOrSouth).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void longDecSecTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLongDecSec = Convert::ToDouble(longDecSecTextBox->Text);
						 GPSLongitudeDegMinDecSec2DecDeg(*pLongDeg, *pLongMin, *pLongDecSec, *pEastOrWest, pLongDecDeg);
						 GPSLongitudeDecDeg2DegDecMin(*pLongDecDeg, pLongDeg, pLongDecMin, pEastOrWest);
						 longDecDegTextBox->Text = System::Double(*pLongDecDeg).ToString();
						 longDegTextBox->Text = System::Int32(*pLongDeg).ToString();
						 longDecMinTextBox->Text = System::Double(*pLongDecMin).ToString();
						 longMinTextBox->Text = System::Int32(*pLongMin).ToString();
						 longDirTextBox->Text = System::Char(*pEastOrWest).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void latDecMinTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLatDecMin = Convert::ToDouble(latDecMinTextBox->Text);
						 GPSLatitudeDegDecMin2DecDeg(*pLatDeg, *pLatDecMin, *pNorthOrSouth, pLatDecDeg);
						 GPSLatitudeDecDeg2DegMinDecSec(*pLatDecDeg, pLatDeg, pLatMin, pLatDecSec, pNorthOrSouth);
						 latDecDegTextBox->Text = System::Double(*pLatDecDeg).ToString();
						 latDegTextBox->Text = System::Int32(*pLatDeg).ToString();
						 latMinTextBox->Text = System::Int32(*pLatMin).ToString();
						 latDecSecTextBox->Text = System::Double(*pLatDecSec).ToString();
						 latDirTextBox->Text = System::Char(*pNorthOrSouth).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void longDecMinTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pLongDecMin = Convert::ToDouble(longDecMinTextBox->Text);
						 GPSLongitudeDegDecMin2DecDeg(*pLongDeg, *pLongDecMin, *pEastOrWest, pLongDecDeg);
						 GPSLongitudeDecDeg2DegMinDecSec(*pLongDecDeg, pLongDeg, pLongMin, pLongDecSec, pEastOrWest);
						 longDecDegTextBox->Text = System::Double(*pLongDecDeg).ToString();
						 longDegTextBox->Text = System::Int32(*pLongDeg).ToString();
						 longMinTextBox->Text = System::Int32(*pLongMin).ToString();
						 longDecSecTextBox->Text = System::Double(*pLongDecSec).ToString();
						 longDirTextBox->Text = System::Char(*pEastOrWest).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void latDirTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pNorthOrSouth = (char)Convert::ToChar(latDirTextBox->Text);
						 GPSLatitudeDegDecMin2DecDeg(*pLatDeg, *pLatDecMin, *pNorthOrSouth, pLatDecDeg);
						 latDecDegTextBox->Text = System::Double(*pLatDecDeg).ToString();
						 latDegTextBox->Text = System::Int32(*pLatDeg).ToString();
						 latDecMinTextBox->Text = System::Double(*pLatDecMin).ToString();
						 latMinTextBox->Text = System::Int32(*pLatMin).ToString();
						 latDecSecTextBox->Text = System::Double(*pLatDecSec).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	private: System::Void longDirTextBox_TextChanged(System::Object^  sender, System::EventArgs^  e) {

				 if (!bUpdating)
				 {
					 bUpdating = true;
					 try 
					 {
						 *pEastOrWest = (char)Convert::ToChar(longDirTextBox->Text);
						 GPSLongitudeDegDecMin2DecDeg(*pLongDeg, *pLongDecMin, *pEastOrWest, pLongDecDeg);
						 longDecDegTextBox->Text = System::Double(*pLongDecDeg).ToString();
						 longDegTextBox->Text = System::Int32(*pLongDeg).ToString();
						 longDecMinTextBox->Text = System::Double(*pLongDecMin).ToString();
						 longMinTextBox->Text = System::Int32(*pLongMin).ToString();
						 longDecSecTextBox->Text = System::Double(*pLongDecSec).ToString();
					 }
					 catch (...) {}
					 bUpdating = false;
				 }
			 }
	};
}
