// mainform.cs: main program  
// --------------------------------------------------------
// July 12,2004 
// By Xiaotao Shu.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;


namespace tools
{
	/// <summary>
	/// Summary description for MapSourceForm.
	/// </summary>
	public class MapSourceForm : System.Windows.Forms.Form
	{
		private string status;                        //current status of the data operation(insert edit or delete 
		private CurrencyManager cmMapSource;          //data manager
		public string WorkDir;								
		//components
		private System.Data.DataSet dataSet1;
		private System.Data.DataColumn dataColumn1;
		private System.Data.DataColumn dataColumn3;
		private System.Data.DataColumn dataColumn4;
		private System.Data.DataColumn dataColumn5;
		private System.Data.DataColumn dataColumn6;
		private System.Data.DataColumn dataColumn7;
		private System.Data.DataTable dtMapSource;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn5;
		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn6;
		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn7;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.TextBox textBox_bottom;
		private System.Windows.Forms.TextBox textBox_right;
		private System.Windows.Forms.TextBox textBox_left;
		private System.Windows.Forms.TextBox textBox_top;
		private System.Windows.Forms.Button button_browse;
		private System.Windows.Forms.TextBox textBox_fileName;
		private System.Windows.Forms.TextBox textBox_title;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.GroupBox groupBox4;
		private System.Windows.Forms.GroupBox groupBox5;
		private System.Windows.Forms.Label label_sec3;
		private System.Windows.Forms.Label label_min3;
		private System.Windows.Forms.Label label_de3;
		private System.Windows.Forms.Label labelsec4;
		private System.Windows.Forms.Label label_min4;
		private System.Windows.Forms.Label label_de4;
		private System.Windows.Forms.Label label_sec2;
		private System.Windows.Forms.Label label_min2;
		private System.Windows.Forms.Label label_de2;
		private System.Windows.Forms.Label label_sec1;
		private System.Windows.Forms.Label label_min1;
		private System.Windows.Forms.Label label_de1;
		private System.Windows.Forms.Label label_bottom;
		private System.Windows.Forms.Label label_right;
		private System.Windows.Forms.Label label1_left;
		private System.Windows.Forms.Label label_top;
		private System.Windows.Forms.Label label_file;
		private System.Windows.Forms.Label label_title;
		private System.Windows.Forms.TextBox textBox_right3;
		private System.Windows.Forms.TextBox textBox_right1;
		private System.Windows.Forms.TextBox textBox_bottom2;
		private System.Windows.Forms.TextBox textBox_bottom1;
		private System.Windows.Forms.TextBox textBox_left3;
		private System.Windows.Forms.TextBox textBox_left2;
		private System.Windows.Forms.TextBox textBox_left1;
		private System.Windows.Forms.TextBox textBox_top3;
		private System.Windows.Forms.TextBox textBox_top2;
		private System.Windows.Forms.TextBox textBox_top1;
		private System.Windows.Forms.TextBox textBox_right2;
		private System.Windows.Forms.TextBox textBox_bottom3;
		private System.Windows.Forms.RadioButton radioButton1;
		private System.Windows.Forms.RadioButton radioButton6;
		private System.Windows.Forms.RadioButton radioButton5;
		private System.Windows.Forms.RadioButton radioButton8;
		private System.Windows.Forms.RadioButton radioButton7;
		private System.Windows.Forms.RadioButton radioButton4;
		private System.Windows.Forms.RadioButton radioButton3;
		private System.Windows.Forms.RadioButton radioButton2;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Button button_edit;
		private System.Windows.Forms.Button button_delete;
		private System.Windows.Forms.Button button_colse;
		private System.Windows.Forms.Button button_insert;
		private System.Windows.Forms.Button button_next;
		private System.Windows.Forms.Button button_pre;
		private System.Windows.Forms.Button button_cancel;
		private System.Windows.Forms.Button button_ok;
		private System.Windows.Forms.Panel panel3;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public MapSourceForm()
		{
			InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#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>
		private void InitializeComponent()
		{
			this.dtMapSource = new System.Data.DataTable();
			this.dataColumn1 = new System.Data.DataColumn();
			this.dataColumn3 = new System.Data.DataColumn();
			this.dataColumn4 = new System.Data.DataColumn();
			this.dataColumn5 = new System.Data.DataColumn();
			this.dataColumn6 = new System.Data.DataColumn();
			this.dataColumn7 = new System.Data.DataColumn();
			this.dataSet1 = new System.Data.DataSet();
			this.panel2 = new System.Windows.Forms.Panel();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.groupBox5 = new System.Windows.Forms.GroupBox();
			this.radioButton6 = new System.Windows.Forms.RadioButton();
			this.radioButton5 = new System.Windows.Forms.RadioButton();
			this.textBox_right3 = new System.Windows.Forms.TextBox();
			this.label_sec3 = new System.Windows.Forms.Label();
			this.label_min3 = new System.Windows.Forms.Label();
			this.textBox_right2 = new System.Windows.Forms.TextBox();
			this.label_de3 = new System.Windows.Forms.Label();
			this.textBox_right1 = new System.Windows.Forms.TextBox();
			this.groupBox4 = new System.Windows.Forms.GroupBox();
			this.radioButton8 = new System.Windows.Forms.RadioButton();
			this.radioButton7 = new System.Windows.Forms.RadioButton();
			this.textBox_bottom3 = new System.Windows.Forms.TextBox();
			this.labelsec4 = new System.Windows.Forms.Label();
			this.label_min4 = new System.Windows.Forms.Label();
			this.textBox_bottom2 = new System.Windows.Forms.TextBox();
			this.label_de4 = new System.Windows.Forms.Label();
			this.textBox_bottom1 = new System.Windows.Forms.TextBox();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.radioButton4 = new System.Windows.Forms.RadioButton();
			this.radioButton3 = new System.Windows.Forms.RadioButton();
			this.textBox_left3 = new System.Windows.Forms.TextBox();
			this.label_sec2 = new System.Windows.Forms.Label();
			this.label_min2 = new System.Windows.Forms.Label();
			this.textBox_left2 = new System.Windows.Forms.TextBox();
			this.label_de2 = new System.Windows.Forms.Label();
			this.textBox_left1 = new System.Windows.Forms.TextBox();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.radioButton2 = new System.Windows.Forms.RadioButton();
			this.radioButton1 = new System.Windows.Forms.RadioButton();
			this.textBox_top3 = new System.Windows.Forms.TextBox();
			this.label_sec1 = new System.Windows.Forms.Label();
			this.label_min1 = new System.Windows.Forms.Label();
			this.textBox_top2 = new System.Windows.Forms.TextBox();
			this.label_de1 = new System.Windows.Forms.Label();
			this.textBox_top1 = new System.Windows.Forms.TextBox();
			this.textBox_bottom = new System.Windows.Forms.TextBox();
			this.label_bottom = new System.Windows.Forms.Label();
			this.textBox_right = new System.Windows.Forms.TextBox();
			this.label_right = new System.Windows.Forms.Label();
			this.textBox_left = new System.Windows.Forms.TextBox();
			this.label1_left = new System.Windows.Forms.Label();
			this.textBox_top = new System.Windows.Forms.TextBox();
			this.label_top = new System.Windows.Forms.Label();
			this.button_browse = new System.Windows.Forms.Button();
			this.textBox_fileName = new System.Windows.Forms.TextBox();
			this.label_file = new System.Windows.Forms.Label();
			this.textBox_title = new System.Windows.Forms.TextBox();
			this.label_title = new System.Windows.Forms.Label();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
			this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
			this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
			this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
			this.dataGridTextBoxColumn5 = new System.Windows.Forms.DataGridTextBoxColumn();
			this.dataGridTextBoxColumn6 = new System.Windows.Forms.DataGridTextBoxColumn();
			this.dataGridTextBoxColumn7 = new System.Windows.Forms.DataGridTextBoxColumn();
			this.panel1 = new System.Windows.Forms.Panel();
			this.button_edit = new System.Windows.Forms.Button();
			this.button_delete = new System.Windows.Forms.Button();
			this.button_colse = new System.Windows.Forms.Button();
			this.button_insert = new System.Windows.Forms.Button();
			this.button_next = new System.Windows.Forms.Button();
			this.button_pre = new System.Windows.Forms.Button();
			this.button_cancel = new System.Windows.Forms.Button();
			this.button_ok = new System.Windows.Forms.Button();
			this.panel3 = new System.Windows.Forms.Panel();
			((System.ComponentModel.ISupportInitialize)(this.dtMapSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
			this.panel2.SuspendLayout();
			this.groupBox1.SuspendLayout();
			this.groupBox5.SuspendLayout();
			this.groupBox4.SuspendLayout();
			this.groupBox3.SuspendLayout();
			this.groupBox2.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.panel1.SuspendLayout();
			this.panel3.SuspendLayout();
			this.SuspendLayout();
			// 
			// dtMapSource
			// 
			this.dtMapSource.Columns.AddRange(new System.Data.DataColumn[] {
																			   this.dataColumn1,
																			   this.dataColumn3,
																			   this.dataColumn4,
																			   this.dataColumn5,
																			   this.dataColumn6,
																			   this.dataColumn7});
			this.dtMapSource.TableName = "dtMapSource";
			// 
			// dataColumn1
			// 
			this.dataColumn1.AllowDBNull = false;
			this.dataColumn1.ColumnName = "Title";
			// 
			// dataColumn3
			// 
			this.dataColumn3.ColumnName = "FileName";
			// 
			// dataColumn4
			// 
			this.dataColumn4.ColumnName = "TopLatitude";
			this.dataColumn4.DataType = typeof(System.Double);
			// 
			// dataColumn5
			// 
			this.dataColumn5.ColumnName = "LeftLongitude";
			this.dataColumn5.DataType = typeof(System.Double);
			// 
			// dataColumn6
			// 
			this.dataColumn6.ColumnName = "RightLongitude";
			this.dataColumn6.DataType = typeof(System.Double);
			// 
			// dataColumn7
			// 
			this.dataColumn7.ColumnName = "BottomLatitude";
			this.dataColumn7.DataType = typeof(System.Double);
			// 
			// dataSet1
			// 
			this.dataSet1.DataSetName = "NewDataSet";
			this.dataSet1.Locale = new System.Globalization.CultureInfo("en-US");
			this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {
																		  this.dtMapSource});
			// 
			// panel2
			// 
			this.panel2.Controls.Add(this.panel1);
			this.panel2.Controls.Add(this.groupBox1);
			this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel2.Location = new System.Drawing.Point(0, 245);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(832, 280);
			this.panel2.TabIndex = 3;
			// 
			// groupBox1
			// 
			this.groupBox1.Anchor = System.Windows.Forms.AnchorStyles.None;
			this.groupBox1.Controls.Add(this.groupBox2);
			this.groupBox1.Controls.Add(this.textBox_bottom);
			this.groupBox1.Controls.Add(this.label_bottom);
			this.groupBox1.Controls.Add(this.textBox_right);
			this.groupBox1.Controls.Add(this.label_right);
			this.groupBox1.Controls.Add(this.textBox_left);
			this.groupBox1.Controls.Add(this.label1_left);
			this.groupBox1.Controls.Add(this.textBox_top);
			this.groupBox1.Controls.Add(this.label_top);
			this.groupBox1.Controls.Add(this.button_browse);
			this.groupBox1.Controls.Add(this.textBox_fileName);
			this.groupBox1.Controls.Add(this.label_file);
			this.groupBox1.Controls.Add(this.textBox_title);
			this.groupBox1.Controls.Add(this.label_title);
			this.groupBox1.Controls.Add(this.groupBox5);
			this.groupBox1.Controls.Add(this.groupBox4);
			this.groupBox1.Controls.Add(this.groupBox3);
			this.groupBox1.Location = new System.Drawing.Point(24, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(776, 224);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Map Information";
			// 
			// groupBox5
			// 
			this.groupBox5.Controls.Add(this.radioButton6);
			this.groupBox5.Controls.Add(this.radioButton5);
			this.groupBox5.Controls.Add(this.textBox_right3);
			this.groupBox5.Controls.Add(this.label_sec3);
			this.groupBox5.Controls.Add(this.label_min3);
			this.groupBox5.Controls.Add(this.textBox_right2);
			this.groupBox5.Controls.Add(this.label_de3);
			this.groupBox5.Controls.Add(this.textBox_right1);
			this.groupBox5.Location = new System.Drawing.Point(400, 144);
			this.groupBox5.Name = "groupBox5";
			this.groupBox5.Size = new System.Drawing.Size(360, 40);
			this.groupBox5.TabIndex = 58;
			this.groupBox5.TabStop = false;
			// 
			// radioButton6
			// 
			this.radioButton6.Location = new System.Drawing.Point(312, 16);
			this.radioButton6.Name = "radioButton6";
			this.radioButton6.Size = new System.Drawing.Size(32, 16);
			this.radioButton6.TabIndex = 36;
			this.radioButton6.Text = "E";
			// 
			// radioButton5
			// 
			this.radioButton5.Checked = true;
			this.radioButton5.Location = new System.Drawing.Point(280, 16);
			this.radioButton5.Name = "radioButton5";
			this.radioButton5.Size = new System.Drawing.Size(32, 16);
			this.radioButton5.TabIndex = 35;
			this.radioButton5.TabStop = true;
			this.radioButton5.Text = "W";
			// 
			// textBox_right3
			// 
			this.textBox_right3.Location = new System.Drawing.Point(208, 16);
			this.textBox_right3.Name = "textBox_right3";
			this.textBox_right3.Size = new System.Drawing.Size(40, 20);
			this.textBox_right3.TabIndex = 34;
			this.textBox_right3.Text = "";
			// 
			// label_sec3
			// 
			this.label_sec3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label_sec3.Location = new System.Drawing.Point(248, 16);
			this.label_sec3.Name = "label_sec3";
			this.label_sec3.Size = new System.Drawing.Size(16, 16);
			this.label_sec3.TabIndex = 33;
			this.label_sec3.Text = "\"";
			// 
			// label_min3
			// 
			this.label_min3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label_min3.Location = new System.Drawing.Point(184, 16);
			this.label_min3.Name = "label_min3";
			this.label_min3.Size = new System.Drawing.Size(16, 16);
			this.label_min3.TabIndex = 32;
			this.label_min3.Text = "\'";
			// 
			// textBox_right2
			// 
			this.textBox_right2.Location = new System.Drawing.Point(144, 16);
			this.textBox_right2.Name = "textBox_right2";
			this.textBox_right2.Size = new System.Drawing.Size(32, 20);
			this.textBox_right2.TabIndex = 30;
			this.textBox_right2.Text = "";
			// 
			// label_de3
			// 
			this.label_de3.Location = new System.Drawing.Point(88, 16);
			this.label_de3.Name = "label_de3";
			this.label_de3.Size = new System.Drawing.Size(48, 16);
			this.label_de3.TabIndex = 29;
			this.label_de3.Text = "Degree";
			// 
			// textBox_right1
			// 
			this.textBox_right1.Location = new System.Drawing.Point(16, 16);
			this.textBox_right1.Name = "textBox_right1";
			this.textBox_right1.Size = new System.Drawing.Size(64, 20);
			this.textBox_right1.TabIndex = 27;
			this.textBox_right1.Text = "";
			// 
			// groupBox4
			// 
			this.groupBox4.Controls.Add(this.radioButton8);
			this.groupBox4.Controls.Add(this.radioButton7);
			this.groupBox4.Controls.Add(this.textBox_bottom3);
			this.groupBox4.Controls.Add(this.labelsec4);
			this.groupBox4.Controls.Add(this.label_min4);
			this.groupBox4.Controls.Add(this.textBox_bottom2);
			this.groupBox4.Controls.Add(this.label_de4);
			this.groupBox4.Controls.Add(this.textBox_bottom1);
			this.groupBox4.Location = new System.Drawing.Point(400, 176);
			this.groupBox4.Name = "groupBox4";
			this.groupBox4.Size = new System.Drawing.Size(360, 40);
			this.groupBox4.TabIndex = 57;
			this.groupBox4.TabStop = false;
			// 
			// radioButton8
			// 
			this.radioButton8.Location = new System.Drawing.Point(312, 16);
			this.radioButton8.Name = "radioButton8";
			this.radioButton8.Size = new System.Drawing.Size(32, 16);
			this.radioButton8.TabIndex = 36;
			this.radioButton8.Text = "S";
			// 
			// radioButton7
			// 
			this.radioButton7.Checked = true;
			this.radioButton7.Location = new System.Drawing.Point(280, 16);
			this.radioButton7.Name = "radioButton7";
			this.radioButton7.Size = new System.Drawing.Size(32, 16);
			this.radioButton7.TabIndex = 35;
			this.radioButton7.TabStop = true;
			this.radioButton7.Text = "N";
			// 
			// textBox_bottom3
			// 
			this.textBox_bottom3.Location = new System.Drawing.Point(208, 16);
			this.textBox_bottom3.Name = "textBox_bottom3";
			this.textBox_bottom3.Size = new System.Drawing.Size(40, 20);
			this.textBox_bottom3.TabIndex = 34;
			this.textBox_bottom3.Text = "";
			// 
			// labelsec4
			// 
			this.labelsec4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.labelsec4.Location = new System.Drawing.Point(248, 16);
			this.labelsec4.Name = "labelsec4";
			this.labelsec4.Size = new System.Drawing.Size(16, 16);
			this.labelsec4.TabIndex = 33;
			this.labelsec4.Text = "\"";
			// 
			// label_min4
			// 
			this.label_min4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label_min4.Location = new System.Drawing.Point(184, 16);
			this.label_min4.Name = "label_min4";
			this.label_min4.Size = new System.Drawing.Size(16, 16);
			this.label_min4.TabIndex = 32;
			this.label_min4.Text = "\'";
			// 
			// textBox_bottom2
			// 
			this.textBox_bottom2.Location = new System.Drawing.Point(144, 16);
			this.textBox_bottom2.Name = "textBox_bottom2";
			this.textBox_bottom2.Size = new System.Drawing.Size(32, 20);
			this.textBox_bottom2.TabIndex = 30;
			this.textBox_bottom2.Text = "";
			// 
			// label_de4
			// 
			this.label_de4.Location = new System.Drawing.Point(88, 16);
			this.label_de4.Name = "label_de4";
			this.label_de4.Size = new System.Drawing.Size(48, 16);
			this.label_de4.TabIndex = 29;
			this.label_de4.Text = "Degree";
			// 
			// textBox_bottom1
			// 
			this.textBox_bottom1.Location = new System.Drawing.Point(16, 16);
			this.textBox_bottom1.Name = "textBox_bottom1";
			this.textBox_bottom1.Size = new System.Drawing.Size(64, 20);
			this.textBox_bottom1.TabIndex = 27;
			this.textBox_bottom1.Text = "";
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this.radioButton4);
			this.groupBox3.Controls.Add(this.radioButton3);
			this.groupBox3.Controls.Add(this.textBox_left3);
			this.groupBox3.Controls.Add(this.label_sec2);
			this.groupBox3.Controls.Add(this.label_min2);
			this.groupBox3.Controls.Add(this.textBox_left2);
			this.groupBox3.Controls.Add(this.label_de2);
			this.groupBox3.Controls.Add(this.textBox_left1);
			this.groupBox3.Location = new System.Drawing.Point(400, 112);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(360, 40);
			this.groupBox3.TabIndex = 56;
			this.groupBox3.TabStop = false;
			// 
			// radioButton4
			// 
			this.radioButton4.Location = new System.Drawing.Point(312, 16);
			this.radioButton4.Name = "radioButton4";
			this.radioButton4.Size = new System.Drawing.Size(32, 16);
			this.radioButton4.TabIndex = 36;
			this.radioButton4.Text = "E";
			// 
			// radioButton3
			// 
			this.radioButton3.Checked = true;
			this.radioButton3.Location = new System.Drawing.Point(280, 16);
			this.radioButton3.Name = "radioButton3";
			this.radioButton3.Size = new System.Drawing.Size(32, 16);
			this.radioButton3.TabIndex = 35;
			this.radioButton3.TabStop = true;
			this.radioButton3.Text = "W";
			// 
			// textBox_left3
			// 
			this.textBox_left3.Location = new System.Drawing.Point(208, 16);
			this.textBox_left3.Name = "textBox_left3";
			this.textBox_left3.Size = new System.Drawing.Size(40, 20);
			this.textBox_left3.TabIndex = 34;
			this.textBox_left3.Text = "";
			// 
			// label_sec2
			// 
			this.label_sec2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label_sec2.Location = new System.Drawing.Point(248, 16);
			this.label_sec2.Name = "label_sec2";
			this.label_sec2.Size = new System.Drawing.Size(16, 16);
			this.label_sec2.TabIndex = 33;
			this.label_sec2.Text = "\"";
			// 
			// label_min2
			// 
			this.label_min2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label_min2.Location = new System.Drawing.Point(184, 16);
			this.label_min2.Name = "label_min2";
			this.label_min2.Size = new System.Drawing.Size(16, 16);
			this.label_min2.TabIndex = 32;
			this.label_min2.Text = "\'";
			// 
			// textBox_left2
			// 
			this.textBox_left2.Location = new System.Drawing.Point(144, 16);
			this.textBox_left2.Name = "textBox_left2";
			this.textBox_left2.Size = new System.Drawing.Size(32, 20);
			this.textBox_left2.TabIndex = 30;
			this.textBox_left2.Text = "";
			// 
			// label_de2
			// 
			this.label_de2.Location = new System.Drawing.Point(88, 16);
			this.label_de2.Name = "label_de2";
			this.label_de2.Size = new System.Drawing.Size(48, 16);
			this.label_de2.TabIndex = 29;
			this.label_de2.Text = "Degree";
			// 
			// textBox_left1
			// 
			this.textBox_left1.Location = new System.Drawing.Point(16, 16);
			this.textBox_left1.Name = "textBox_left1";
			this.textBox_left1.Size = new System.Drawing.Size(64, 20);
			this.textBox_left1.TabIndex = 27;
			this.textBox_left1.Text = "";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.radioButton2);
			this.groupBox2.Controls.Add(this.radioButton1);
			this.groupBox2.Controls.Add(this.textBox_top3);
			this.groupBox2.Controls.Add(this.label_sec1);
			this.groupBox2.Controls.Add(this.label_min1);
			this.groupBox2.Controls.Add(this.textBox_top2);
			this.groupBox2.Controls.Add(this.label_de1);
			this.groupBox2.Controls.Add(this.textBox_top1);
			this.groupBox2.Location = new System.Drawing.Point(400, 80);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(360, 40);
			this.groupBox2.TabIndex = 55;
			this.groupBox2.TabStop = false;
			// 
			// radioButton2
			// 
			this.radioButton2.Location = new System.Drawing.Point(312, 16);
			this.radioButton2.Name = "radioButton2";
			this.radioButton2.Size = new System.Drawing.Size(32, 16);
			this.radioButton2.TabIndex = 36;
			this.radioButton2.Text = "S";
			// 
			// radioButton1
			// 
			this.radioButton1.Checked = true;
			this.radioButton1.Location = new System.Drawing.Point(280, 16);
			this.radioButton1.Name = "radioButton1";
			this.radioButton1.Size = new System.Drawing.Size(32, 16);
			this.radioButton1.TabIndex = 35;
			this.radioButton1.TabStop = true;
			this.radioButton1.Text = "N";
			// 
			// textBox_top3
			// 
			this.textBox_top3.Location = new System.Drawing.Point(208, 16);
			this.textBox_top3.Name = "textBox_top3";
			this.textBox_top3.Size = new System.Drawing.Size(40, 20);
			this.textBox_top3.TabIndex = 34;
			this.textBox_top3.Text = "";
			// 
			// label_sec1
			// 
			this.label_sec1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label_sec1.Location = new System.Drawing.Point(248, 16);
			this.label_sec1.Name = "label_sec1";
			this.label_sec1.Size = new System.Drawing.Size(16, 16);
			this.label_sec1.TabIndex = 33;
			this.label_sec1.Text = "\"";
			// 
			// label_min1
			// 
			this.label_min1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label_min1.Location = new System.Drawing.Point(184, 16);
			this.label_min1.Name = "label_min1";
			this.label_min1.Size = new System.Drawing.Size(16, 16);
			this.label_min1.TabIndex = 32;
			this.label_min1.Text = "\'";
			// 
			// textBox_top2
			// 
			this.textBox_top2.Location = new System.Drawing.Point(144, 16);
			this.textBox_top2.Name = "textBox_top2";
			this.textBox_top2.Size = new System.Drawing.Size(32, 20);
			this.textBox_top2.TabIndex = 30;
			this.textBox_top2.Text = "";
			// 
			// label_de1
			// 
			this.label_de1.Location = new System.Drawing.Point(88, 16);
			this.label_de1.Name = "label_de1";
			this.label_de1.Size = new System.Drawing.Size(48, 16);
			this.label_de1.TabIndex = 29;
			this.label_de1.Text = "Degree";
			// 
			// textBox_top1
			// 
			this.textBox_top1.Location = new System.Drawing.Point(16, 16);
			this.textBox_top1.Name = "textBox_top1";
			this.textBox_top1.Size = new System.Drawing.Size(64, 20);
			this.textBox_top1.TabIndex = 27;
			this.textBox_top1.Text = "";
			// 
			// textBox_bottom
			// 
			this.textBox_bottom.Location = new System.Drawing.Point(152, 184);
			this.textBox_bottom.Name = "textBox_bottom";
			this.textBox_bottom.ReadOnly = true;
			this.textBox_bottom.Size = new System.Drawing.Size(232, 20);
			this.textBox_bottom.TabIndex = 46;
			this.textBox_bottom.Text = "";
			// 
			// label_bottom
			// 
			this.label_bottom.Location = new System.Drawing.Point(16, 184);
			this.label_bottom.Name = "label_bottom";
			this.label_bottom.Size = new System.Drawing.Size(136, 16);
			this.label_bottom.TabIndex = 45;
			this.label_bottom.Text = "Bottom Latitude:";
			// 
			// textBox_right
			// 
			this.textBox_right.Location = new System.Drawing.Point(152, 152);
			this.textBox_right.Name = "textBox_right";
			this.textBox_right.ReadOnly = true;
			this.textBox_right.Size = new System.Drawing.Size(232, 20);
			this.textBox_right.TabIndex = 36;
			this.textBox_right.Text = "";
			// 
			// label_right
			// 
			this.label_right.Location = new System.Drawing.Point(16, 152);
			this.label_right.Name = "label_right";
			this.label_right.Size = new System.Drawing.Size(144, 23);
			this.label_right.TabIndex = 35;
			this.label_right.Text = "Right Longitude:";
			// 
			// textBox_left
			// 
			this.textBox_left.Location = new System.Drawing.Point(152, 120);
			this.textBox_left.Name = "textBox_left";
			this.textBox_left.ReadOnly = true;
			this.textBox_left.Size = new System.Drawing.Size(232, 20);
			this.textBox_left.TabIndex = 25;
			this.textBox_left.Text = "";
			// 
			// label1_left
			// 
			this.label1_left.Location = new System.Drawing.Point(16, 120);
			this.label1_left.Name = "label1_left";
			this.label1_left.Size = new System.Drawing.Size(128, 23);
			this.label1_left.TabIndex = 24;
			this.label1_left.Text = "Left Lonitude:";
			// 
			// textBox_top
			// 
			this.textBox_top.Location = new System.Drawing.Point(152, 88);
			this.textBox_top.Name = "textBox_top";
			this.textBox_top.ReadOnly = true;
			this.textBox_top.Size = new System.Drawing.Size(232, 20);
			this.textBox_top.TabIndex = 8;
			this.textBox_top.Text = "";
			// 
			// label_top
			// 
			this.label_top.Location = new System.Drawing.Point(16, 88);
			this.label_top.Name = "label_top";
			this.label_top.Size = new System.Drawing.Size(128, 23);
			this.label_top.TabIndex = 7;
			this.label_top.Text = "Top Latitude:";
			// 
			// button_browse
			// 
			this.button_browse.Location = new System.Drawing.Point(672, 56);
			this.button_browse.Name = "button_browse";
			this.button_browse.Size = new System.Drawing.Size(80, 24);
			this.button_browse.TabIndex = 4;
			this.button_browse.Text = "Browse";
			this.button_browse.Click += new System.EventHandler(this.button_browse_Click);
			// 
			// textBox_fileName
			// 
			this.textBox_fileName.Location = new System.Drawing.Point(104, 56);
			this.textBox_fileName.Name = "textBox_fileName";
			this.textBox_fileName.Size = new System.Drawing.Size(560, 20);
			this.textBox_fileName.TabIndex = 3;
			this.textBox_fileName.Text = "";
			// 
			// label_file
			// 
			this.label_file.Location = new System.Drawing.Point(24, 56);
			this.label_file.Name = "label_file";
			this.label_file.Size = new System.Drawing.Size(56, 23);
			this.label_file.TabIndex = 2;
			this.label_file.Text = "FileName:";
			// 
			// textBox_title
			// 
			this.textBox_title.Location = new System.Drawing.Point(104, 24);
			this.textBox_title.Name = "textBox_title";
			this.textBox_title.Size = new System.Drawing.Size(648, 20);
			this.textBox_title.TabIndex = 1;
			this.textBox_title.Text = "";
			// 
			// label_title
			// 
			this.label_title.Location = new System.Drawing.Point(24, 24);
			this.label_title.Name = "label_title";
			this.label_title.Size = new System.Drawing.Size(32, 23);
			this.label_title.TabIndex = 0;
			this.label_title.Text = "Title:";
			// 
			// dataGrid1
			// 
			this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.DataSource = this.dtMapSource;
			this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(0, 0);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.Size = new System.Drawing.Size(832, 245);
			this.dataGrid1.TabIndex = 4;
			this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																								  this.dataGridTableStyle1});
			// 
			// dataGridTableStyle1
			// 
			this.dataGridTableStyle1.DataGrid = this.dataGrid1;
			this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
																												  this.dataGridTextBoxColumn1,
																												  this.dataGridTextBoxColumn3,
																												  this.dataGridTextBoxColumn4,
																												  this.dataGridTextBoxColumn5,
																												  this.dataGridTextBoxColumn6,
																												  this.dataGridTextBoxColumn7});
			this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridTableStyle1.MappingName = "dtMapSource";
			// 
			// dataGridTextBoxColumn1
			// 
			this.dataGridTextBoxColumn1.Format = "";
			this.dataGridTextBoxColumn1.FormatInfo = null;
			this.dataGridTextBoxColumn1.HeaderText = "Title";
			this.dataGridTextBoxColumn1.MappingName = "Title";
			this.dataGridTextBoxColumn1.Width = 150;
			// 
			// dataGridTextBoxColumn3
			// 
			this.dataGridTextBoxColumn3.Format = "";
			this.dataGridTextBoxColumn3.FormatInfo = null;
			this.dataGridTextBoxColumn3.HeaderText = "FileName";
			this.dataGridTextBoxColumn3.MappingName = "FileName";
			this.dataGridTextBoxColumn3.Width = 300;
			// 
			// dataGridTextBoxColumn4
			// 
			this.dataGridTextBoxColumn4.Format = "";
			this.dataGridTextBoxColumn4.FormatInfo = null;
			this.dataGridTextBoxColumn4.HeaderText = "Top Latitude";
			this.dataGridTextBoxColumn4.MappingName = "TopLatitude";
			this.dataGridTextBoxColumn4.Width = 75;
			// 
			// dataGridTextBoxColumn5
			// 
			this.dataGridTextBoxColumn5.Format = "";
			this.dataGridTextBoxColumn5.FormatInfo = null;
			this.dataGridTextBoxColumn5.HeaderText = "Left Longitude";
			this.dataGridTextBoxColumn5.MappingName = "LeftLongitude";
			this.dataGridTextBoxColumn5.Width = 80;
			// 
			// dataGridTextBoxColumn6
			// 
			this.dataGridTextBoxColumn6.Format = "";
			this.dataGridTextBoxColumn6.FormatInfo = null;
			this.dataGridTextBoxColumn6.HeaderText = "Right Latitude";
			this.dataGridTextBoxColumn6.MappingName = "RightLongitude";
			this.dataGridTextBoxColumn6.Width = 80;
			// 
			// dataGridTextBoxColumn7
			// 
			this.dataGridTextBoxColumn7.Format = "";
			this.dataGridTextBoxColumn7.FormatInfo = null;
			this.dataGridTextBoxColumn7.HeaderText = "Bottom Lonitude";
			this.dataGridTextBoxColumn7.MappingName = "BottomLatitude";
			this.dataGridTextBoxColumn7.Width = 90;
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.button_edit);
			this.panel1.Controls.Add(this.button_delete);
			this.panel1.Controls.Add(this.button_colse);
			this.panel1.Controls.Add(this.button_insert);
			this.panel1.Controls.Add(this.button_next);
			this.panel1.Controls.Add(this.button_pre);
			this.panel1.Controls.Add(this.button_cancel);
			this.panel1.Controls.Add(this.button_ok);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel1.Location = new System.Drawing.Point(0, 232);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(832, 48);
			this.panel1.TabIndex = 10;
			// 
			// button_edit
			// 
			this.button_edit.Location = new System.Drawing.Point(344, 16);
			this.button_edit.Name = "button_edit";
			this.button_edit.TabIndex = 16;
			this.button_edit.Text = "Edit";
			this.button_edit.Click += new System.EventHandler(this.button_edit_Click);
			// 
			// button_delete
			// 
			this.button_delete.Location = new System.Drawing.Point(264, 16);
			this.button_delete.Name = "button_delete";
			this.button_delete.TabIndex = 15;
			this.button_delete.Text = "Delete";
			this.button_delete.Click += new System.EventHandler(this.button_delete_Click);
			// 
			// button_colse
			// 
			this.button_colse.Location = new System.Drawing.Point(688, 16);
			this.button_colse.Name = "button_colse";
			this.button_colse.TabIndex = 14;
			this.button_colse.Text = "Colse";
			this.button_colse.Click += new System.EventHandler(this.button_colse_Click);
			// 
			// button_insert
			// 
			this.button_insert.Location = new System.Drawing.Point(184, 16);
			this.button_insert.Name = "button_insert";
			this.button_insert.TabIndex = 13;
			this.button_insert.Text = "Insert";
			this.button_insert.Click += new System.EventHandler(this.button_insert_Click);
			// 
			// button_next
			// 
			this.button_next.Location = new System.Drawing.Point(104, 16);
			this.button_next.Name = "button_next";
			this.button_next.TabIndex = 12;
			this.button_next.Text = "Next";
			this.button_next.Click += new System.EventHandler(this.button_next_Click);
			// 
			// button_pre
			// 
			this.button_pre.Location = new System.Drawing.Point(24, 16);
			this.button_pre.Name = "button_pre";
			this.button_pre.TabIndex = 11;
			this.button_pre.Text = "Previous";
			this.button_pre.Click += new System.EventHandler(this.button_pre_Click);
			// 
			// button_cancel
			// 
			this.button_cancel.Location = new System.Drawing.Point(536, 16);
			this.button_cancel.Name = "button_cancel";
			this.button_cancel.TabIndex = 10;
			this.button_cancel.Text = "Cancel";
			this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
			// 
			// button_ok
			// 
			this.button_ok.Location = new System.Drawing.Point(456, 16);
			this.button_ok.Name = "button_ok";
			this.button_ok.TabIndex = 9;
			this.button_ok.Text = "Ok";
			this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
			// 
			// panel3
			// 
			this.panel3.Controls.Add(this.dataGrid1);
			this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel3.Location = new System.Drawing.Point(0, 0);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(832, 245);
			this.panel3.TabIndex = 5;
			// 
			// MapSourceForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(832, 525);
			this.Controls.Add(this.panel3);
			this.Controls.Add(this.panel2);
			this.Name = "MapSourceForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "MapSourceForm";
			((System.ComponentModel.ISupportInitialize)(this.dtMapSource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
			this.panel2.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.groupBox5.ResumeLayout(false);
			this.groupBox4.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.panel1.ResumeLayout(false);
			this.panel3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

	
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);
			try 
			{
				this.dataSet1.ReadXml(WorkDir+"\\mapsource.xml", XmlReadMode.IgnoreSchema);
			}
			catch (Exception e1)
			{
				MessageBox.Show("No map source, create a new one"+e1.ToString());
			}
			// dynamically binding the data to the textBoxes
			textBox_title.DataBindings.Add("Text", dtMapSource, "Title");
			textBox_fileName.DataBindings.Add("Text", dtMapSource, "FileName");
			textBox_top.DataBindings.Add("Text", dtMapSource, "TopLatitude");
			textBox_left.DataBindings.Add("Text", dtMapSource, "LeftLongitude");
			textBox_right.DataBindings.Add("Text", dtMapSource, "RightLongitude");
			textBox_bottom.DataBindings.Add("Text", dtMapSource, "BottomLatitude");

			cmMapSource = (CurrencyManager)this.BindingContext[dtMapSource];
			cmMapSource.Position = 0;
			this.status = "start";
			isEnabled(false);
		}

		private void button_colse_Click(object sender, System.EventArgs e)
		{
			MapSourceForm_Closed();
			this.Close();
		}

		private void MapSourceForm_Closed()
		{
			try
			{
				this.dataSet1.WriteXml(WorkDir+"\\mapsource.xml", XmlWriteMode.IgnoreSchema);
			}
			catch (Exception e1)
			{
				MessageBox.Show(e1.ToString());
			}
			
		}

		private void button_pre_Click(object sender, System.EventArgs e)
		{
			if (cmMapSource.Position >0)
				cmMapSource.Position--;
		}

		private void button_next_Click(object sender, System.EventArgs e)
		{
			if (cmMapSource.Position <cmMapSource.Count-1)
				cmMapSource.Position++;
		}

		private void button_insert_Click(object sender, System.EventArgs e)
		{
			DataRow drMap = dtMapSource.NewRow();
			drMap["Title"] = " ";
			dtMapSource.Rows.Add(drMap);
			cmMapSource.Position = cmMapSource.Count-1;
			status ="insert";
			isEnabled(true);
		}

		private void button_delete_Click(object sender, System.EventArgs e)
		{
			status = "delete";
			isEnabled(true);
		}

		private void button_edit_Click(object sender, System.EventArgs e)
		{
			status = "edit";
			isEnabled(true);
		}

		private void button_ok_Click(object sender, System.EventArgs e)
		{
			if (status == "delete")
				dtMapSource.Rows.RemoveAt(cmMapSource.Position);
			isEnabled(false);
		}

		private void button_cancel_Click(object sender, System.EventArgs e)
		{
			if (status == "delete")
				dtMapSource.Rows.RemoveAt(cmMapSource.Position);
			isEnabled(false);
		}

		private void isEnabled(bool Enable)
		{
			double temp;

			this.button_insert.Visible = !Enable;
			this.button_delete.Visible = !Enable;
			this.button_edit.Visible = !Enable;
			this.button_pre.Visible = !Enable;
			this.button_pre.Visible = !Enable;
			this.button_next.Visible = !Enable;
			this.dataGrid1.Enabled = !Enable;
			
			this.button_ok.Visible = Enable;
			this.button_cancel.Visible = Enable;
			this.textBox_title.Enabled = Enable;
			this.textBox_fileName.Enabled = Enable;
		
			this.groupBox2.Enabled = Enable;
			this.groupBox3.Enabled = Enable;
			this.groupBox4.Enabled = Enable;
			this.groupBox5.Enabled = Enable;
			
			//convert latitude and longitude between double degree and degree, min ,second
			if (!Enable)
			{
				//input the top latitude by the degree, min and sec
				if (textBox_top1.Text!="" && textBox_top2.Text!="" &&textBox_top3.Text!="")
				{
					temp = Convert.ToDouble(textBox_top1.Text)+
						+Convert.ToDouble(textBox_top2.Text)/60.0+Convert.ToDouble(textBox_top3.Text)/3600.0;
					if (radioButton2.Checked) //S<0
						temp = -temp;

					dtMapSource.Rows[cmMapSource.Position]["TopLatitude"] = temp;
				}
				else if (status == "start" && cmMapSource.Position >= 0)
					(Object)dtMapSource.Rows[cmMapSource.Position]["TopLatitude"] = DBNull.Value;
				
				//input the left longitude by the degree, min and sec
				if (textBox_left1.Text !="" && textBox_left2.Text!="" &&textBox_left3.Text!="")
				{
					temp =Convert.ToDouble(textBox_left1.Text)+
						+Convert.ToDouble(textBox_left2.Text) /60.0+Convert.ToDouble(textBox_left3.Text)/3600.0;
					if (radioButton3.Checked) //W
					temp = 0 -temp;
					dtMapSource.Rows[cmMapSource.Position]["LeftLongitude"] = temp;
				}
				else if (status =="start" && cmMapSource.Position >= 0)
					(Object)dtMapSource.Rows[cmMapSource.Position]["LeftLongitude"] =DBNull.Value;
				
				//input the bottom latitude by the degree, min and sec
				if (textBox_bottom1.Text!="" && textBox_bottom2.Text!="" &&textBox_bottom3.Text!="")
				{
					temp = Convert.ToDouble(textBox_bottom1.Text)
						+Convert.ToDouble(textBox_bottom2.Text) /60.0+Convert.ToDouble(textBox_bottom3.Text)/3600.0;
					if (radioButton8.Checked) //S<0
						temp = -temp;
					dtMapSource.Rows[cmMapSource.Position]["BottomLatitude"] = temp;
				}
				else if (status =="start" && cmMapSource.Position >=0)
					(Object)dtMapSource.Rows[cmMapSource.Position]["BottomLatitude"] =DBNull.Value;
				
				//input the right longitude by the degree, min and sec
				if (textBox_right1.Text!="" && textBox_right2.Text!="" &&textBox_right3.Text!="")
				{
					temp = Convert.ToDouble(textBox_right1.Text)
						+Convert.ToDouble(textBox_right2.Text)/60.0+Convert.ToDouble(textBox_right3.Text)/3600.0;
					if (radioButton5.Checked) //W<0
						temp = -temp;
					dtMapSource.Rows[cmMapSource.Position]["RightLongitude"] = temp;
				}
				else if (status =="start" && cmMapSource.Position >=0)
					(Object)dtMapSource.Rows[cmMapSource.Position]["RightLongitude"] = DBNull.Value;
				
				textBox_top1.Text="";
				textBox_top2.Text="";
				textBox_top3.Text="";
				textBox_left1.Text="";
				textBox_left2.Text="";
				textBox_left3.Text="";
				textBox_right1.Text="";
				textBox_right2.Text="";
				textBox_right3.Text="";
				textBox_bottom1.Text="";
				textBox_bottom2.Text="";
				textBox_bottom3.Text="";
			}
			else
			{
				int degree, min,sec;
				//input the top latitude by the degree, min and sec
				if (textBox_top.Text!="")
				{
					temp = (double)dtMapSource.Rows[cmMapSource.Position]["TopLatitude"];
					radioButton1.Checked = (temp>0); //N>0 or S<0
					temp = Math.Abs(temp);
					degree = (int)(temp);
					textBox_top1.Text = Convert.ToString(degree);
					min = (int)((temp - (double)degree)/60.0);
					textBox_top2.Text = Convert.ToString(min);
					sec = (int)((temp- (double)degree-(double)(min*60))/3600);
					textBox_top3.Text = Convert.ToString(sec);
				}
				if (textBox_left.Text != "")
				{
					temp = (double)dtMapSource.Rows[cmMapSource.Position]["LeftLongitude"];
					radioButton3.Checked = (temp<0); //W<0 or E>0
					temp = Math.Abs(temp);
					degree = (int)(temp);
					textBox_left1.Text = Convert.ToString(degree);
					min = (int)( (temp - (double)degree)/60.0);
					textBox_left2.Text = Convert.ToString(min);
					sec = (int)((temp- (double)degree-(double)(min*60))/3600);
					textBox_left3.Text = Convert.ToString(sec);
				}
				if (textBox_right.Text != "")
				{
					 temp = (double)dtMapSource.Rows[cmMapSource.Position]["RightLongitude"];
					 radioButton5.Checked = (temp<0); //W<0 or E>0
					 temp = Math.Abs(temp);
					 degree = (int)(temp);
					 textBox_right1.Text = Convert.ToString(degree);
					 min = (int)( (temp - (double)degree)/60.0);
					 textBox_right2.Text = Convert.ToString(min);
					 sec = (int)((temp- (double)degree-(double)(min*60))/3600);
					 textBox_right3.Text = Convert.ToString(sec);
				}
				if (textBox_bottom.Text != "")
				{
					 temp = (double)dtMapSource.Rows[cmMapSource.Position]["BottomLatitude"];
					 radioButton7.Checked = (temp>0); //N>0 or S<0
					 temp = Math.Abs(temp);
					 degree = (int)(temp);
					 textBox_bottom1.Text = Convert.ToString(degree);
					 min = (int)( (temp - (double)degree)/60.0);
					 textBox_bottom2.Text = Convert.ToString(min);
					 sec = (int)((temp- (double)degree-(double)(min*60))/3600);
					 textBox_bottom3.Text = Convert.ToString(sec);
				}
			}

		}

		private void button_browse_Click(object sender, System.EventArgs e)
		{
			//open file dialog
			OpenFileDialog openFileDialog1 = new OpenFileDialog();
			openFileDialog1.Filter = "IMAGE files (*.map;*.bmp;*.jpg;*.gif;*.jpeg;*.jpe;)|*.map;*.bmp;*.jpg;*.jpeg;*.gif|All files (*.*)|*.*" ;
			openFileDialog1.FilterIndex = 1 ;
			openFileDialog1.InitialDirectory = WorkDir;
			openFileDialog1.RestoreDirectory = true;
			if(openFileDialog1.ShowDialog() != DialogResult.OK)
			{
				return;
			}
			textBox_fileName.Text= openFileDialog1.FileName;
		}
	}
}
