using System;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Text;
using System.IO;
using Spherical.HTM;
using Spherical;
namespace hcalc
{
	/// <summary>
	/// Summary description for Form2.
	/// </summary>
	public class RegionForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label hsTitleLabel;
		private TextBox coverSpec;
		private TextBox normalBox;
		private TextBox hidrangeBox;
		private Button heuristic;
		private Label statusLabel;
		private Button renderTracesButton;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private MenuStrip menuStrip1;
		private ToolStripMenuItem testStringsToolStripMenuItem;
		private ToolStripMenuItem cubeToolStripMenuItem;
		private ToolStripMenuItem otherCubeToolStripMenuItem;
		private ToolStripMenuItem hemisphereToolStripMenuItem;
		private ToolStripMenuItem coloradoToolStripMenuItem;
		private ToolStripMenuItem smallCircleToolStripMenuItem;
		private ToolStripMenuItem bowTieToolStripMenuItem;
		private ToolStripMenuItem twoSpheresToolStripMenuItem;
		private ToolStripMenuItem anotherRectangleToolStripMenuItem;
		private ToolStripMenuItem circle5400ToolStripMenuItem;
		private ToolStripMenuItem polygonToolStripMenuItem;
		private ToolStripMenuItem twToolStripMenuItem;
		private ToolStripMenuItem hugeToolStripMenuItem;
		private ToolStripMenuItem earthToolStripMenuItem;
		private ToolStripMenuItem circle377512251ToolStripMenuItem;
		private ToolStripMenuItem rect37701224237721224ToolStripMenuItem;
		private ToolStripMenuItem rect8024801241ToolStripMenuItem;
		private ToolStripMenuItem rect70247228ToolStripMenuItem;
		private ToolStripMenuItem rect70247227ToolStripMenuItem;
		private Button spectest;
		private ListBox deltaLevelBox;
		private Label timeLabel;
		private CheckBox traceCheckBox;
		private Button budgeted;
        private ToolStripMenuItem examplesToolStripMenuItem;
        private ToolStripMenuItem tinyDiskToolStripMenuItem;
        private ToolStripMenuItem coloradoPolyToolStripMenuItem;
        private ToolStripMenuItem coloradoRectToolStripMenuItem;
        private ToolStripMenuItem cubeToolStripMenuItem1;
        private ToolStripMenuItem tVFdocExamplesToolStripMenuItem;
        private ToolStripMenuItem californiaToolStripMenuItem;
        private ToolStripMenuItem baltimoreCircleToolStripMenuItem;
        private ToolStripMenuItem coloradoRectToolStripMenuItem1;
        private ToolStripMenuItem coloradoChullToolStripMenuItem;
        private ToolStripMenuItem utah2RectsToolStripMenuItem;
        private ToolStripMenuItem unionTwoRectsToolStripMenuItem;
        private ToolStripMenuItem maskToolStripMenuItem;
        private ToolStripMenuItem bandToolStripMenuItem;
        private ToolStripMenuItem talkToolStripMenuItem;
        private ToolStripMenuItem colRectToolStripMenuItem;
        private ToolStripMenuItem colDiagToolStripMenuItem;
        private ToolStripMenuItem randPolyToolStripMenuItem;
        private ToolStripMenuItem randDiagToolStripMenuItem;
        private ToolStripMenuItem randRectToolStripMenuItem;
        private CheckBox feqpcheckBox;
		private HtmCalcForm _parent;

		public RegionForm(HtmCalcForm parent)
		{
			//
			// Required for Windows Form Designer support
			//
			_parent = parent;
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			statusLabel.Text = "Ready";
			deltaLevelBox.Text = "0";
		}

		/// <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.hsTitleLabel = new System.Windows.Forms.Label();
            this.coverSpec = new System.Windows.Forms.TextBox();
            this.normalBox = new System.Windows.Forms.TextBox();
            this.hidrangeBox = new System.Windows.Forms.TextBox();
            this.heuristic = new System.Windows.Forms.Button();
            this.statusLabel = new System.Windows.Forms.Label();
            this.renderTracesButton = new System.Windows.Forms.Button();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.testStringsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.cubeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.otherCubeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.hemisphereToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.coloradoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.smallCircleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.bowTieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.twoSpheresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.anotherRectangleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.circle5400ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.polygonToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.twToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.hugeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.earthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.circle377512251ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.rect37701224237721224ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.rect8024801241ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.rect70247228ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.rect70247227ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.unionTwoRectsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.examplesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.tinyDiskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.coloradoPolyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.coloradoRectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.cubeToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.maskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.bandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.tVFdocExamplesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.californiaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.baltimoreCircleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.coloradoRectToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.coloradoChullToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.utah2RectsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.talkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.colRectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.colDiagToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.randPolyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.randDiagToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.randRectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.spectest = new System.Windows.Forms.Button();
            this.deltaLevelBox = new System.Windows.Forms.ListBox();
            this.timeLabel = new System.Windows.Forms.Label();
            this.traceCheckBox = new System.Windows.Forms.CheckBox();
            this.budgeted = new System.Windows.Forms.Button();
            this.feqpcheckBox = new System.Windows.Forms.CheckBox();
            this.menuStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // hsTitleLabel
            // 
            this.hsTitleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.hsTitleLabel.Location = new System.Drawing.Point(260, 24);
            this.hsTitleLabel.Name = "hsTitleLabel";
            this.hsTitleLabel.Size = new System.Drawing.Size(135, 23);
            this.hsTitleLabel.TabIndex = 0;
            this.hsTitleLabel.Text = "TESTREGION";
            // 
            // coverSpec
            // 
            this.coverSpec.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.coverSpec.Location = new System.Drawing.Point(-1, 51);
            this.coverSpec.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.coverSpec.Multiline = true;
            this.coverSpec.Name = "coverSpec";
            this.coverSpec.Size = new System.Drawing.Size(398, 160);
            this.coverSpec.TabIndex = 11;
            this.coverSpec.Text = "CIRCLE J2000 0 0 1";
            // 
            // normalBox
            // 
            this.normalBox.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.normalBox.Location = new System.Drawing.Point(0, 220);
            this.normalBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.normalBox.Multiline = true;
            this.normalBox.Name = "normalBox";
            this.normalBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.normalBox.Size = new System.Drawing.Size(395, 145);
            this.normalBox.TabIndex = 32;
            // 
            // hidrangeBox
            // 
            this.hidrangeBox.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.hidrangeBox.Location = new System.Drawing.Point(477, 13);
            this.hidrangeBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.hidrangeBox.Multiline = true;
            this.hidrangeBox.Name = "hidrangeBox";
            this.hidrangeBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.hidrangeBox.Size = new System.Drawing.Size(347, 350);
            this.hidrangeBox.TabIndex = 33;
            // 
            // heuristic
            // 
            this.heuristic.BackColor = System.Drawing.Color.Pink;
            this.heuristic.Location = new System.Drawing.Point(401, 235);
            this.heuristic.Name = "heuristic";
            this.heuristic.Size = new System.Drawing.Size(67, 23);
            this.heuristic.TabIndex = 34;
            this.heuristic.Text = "heuristic";
            this.heuristic.UseVisualStyleBackColor = false;
            this.heuristic.Click += new System.EventHandler(this.DoCover_Click);
            // 
            // statusLabel
            // 
            this.statusLabel.AutoSize = true;
            this.statusLabel.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.statusLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.statusLabel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.statusLabel.Location = new System.Drawing.Point(0, 373);
            this.statusLabel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.statusLabel.Name = "statusLabel";
            this.statusLabel.Size = new System.Drawing.Size(213, 15);
            this.statusLabel.TabIndex = 35;
            this.statusLabel.Text = "and now, for something completely different";
            // 
            // renderTracesButton
            // 
            this.renderTracesButton.BackColor = System.Drawing.Color.Chartreuse;
            this.renderTracesButton.Location = new System.Drawing.Point(401, 201);
            this.renderTracesButton.Name = "renderTracesButton";
            this.renderTracesButton.Size = new System.Drawing.Size(67, 28);
            this.renderTracesButton.TabIndex = 36;
            this.renderTracesButton.Text = "Render";
            this.renderTracesButton.UseVisualStyleBackColor = false;
            this.renderTracesButton.Click += new System.EventHandler(this.renderTracesButton_Click);
            // 
            // menuStrip1
            // 
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.testStringsToolStripMenuItem,
            this.earthToolStripMenuItem,
            this.examplesToolStripMenuItem,
            this.tVFdocExamplesToolStripMenuItem,
            this.talkToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(827, 24);
            this.menuStrip1.TabIndex = 37;
            this.menuStrip1.Text = "menuStrip1";
            // 
            // testStringsToolStripMenuItem
            // 
            this.testStringsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.cubeToolStripMenuItem,
            this.otherCubeToolStripMenuItem,
            this.hemisphereToolStripMenuItem,
            this.coloradoToolStripMenuItem,
            this.smallCircleToolStripMenuItem,
            this.bowTieToolStripMenuItem,
            this.twoSpheresToolStripMenuItem,
            this.anotherRectangleToolStripMenuItem,
            this.circle5400ToolStripMenuItem,
            this.polygonToolStripMenuItem,
            this.twToolStripMenuItem,
            this.hugeToolStripMenuItem});
            this.testStringsToolStripMenuItem.Name = "testStringsToolStripMenuItem";
            this.testStringsToolStripMenuItem.Size = new System.Drawing.Size(73, 20);
            this.testStringsToolStripMenuItem.Text = "TestStrings";
            this.testStringsToolStripMenuItem.Click += new System.EventHandler(this.testStringsToolStripMenuItem_Click);
            // 
            // cubeToolStripMenuItem
            // 
            this.cubeToolStripMenuItem.Name = "cubeToolStripMenuItem";
            this.cubeToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.cubeToolStripMenuItem.Text = "Cube";
            this.cubeToolStripMenuItem.Click += new System.EventHandler(this.cubeToolStripMenuItem_Click);
            // 
            // otherCubeToolStripMenuItem
            // 
            this.otherCubeToolStripMenuItem.Name = "otherCubeToolStripMenuItem";
            this.otherCubeToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.otherCubeToolStripMenuItem.Text = "Other Cube";
            this.otherCubeToolStripMenuItem.Click += new System.EventHandler(this.otherCubeToolStripMenuItem_Click);
            // 
            // hemisphereToolStripMenuItem
            // 
            this.hemisphereToolStripMenuItem.Name = "hemisphereToolStripMenuItem";
            this.hemisphereToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.hemisphereToolStripMenuItem.Text = "Hemisphere";
            this.hemisphereToolStripMenuItem.Click += new System.EventHandler(this.hemisphereToolStripMenuItem_Click);
            // 
            // coloradoToolStripMenuItem
            // 
            this.coloradoToolStripMenuItem.Name = "coloradoToolStripMenuItem";
            this.coloradoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.coloradoToolStripMenuItem.Text = "Colorado";
            this.coloradoToolStripMenuItem.Click += new System.EventHandler(this.coloradoToolStripMenuItem_Click);
            // 
            // smallCircleToolStripMenuItem
            // 
            this.smallCircleToolStripMenuItem.Name = "smallCircleToolStripMenuItem";
            this.smallCircleToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.smallCircleToolStripMenuItem.Text = "Small Circle";
            this.smallCircleToolStripMenuItem.Click += new System.EventHandler(this.smallCircleToolStripMenuItem_Click);
            // 
            // bowTieToolStripMenuItem
            // 
            this.bowTieToolStripMenuItem.Name = "bowTieToolStripMenuItem";
            this.bowTieToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.bowTieToolStripMenuItem.Text = "Bow Tie";
            this.bowTieToolStripMenuItem.Click += new System.EventHandler(this.bowTieToolStripMenuItem_Click);
            // 
            // twoSpheresToolStripMenuItem
            // 
            this.twoSpheresToolStripMenuItem.Name = "twoSpheresToolStripMenuItem";
            this.twoSpheresToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.twoSpheresToolStripMenuItem.Text = "Two Spheres";
            this.twoSpheresToolStripMenuItem.Click += new System.EventHandler(this.twoSpheresToolStripMenuItem_Click);
            // 
            // anotherRectangleToolStripMenuItem
            // 
            this.anotherRectangleToolStripMenuItem.Name = "anotherRectangleToolStripMenuItem";
            this.anotherRectangleToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.anotherRectangleToolStripMenuItem.Text = "Another Rectangle";
            this.anotherRectangleToolStripMenuItem.Click += new System.EventHandler(this.anotherRectangleToolStripMenuItem_Click);
            // 
            // circle5400ToolStripMenuItem
            // 
            this.circle5400ToolStripMenuItem.Name = "circle5400ToolStripMenuItem";
            this.circle5400ToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.circle5400ToolStripMenuItem.Text = "circle5400";
            this.circle5400ToolStripMenuItem.Click += new System.EventHandler(this.circle5400ToolStripMenuItem_Click);
            // 
            // polygonToolStripMenuItem
            // 
            this.polygonToolStripMenuItem.Name = "polygonToolStripMenuItem";
            this.polygonToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.polygonToolStripMenuItem.Text = "Polygon";
            this.polygonToolStripMenuItem.Click += new System.EventHandler(this.polygonToolStripMenuItem_Click);
            // 
            // twToolStripMenuItem
            // 
            this.twToolStripMenuItem.Name = "twToolStripMenuItem";
            this.twToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.twToolStripMenuItem.Text = "Two circles";
            this.twToolStripMenuItem.Click += new System.EventHandler(this.twToolStripMenuItem_Click);
            // 
            // hugeToolStripMenuItem
            // 
            this.hugeToolStripMenuItem.Name = "hugeToolStripMenuItem";
            this.hugeToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
            this.hugeToolStripMenuItem.Text = "huge";
            this.hugeToolStripMenuItem.Click += new System.EventHandler(this.hugeToolStripMenuItem_Click);
            // 
            // earthToolStripMenuItem
            // 
            this.earthToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.circle377512251ToolStripMenuItem,
            this.rect37701224237721224ToolStripMenuItem,
            this.rect8024801241ToolStripMenuItem,
            this.rect70247228ToolStripMenuItem,
            this.rect70247227ToolStripMenuItem,
            this.unionTwoRectsToolStripMenuItem});
            this.earthToolStripMenuItem.Name = "earthToolStripMenuItem";
            this.earthToolStripMenuItem.Size = new System.Drawing.Size(45, 20);
            this.earthToolStripMenuItem.Text = "Earth";
            // 
            // circle377512251ToolStripMenuItem
            // 
            this.circle377512251ToolStripMenuItem.Name = "circle377512251ToolStripMenuItem";
            this.circle377512251ToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
            this.circle377512251ToolStripMenuItem.Text = "circle 37.75 -122.5 1";
            this.circle377512251ToolStripMenuItem.Click += new System.EventHandler(this.circle377512251ToolStripMenuItem_Click);
            // 
            // rect37701224237721224ToolStripMenuItem
            // 
            this.rect37701224237721224ToolStripMenuItem.Name = "rect37701224237721224ToolStripMenuItem";
            this.rect37701224237721224ToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
            this.rect37701224237721224ToolStripMenuItem.Text = "rect 37.70 -122.42 37.72 -122.40";
            this.rect37701224237721224ToolStripMenuItem.Click += new System.EventHandler(this.rect37701224237721224ToolStripMenuItem_Click);
            // 
            // rect8024801241ToolStripMenuItem
            // 
            this.rect8024801241ToolStripMenuItem.Name = "rect8024801241ToolStripMenuItem";
            this.rect8024801241ToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
            this.rect8024801241ToolStripMenuItem.Text = "rect 80 24 80.1 24.1";
            this.rect8024801241ToolStripMenuItem.Click += new System.EventHandler(this.rect8024801241ToolStripMenuItem_Click);
            // 
            // rect70247228ToolStripMenuItem
            // 
            this.rect70247228ToolStripMenuItem.Name = "rect70247228ToolStripMenuItem";
            this.rect70247228ToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
            this.rect70247228ToolStripMenuItem.Text = "rect 70 24 72 28";
            this.rect70247228ToolStripMenuItem.Click += new System.EventHandler(this.rect70247228ToolStripMenuItem_Click);
            // 
            // rect70247227ToolStripMenuItem
            // 
            this.rect70247227ToolStripMenuItem.Name = "rect70247227ToolStripMenuItem";
            this.rect70247227ToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
            this.rect70247227ToolStripMenuItem.Text = "rect 70 24 72 27";
            this.rect70247227ToolStripMenuItem.Click += new System.EventHandler(this.rect70247227ToolStripMenuItem_Click);
            // 
            // unionTwoRectsToolStripMenuItem
            // 
            this.unionTwoRectsToolStripMenuItem.Name = "unionTwoRectsToolStripMenuItem";
            this.unionTwoRectsToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
            this.unionTwoRectsToolStripMenuItem.Text = "union two rects";
            this.unionTwoRectsToolStripMenuItem.Click += new System.EventHandler(this.unionTwoRectsToolStripMenuItem_Click);
            // 
            // examplesToolStripMenuItem
            // 
            this.examplesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.tinyDiskToolStripMenuItem,
            this.coloradoPolyToolStripMenuItem,
            this.coloradoRectToolStripMenuItem,
            this.cubeToolStripMenuItem1,
            this.maskToolStripMenuItem,
            this.bandToolStripMenuItem});
            this.examplesToolStripMenuItem.Name = "examplesToolStripMenuItem";
            this.examplesToolStripMenuItem.Size = new System.Drawing.Size(64, 20);
            this.examplesToolStripMenuItem.Text = "Examples";
            // 
            // tinyDiskToolStripMenuItem
            // 
            this.tinyDiskToolStripMenuItem.Name = "tinyDiskToolStripMenuItem";
            this.tinyDiskToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
            this.tinyDiskToolStripMenuItem.Text = "TinyDisk";
            this.tinyDiskToolStripMenuItem.Click += new System.EventHandler(this.tinyDiskToolStripMenuItem_Click);
            // 
            // coloradoPolyToolStripMenuItem
            // 
            this.coloradoPolyToolStripMenuItem.Name = "coloradoPolyToolStripMenuItem";
            this.coloradoPolyToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
            this.coloradoPolyToolStripMenuItem.Text = "Colorado Poly";
            this.coloradoPolyToolStripMenuItem.Click += new System.EventHandler(this.coloradoPolyToolStripMenuItem_Click);
            // 
            // coloradoRectToolStripMenuItem
            // 
            this.coloradoRectToolStripMenuItem.Name = "coloradoRectToolStripMenuItem";
            this.coloradoRectToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
            this.coloradoRectToolStripMenuItem.Text = "Colorado Rect";
            this.coloradoRectToolStripMenuItem.Click += new System.EventHandler(this.coloradoRectToolStripMenuItem_Click);
            // 
            // cubeToolStripMenuItem1
            // 
            this.cubeToolStripMenuItem1.Name = "cubeToolStripMenuItem1";
            this.cubeToolStripMenuItem1.Size = new System.Drawing.Size(142, 22);
            this.cubeToolStripMenuItem1.Text = "Cube";
            this.cubeToolStripMenuItem1.Click += new System.EventHandler(this.cubeToolStripMenuItem1_Click);
            // 
            // maskToolStripMenuItem
            // 
            this.maskToolStripMenuItem.Name = "maskToolStripMenuItem";
            this.maskToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
            this.maskToolStripMenuItem.Text = "Mask";
            this.maskToolStripMenuItem.Click += new System.EventHandler(this.maskToolStripMenuItem_Click);
            // 
            // bandToolStripMenuItem
            // 
            this.bandToolStripMenuItem.Name = "bandToolStripMenuItem";
            this.bandToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
            this.bandToolStripMenuItem.Text = "Band";
            this.bandToolStripMenuItem.Click += new System.EventHandler(this.bandToolStripMenuItem_Click);
            // 
            // tVFdocExamplesToolStripMenuItem
            // 
            this.tVFdocExamplesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.californiaToolStripMenuItem,
            this.baltimoreCircleToolStripMenuItem,
            this.coloradoRectToolStripMenuItem1,
            this.coloradoChullToolStripMenuItem,
            this.utah2RectsToolStripMenuItem});
            this.tVFdocExamplesToolStripMenuItem.Name = "tVFdocExamplesToolStripMenuItem";
            this.tVFdocExamplesToolStripMenuItem.Size = new System.Drawing.Size(106, 20);
            this.tVFdocExamplesToolStripMenuItem.Text = "TVF.doc Examples";
            // 
            // californiaToolStripMenuItem
            // 
            this.californiaToolStripMenuItem.Name = "californiaToolStripMenuItem";
            this.californiaToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
            this.californiaToolStripMenuItem.Text = "California";
            this.californiaToolStripMenuItem.Click += new System.EventHandler(this.californiaToolStripMenuItem_Click);
            // 
            // baltimoreCircleToolStripMenuItem
            // 
            this.baltimoreCircleToolStripMenuItem.Name = "baltimoreCircleToolStripMenuItem";
            this.baltimoreCircleToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
            this.baltimoreCircleToolStripMenuItem.Text = "Baltimore Circle";
            this.baltimoreCircleToolStripMenuItem.Click += new System.EventHandler(this.baltimoreCircleToolStripMenuItem_Click);
            // 
            // coloradoRectToolStripMenuItem1
            // 
            this.coloradoRectToolStripMenuItem1.Name = "coloradoRectToolStripMenuItem1";
            this.coloradoRectToolStripMenuItem1.Size = new System.Drawing.Size(147, 22);
            this.coloradoRectToolStripMenuItem1.Text = "Colorado Rect";
            this.coloradoRectToolStripMenuItem1.Click += new System.EventHandler(this.coloradoRectToolStripMenuItem1_Click);
            // 
            // coloradoChullToolStripMenuItem
            // 
            this.coloradoChullToolStripMenuItem.Name = "coloradoChullToolStripMenuItem";
            this.coloradoChullToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
            this.coloradoChullToolStripMenuItem.Text = "Colorado Chull";
            this.coloradoChullToolStripMenuItem.Click += new System.EventHandler(this.coloradoChullToolStripMenuItem_Click);
            // 
            // utah2RectsToolStripMenuItem
            // 
            this.utah2RectsToolStripMenuItem.Name = "utah2RectsToolStripMenuItem";
            this.utah2RectsToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
            this.utah2RectsToolStripMenuItem.Text = "Utah (2 rects)";
            this.utah2RectsToolStripMenuItem.Click += new System.EventHandler(this.utah2RectsToolStripMenuItem_Click);
            // 
            // talkToolStripMenuItem
            // 
            this.talkToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.colRectToolStripMenuItem,
            this.colDiagToolStripMenuItem,
            this.randPolyToolStripMenuItem,
            this.randDiagToolStripMenuItem,
            this.randRectToolStripMenuItem});
            this.talkToolStripMenuItem.Name = "talkToolStripMenuItem";
            this.talkToolStripMenuItem.Size = new System.Drawing.Size(38, 20);
            this.talkToolStripMenuItem.Text = "Talk";
            // 
            // colRectToolStripMenuItem
            // 
            this.colRectToolStripMenuItem.Name = "colRectToolStripMenuItem";
            this.colRectToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
            this.colRectToolStripMenuItem.Text = "Col Poly";
            this.colRectToolStripMenuItem.Click += new System.EventHandler(this.colRectToolStripMenuItem_Click);
            // 
            // colDiagToolStripMenuItem
            // 
            this.colDiagToolStripMenuItem.Name = "colDiagToolStripMenuItem";
            this.colDiagToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
            this.colDiagToolStripMenuItem.Text = "Col Diag";
            this.colDiagToolStripMenuItem.Click += new System.EventHandler(this.colDiagToolStripMenuItem_Click);
            // 
            // randPolyToolStripMenuItem
            // 
            this.randPolyToolStripMenuItem.Name = "randPolyToolStripMenuItem";
            this.randPolyToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
            this.randPolyToolStripMenuItem.Text = "Rand Poly";
            this.randPolyToolStripMenuItem.Click += new System.EventHandler(this.randPolyToolStripMenuItem_Click);
            // 
            // randDiagToolStripMenuItem
            // 
            this.randDiagToolStripMenuItem.Name = "randDiagToolStripMenuItem";
            this.randDiagToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
            this.randDiagToolStripMenuItem.Text = "Rand Diag";
            this.randDiagToolStripMenuItem.Click += new System.EventHandler(this.randDiagToolStripMenuItem_Click);
            // 
            // randRectToolStripMenuItem
            // 
            this.randRectToolStripMenuItem.Name = "randRectToolStripMenuItem";
            this.randRectToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
            this.randRectToolStripMenuItem.Text = "Rand Rect";
            this.randRectToolStripMenuItem.Click += new System.EventHandler(this.randRectToolStripMenuItem_Click);
            // 
            // spectest
            // 
            this.spectest.Location = new System.Drawing.Point(761, 378);
            this.spectest.Name = "spectest";
            this.spectest.Size = new System.Drawing.Size(54, 23);
            this.spectest.TabIndex = 42;
            this.spectest.Text = "spectest";
            this.spectest.Click += new System.EventHandler(this.spectest_Click);
            // 
            // deltaLevelBox
            // 
            this.deltaLevelBox.FormattingEnabled = true;
            this.deltaLevelBox.Items.AddRange(new object[] {
            "-3",
            "-2",
            "-1",
            "0",
            "1",
            "2",
            "3"});
            this.deltaLevelBox.Location = new System.Drawing.Point(401, 264);
            this.deltaLevelBox.Name = "deltaLevelBox";
            this.deltaLevelBox.Size = new System.Drawing.Size(64, 43);
            this.deltaLevelBox.TabIndex = 44;
            this.deltaLevelBox.SelectedIndexChanged += new System.EventHandler(this.deltaLevelChanged);
            // 
            // timeLabel
            // 
            this.timeLabel.AutoSize = true;
            this.timeLabel.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.timeLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.timeLabel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.timeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.timeLabel.Location = new System.Drawing.Point(0, 407);
            this.timeLabel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
            this.timeLabel.Name = "timeLabel";
            this.timeLabel.Size = new System.Drawing.Size(21, 22);
            this.timeLabel.TabIndex = 47;
            this.timeLabel.Text = "0";
            // 
            // traceCheckBox
            // 
            this.traceCheckBox.AutoSize = true;
            this.traceCheckBox.Location = new System.Drawing.Point(404, 327);
            this.traceCheckBox.Name = "traceCheckBox";
            this.traceCheckBox.Size = new System.Drawing.Size(50, 17);
            this.traceCheckBox.TabIndex = 48;
            this.traceCheckBox.Text = "trace";
            this.traceCheckBox.CheckedChanged += new System.EventHandler(this.traceCheckBox_CheckedChanged);
            // 
            // budgeted
            // 
            this.budgeted.BackColor = System.Drawing.Color.SteelBlue;
            this.budgeted.Location = new System.Drawing.Point(401, 172);
            this.budgeted.Name = "budgeted";
            this.budgeted.Size = new System.Drawing.Size(67, 23);
            this.budgeted.TabIndex = 49;
            this.budgeted.Text = "Budgeted";
            this.budgeted.UseVisualStyleBackColor = false;
            this.budgeted.Click += new System.EventHandler(this.DoCover_Click);
            // 
            // feqpcheckBox
            // 
            this.feqpcheckBox.AutoSize = true;
            this.feqpcheckBox.Location = new System.Drawing.Point(404, 346);
            this.feqpcheckBox.Name = "feqpcheckBox";
            this.feqpcheckBox.Size = new System.Drawing.Size(73, 17);
            this.feqpcheckBox.TabIndex = 50;
            this.feqpcheckBox.Text = "full=partial";
            this.feqpcheckBox.CheckedChanged += new System.EventHandler(this.feqpcheckBox_CheckedChanged);
            // 
            // RegionForm
            // 
            this.ClientSize = new System.Drawing.Size(827, 432);
            this.Controls.Add(this.feqpcheckBox);
            this.Controls.Add(this.budgeted);
            this.Controls.Add(this.traceCheckBox);
            this.Controls.Add(this.timeLabel);
            this.Controls.Add(this.deltaLevelBox);
            this.Controls.Add(this.spectest);
            this.Controls.Add(this.renderTracesButton);
            this.Controls.Add(this.statusLabel);
            this.Controls.Add(this.heuristic);
            this.Controls.Add(this.hidrangeBox);
            this.Controls.Add(this.normalBox);
            this.Controls.Add(this.coverSpec);
            this.Controls.Add(this.hsTitleLabel);
            this.Controls.Add(this.menuStrip1);
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "RegionForm";
            this.Text = "Region Form";
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void textBoxY_TextChanged(object sender, System.EventArgs e) {
		}
		// //////////////////////////////// TIMING SUPPORT
		//
		private long _start;
		private long _nticks;

		long ms {
			get {
				return _nticks / TimeSpan.TicksPerMillisecond;
			}
		}
		System.TimeSpan now {
			get {
				return DateTime.Now.TimeOfDay;
			}
		}
		public void start() {
			_start = DateTime.Now.Ticks;
		}

		public long stop() {
			_nticks = DateTime.Now.Ticks - _start;
			return ms;
		}

		private void limitCover_Click(object sender, EventArgs e) {
			DoCover_Click(heuristic, e);
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void DoCover_Click(object sender, EventArgs e) {

			List<Int64Pair> cover = null;
            List<Int64AugPair> coverA = null;
            String s = this.coverSpec.Text;
			StringBuilder sb = new StringBuilder();
			//
			String dir;
            bool feqp = feqpcheckBox.Checked;
			if (traceCheckBox.Checked){
				dir = "C:\\htmtmp\\mhg\\";
				sb.Append("X ");
			} else {
				dir = null;
				sb.Append(". ");
			}
			sb.Append("[");
			Spherical.Region reg = null;
			try {
                reg = Parser.compile(s);
				if (reg != null) {
					reg.Simplify(true, Const.Tolerance, Const.MaximumIteration, false);
					if (reg != null) {
						start();
						if (sender == heuristic) {
							cover = HeuristicCover.HidRange(reg, false, dir, true);
						} else {
                            if(feqp) {
                                cover = Cover.HidRange(reg, false, dir);
                            } else {
                                coverA = Cover.HidAugRange(reg, false, dir);
                            }
                            //List<Int64Pair> hidlist = Cover.HidList(reg);
                            //int k = hidlist.Count;
						}
						stop();
						// -------------------------------------
                        if(feqp) {
                            if(cover == null) {
                                sb.Append("Null table(f=p)");
                            } else {
                                sb.AppendFormat("{0} rows(f=p)", cover.Count);
                            }
                        } else {
                            if(coverA == null) {
                                sb.Append("Null table(f, p)");
                            } else {
                                sb.AppendFormat("{0} rows(f, p)", coverA.Count);
                            }
                        }
					}
				} else {
					sb.AppendFormat("Parser returned null");
				}
			} catch (ApplicationException ex) {
				sb.Append(ex.Message);
			}
			StringBuilder output = new StringBuilder();

            if(feqp) {
                if(cover == null) {
                    output.AppendLine("Parse error");
                } else {
                    for(int i = 0; i < cover.Count; i++) {
                        output.AppendFormat("{{{0}, {1}}},", cover[i].lo, cover[i].hi); //table[i, 0], table[i, 1], i);
                        output.AppendLine();
                    }
                    if(cover.Count >= 2) {
                        for(int i = 1; i < cover.Count; i++) {
                            if(cover[i].lo <= cover[i - 1].hi) {
                                output.AppendFormat("Out of whack at line {0}", i);
                                output.AppendLine();
                            }
                        }
                    }
                }
            } else {
                if(coverA == null) {
                    output.AppendLine("(coverA = null)");
                } else {
                    for(int i = 0; i < coverA.Count; i++) {
                        output.AppendFormat("{{{0}, {1}, {2}}},",
                            coverA[i].lo, coverA[i].hi, coverA[i].full); //table[i, 0], table[i, 1], i);
                        output.AppendLine();
                    }
                    output.AppendFormat("// ----- {0}", coverA.Count);
                }
            }
			this.hidrangeBox.Text = output.ToString();
			/* Also convert to normal form as a separate step */
			{
				if (reg != null) {
					this.normalBox.Text = reg.ToString();
				} else {
					this.normalBox.Text = "N/A (parse error)";
				}
			}
				sb.AppendFormat(" ({0}, {1})",
					HtmState.Instance.minlevel, HtmState.Instance.maxlevel);

			sb.Append(" > ");
			this.statusLabel.Text = sb.ToString();

			timeLabel.Text = "T = " + ms.ToString();
			return;
		}

		private void renderTracesButton_Click(object sender, EventArgs e) {
			_parent.renderTraces();
			return;
		}

		private void testStringsToolStripMenuItem_Click(object sender, EventArgs e) {

		}

		private void cubeToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "CONVEX CARTESIAN 1 0 0 -0.6 -1 0 0 -0.6 0 1 0 -0.6 0 -1 0 -0.6 0 0 1 -0.6 0 0 -1 -0.6";
		}
		private void otherCubeToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "REGION CONVEX 1 0 0 -0.6 0 1 0 -0.6 0 0 1 -0.6 -1 0 0 -0.6 0 -1 0 -0.6 0 0 -1 -0.6";
		}

		private void hemisphereToolStripMenuItem_Click(object sender, EventArgs e)
		{
			coverSpec.Text = "REGION CONVEX 1 0 0 0";
		}

		private void coloradoToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "POLY J2000 -109.55 41 -102.05 41 -102.05 37 -109.55 37";
		}

		private void smallCircleToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "CIRCLE J2000 0 0 1";
		}

		private void bowTieToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "POLY J2000 0 0 10 0 10 10 0 10";
		}

		private void twoSpheresToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "REGION CONVEX J2000 -2 -2 0.99 CONVEX J2000 2 2 0.99";
		}

		private void anotherRectangleToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "RECT LATLON 37 -109.55  41 -102.05";
		}

		private void circle5400ToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "CIRCLE LATLON 90 0 5400";
		}

		private void polygonToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "POLY J2000 -110.9 22.25 -110.9 22.16 -110.9 22.16 -110.9 22.26";
		}

		private void twToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "REGION CONVEX CARTESIAN 0.7 0.7 0.0 -0.5 CIRCLE LATLON 18.2 -22.4 1.75";
		}

		private void hugeToolStripMenuItem_Click(object sender, EventArgs e) {
			 string _huge =
			"REGION CONVEX -0.881150929483595 0.415599238919748 0.225500137648566 0.0 -0.825241436426598 -0.530956793121933 0.192513520154396 0.0 -0.720936435555879 -0.496990252536204 0.482961017859604 0.0 -0.677266583529301 -0.47357726607384 0.563058210039224 0.0 -0.629374109289041 0.364252258472936 0.686446299978368 0.0 -0.626036401048059 0.363111618634144 0.690093020523818 0.0 -0.595856041789324 0.351327227261486 0.722166709872392 0.0 -0.588518239196856 0.348073780787551 0.729719758031049 0.0 -0.560683496133802 0.330641343304175 0.75915105167627 0.0 -0.278764214859803 -0.024388742157962 -0.960049843377702 0.0 -0.269236856169135 -0.041803167885281 -0.962166311213875 0.0 -0.070037634576833 -0.036261927497126 0.996885049720917 0.0 -0.065154312478521 -0.00570024437571 0.997858919276422 0.0 CONVEX -0.959273660712745 -0.009258653546979 -0.282326621481691 0.0 -0.928461326502651 -0.081229804864764 -0.362437972611273 0.0 -0.866726553807027 -0.466339909386636 0.176952450785679 0.0 -0.850243198094996 -0.481210595444418 0.213360884243625 0.0 -0.845410827465618 -0.484963439294755 0.223810177050333 0.0 -0.843458680223901 0.341829892970731 0.41440291869939 0.0 -0.833957013670511 -0.492276671032139 0.249357932513243 0.0 -0.828464545507591 0.350013574765445 0.437192170923514 0.0 -0.81173825085311 -0.50343157997282 0.296036579476261 0.0 -0.811251424860658 -0.503612729041515 0.297061180245601 0.0 -0.785026926738576 0.367559929099093 0.498630547415676 0.0 -0.774801389812406 0.370831569653351 0.51202221953075 0.0 -0.760763476410455 0.374225847462206 0.530277236972391 0.0 -0.74297810484902 0.37761718337453 0.552619940406828 0.0 -0.723230823402448 0.379832884035423 0.576770453721366 0.0 -0.609823002330275 -0.519883272139416 0.598195026039588 0.0 0.623541600072826 0.05455280237566 0.779884520125629 0.0 0.630321493761075 0.035702110287718 0.775512845685879 0.0 CONVEX -0.990273712181729 -0.086637317720906 -0.10886666220632 0.0 -0.259904965405581 0.784612473116762 0.562878917696446 0.0 -0.172271772106903 0.796503115687271 0.579573311355533 0.0 0.130816469095087 -0.913565745125667 -0.385077499662703 0.0 0.365167703184136 -0.86753724097416 -0.337685777127443 0.0 0.977053120215328 0.085481003593399 0.195090231180746 0.0 CONVEX -0.231003979692708 -0.025181748142039 0.972626876518761 0.0 0.284465423595963 0.019916052128678 -0.958479407001516 0.0 0.528463288433016 -0.840225084931738 0.121442823707358 0.0 0.663238967617202 0.722848933694653 0.193916195534491 0.0 CONVEX 0.038139308308712 0.00296656151593 -0.999268028446075 0.0 0.038139308308712 0.00296656151593 0.999268028446075 0.0 0.774987397478142 0.631976687663442 0.0 0.0 0.863388241811571 -0.504540131111018 0.0 0.0 CONVEX -0.133898775723039 -0.011004971223683 -0.990933907214925 0.0 0.211802118355974 0.019239873396932 0.97712317029717 0.0 0.761761130072363 0.631761100900387 -0.143519657538635 0.0 0.876420739730668 -0.458593144657196 -0.146897973584976 0.0 ";
			coverSpec.Text = _huge;
		}

		private void circle377512251ToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "CIRCLE LATLON 37.5 -122.5 1";
		}

		private void rect37701224237721224ToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "RECT LATLON 37.70 -122.42  37.72 -122.40";
		}

		private void rect8024801241ToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "RECT LATLON 80 24 80.1 24.1"; 
		}

		private void rect70247228ToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "RECT LATLON 70 24 72 28";
		}

		private void rect70247227ToolStripMenuItem_Click(object sender, EventArgs e) {
			coverSpec.Text = "RECT LATLON 70 24 72 27";
		}
        //region rect latlon 0.1 0.1 11 11 rect latlon 12 12 20 20 
		public static void addrange(List<Int64Pair> range, Int64 x, Int64 y) {
			Int64Pair a;
			a.lo = x;
			a.hi = y;
			range.Add(a);
		}

		private void spectest_Click(object sender, EventArgs e) {

			Int64 hid = Trixel.CartesianToHid(1.0, 0.0, 0.0, 20);
			return;
			//Interval foo = new Interval();
			//List<Int64Pair> bar = new List<Int64Pair>();
			//bar.Add(new Int64Pair(2L, 8L));

			//Int64Pair pp = bar[0];

			//pp.lo = 3L;
			//pp.hi = 9L;
			//bar.RemoveAt(0);
			//bar.Insert(0, pp);
			//bar.Clear();

			//// ------------------------
			//foo.AddRange(4L, 6L);
			//addrange(bar, 1L, 10L);
			//foo.merge(bar); // should be 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(1L, 10L);
			//addrange(bar, 4L, 6L);
			//foo.merge(bar); // should be 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(1L, 10L);
			//foo.merge(bar); // should be 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//addrange(bar, 1L, 10L);
			//foo.merge(bar); // should be 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//addrange(bar, 1L, 10L);
			//foo.merge(bar); // should be 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(1L, 6L);
			//addrange(bar, 4L, 10L);
			//foo.merge(bar); // should 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(4L, 10L);
			//addrange(bar, 1L, 6L);
			//foo.merge(bar); // should 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(4L, 10L);
			//addrange(bar, 1L, 6L);
			//addrange(bar, 7L, 9L);
			//foo.merge(bar); // should 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(1L, 6L);
			//foo.AddRange(7L, 9L);
			//addrange(bar, 4L, 10L);
			//foo.merge(bar); // should be 1 - 10
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(1L, 3L);
			//foo.AddRange(5L, 7L);
			//foo.AddRange(9L, 11L);
			//addrange(bar, 2L, 4L);
			//addrange(bar, 6L, 8L);
			//foo.merge(bar);
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(2L, 4L);
			//foo.AddRange(6L, 8L);

			//addrange(bar, 1L, 3L);
			//addrange(bar, 5L, 7L);
			//addrange(bar, 9L, 11L);
			//foo.merge(bar);
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(2L, 4L);
			//foo.AddRange(6L, 10L);
			//addrange(bar, 3L, 7L);
			//addrange(bar, 9L, 11L);
			//foo.merge(bar);
			//// ------------------------
			//foo.Clear();
			//bar.Clear();
			//foo.AddRange(2L, 4L);
			//addrange(bar, 4L, 6L);
			//foo.merge(bar);
			//foo.Clear();

			//foo.AddRange(1L, 3L);
			//foo.AddRange(4L, 6L);
			//foo.AddRange(7L, 99L);
			//foo.AddRange(100L, 120L);
			//foo.AddRange(121L, 200L);
			//foo.AddRange(400L, 450L);
			//foo.AddRange(451L, 500L);
			//foo.compact();
			//// --
			//foo.Clear();
			//List<H.Int64Pair> xx = new List<H.Int64Pair>();

			//addrange(xx, 101L, 102L);
			//addrange(xx, 1L, 2L);
			//xx.Sort(ComparisonRanges);
			//foreach (H.Int64Pair i in xx) {
			//    System.Console.WriteLine("({0}, {1})", i.lo, i.hi);
			//}

		}

		private void deltaLevelChanged(object sender, EventArgs e) {
			int delta;
			try {
				delta = int.Parse(this.deltaLevelBox.Text);
			} catch {
				this.deltaLevelBox.Text = HtmState.Instance.deltalevel.ToString();
				delta = HtmState.Instance.deltalevel;
			}
			HtmState.Instance.deltalevel = delta;

		}

		private void traceCheckBox_CheckedChanged(object sender, EventArgs e) {
			CheckBox cb = (CheckBox)sender;
			
		}

        private void tinyDiskToolStripMenuItem_Click(object sender, EventArgs e)
        {
            coverSpec.Text = "CIRCLE J2000 53.1299 -27.8761 36";
        }

        private void coloradoPolyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            coverSpec.Text = "POLY J2000 -109.55 41 -102.05 41 -102.05 37 -109.55 37";
        }

        private void coloradoRectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            coverSpec.Text = "RECT J2000 -109.55 37 -102.05 41";
        }

        private void cubeToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            coverSpec.Text = 
                "REGION CARTESIAN 1 0 0 -0.6 0 1 0 -0.6 0 0 1 -0.6 -1 0 0 -0.6 0 -1 0 -0.6 0 0 -1 -0.6";
        }

        private void californiaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            coverSpec.Text = 
                "region rect latlon 39 -125 42 -120 chull latlon 39 -124 39 -120 35 -114.6 34.3 -114.1 32.74 -114.5 32.53 -117.1 33.2 -119.5 34 -120.5 34.57 -120.65 36.3 -121.9 36.6 -122.0 38 -123.03";
        }
        
        private void baltimoreCircleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            coverSpec.Text =
                "CIRCLE LATLON 39.3, -76.61, 100"; 
        }

        private void coloradoRectToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            coverSpec.Text = 
                "RECT LATLON 37 -109.55  41 -102.05";
        }

        private void coloradoChullToolStripMenuItem_Click(object sender, EventArgs e)
        {
            coverSpec.Text = 
                "CHULL LATLON 37 -109.55 41 -109.55 41 -102.05 37 -102.05";
        }

        private void utah2RectsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // utah, main plus lake(s)
            coverSpec.Text = 
                "region rect latlon 37 -114.0475  41 -109.0475 rect latlon 41 -114.0475  42 -111.01";
        }

        private void unionTwoRectsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            coverSpec.Text =
                "region rect latlon 0.1 0.1 11 11 rect latlon 12 12 20 20 ";
        }

        private void maskToolStripMenuItem_Click(object sender, EventArgs e) {
            coverSpec.Text =
                "CONVEX CARTESIAN -0.996425471013994 -0.084475899887033 -0.000321018403806 0.999661878489243 -0.021731872810911 -0.001901292508142 -0.999762027079909 0.0  -0.021731872810911 -0.001901292508142 0.999762027079909 0.0 0.089125151859617 -0.996020435184942 0.0 0.0  0.993154765232004 0.116805433281792 0.000321018403806 -0.999661878489243 0.993231627341476 0.107582025318876 -0.043784041349471 -0.999661878489243 0.995617234108916 0.082999813755039 0.043097030778705 -0.999661878489243";
        }

        private void bandToolStripMenuItem_Click(object sender, EventArgs e) {
            coverSpec.Text =
                "region convex 1 0 0 -0.1 -1 0 0 -0.1";

        }

        private void colRectToolStripMenuItem_Click(object sender, EventArgs e) {
            coverSpec.Text = "POLY J2000 -109 37 -109 41 -102 41 -102 37";
        }

        private void colDiagToolStripMenuItem_Click(object sender, EventArgs e) {
            coverSpec.Text = "POLY J2000 -109 37 -109 38 -102 41 -102 40";
        }

        private void randPolyToolStripMenuItem_Click(object sender, EventArgs e) {
            coverSpec.Text = "POLY J2000 -110 35 -110 50 -80 50 -80 35";
        }

        private void randDiagToolStripMenuItem_Click(object sender, EventArgs e) {
            coverSpec.Text = "POLY J2000 -110 35 -110 36 -80 50 -80 49";
        }

        private void randRectToolStripMenuItem_Click(object sender, EventArgs e) {
            coverSpec.Text = "RECT J2000 -110 35 -80 50";
        }

        private void feqpcheckBox_CheckedChanged(object sender, EventArgs e) {

        }
        // 
        // 
        // 

	}
}
		//private void pickaSpec(object sender, EventArgs e)
		//{
		//    } else if (huge.Checked){
		//        this.coverSpec.Text = _huge;
		//    }
		//}
			//coverSpec.Text = "CIRCLE LATLON 37.5 -122.5 1";
			//coverSpec.Text = "RECT LATLON 37.70 -122.42  37.72 -122.40";
			//coverSpec.Text = "RECT LATLON 80 24 80.1 24.1"; 
			//coverSpec.Text = "RECT LATLON 70 24 72 28";
			//coverSpec.Text = "RECT LATLON 70 24 72 27";
