//Create a bar graph, add it to a parent form, fill in data
        public static Graph Create_Bar_Graph(Rectangle location, string[][] data)
        {
            //First, create the control graph will be in
            GraphControl gc = new GraphControl();
            List<List<double>> newData = new List<List<double>>();

            //parse the 2d string array
            for( int i = 0; i < data.Length; i++ )
            {
                newData.Add(new List<double>());
                for( int j = 0; j < data[i].Length; j++ )
                {
                    double parsedDouble;
                    if (!Double.TryParse(data[i][j], out parsedDouble))
                        throw new ArgumentException("Invalid data in Cells");
                    newData[i].Add(parsedDouble);
                }
            }

            // now create graph with data
            Graph gr = new bar_graph(newData);

            // location, size of graph in preview tab
            gc.Location = new Point(0, 0);
            gc.Size = new Size(450,400);
            gc.SetGraph(gr);

            // open up a graph configuration window
            graphConfig gConf = new graphConfig(gr,gc);
            gConf.ShowDialog();

            // if press ok then put graph control in main form
            if (gConf.DialogResult == DialogResult.OK)
            {
                // put in the graph with the changes
                gr = gConf.gr;
                // create new control to reset any parameters
                gc = new GraphControl();
                // location and size of control inside main form
                gc.Location = new Point(location.X, location.Y);
                gc.Size = location.Size;
                gc.SetGraph(gr);
                gr.InitFonts();
                gr.InitLabels();

                //add to main form
                Controller.Instance.MainForm.WorksheetsTabControl.SelectedTab.Controls.Add(gc);
                gc.BringToFront();

                return gr;
            }

            return null;
        }
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (inMenu)
                return;

            Point prevLoc = this.Location;
            Size prevSize = this.Size;
            Form parent = this.ParentForm;
            Graph prevGr = gr.cloneGraph();

            this.Location = new Point(0, 0);  //gc.loc is a point, not rect
            this.Size = new Size(450, 400);

            graphConfig gConf = new graphConfig(gr, this);
            gConf.ShowDialog();

            GraphControl gc = new GraphControl();
            gc.Location = prevLoc;
            gc.Size = prevSize;
            if (gConf.DialogResult == DialogResult.OK)
                gc.SetGraph(gr);
            else
                gc.SetGraph(prevGr);
            gr.InitFonts();
            gr.InitLabels();

            parent.Controls.Add(gc);
            gc.BringToFront();
        }