public SetWindowDialog(double xMin, double xMax, double xScale, 
            double yMin, double yMax, double yScale, bool axesOn, bool gridOn, Parser parser)
        {
            InitializeComponent();

            this.parser = parser;

            this.AcceptButton = button1;
            this.CancelButton = button2;

            textBox1.Text = xMin.ToString();
            textBox2.Text = xMax.ToString();
            textBox3.Text = xScale.ToString();
            textBox4.Text = yMin.ToString();
            textBox5.Text = yMax.ToString();
            textBox6.Text = yScale.ToString();
            checkBox1.Checked = axesOn;
            checkBox2.Checked = gridOn;

            checkBox2.Enabled = axesOn;
            if (!axesOn) checkBox2.Checked = false;
        }
        public Approximation(Parser parser)
        {
            this.parser = parser;

            this.curves = new List<CurveItem>(3);
        }
        private void Initialize()
        {
            try
            {
                parser = new Parser();
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                MessageBox.Show("Could not load MTParser, likely because it has not been registered.",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }

            timer = new Timer();
            timer.Interval = 100;
            timer.Tick += (object sender, EventArgs e) =>
                {
                    Control c = ActiveControl;
                    if ((c is TextBox && !(c as TextBox).ReadOnly) || c is DomainUpDown)
                        lastActiveInputBox = c;
                };
            timer.Start();

            this.AcceptButton = this.button1;
            this.lastActiveInputBox = textBox1;

            approx = new Approximation(parser);
            approx.Function = "(x-2)^2+2";
            approx.Start = 0;
            approx.End = 4;
            approx.Intervals = 4;

            textBox1.Text = approx.Function;
            textBox2.Text = approx.Start.ToString();
            textBox3.Text = approx.End.ToString();
            //by changing the text, the index changes, causing the index to be reset
            //and the surrounding numbers to be generated
            domainUpDown1.Text = approx.Intervals.ToString();

            InitializeGraph();
            zg1.ZoomEvent += new ZedGraphControl.ZoomEventHandler(zg1_ZoomEvent);

            //by setting the index, UpdateGraph() is called
            comboBox1.SelectedIndex = 0;
        }