private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                listBox1.Items.Add(Path.GetFileNameWithoutExtension(openFileDialog1.FileName));
                LasFileCollections[LasFileCounts] = new LasParametrs();
                IdentificationLasFile(openFileDialog1.FileName, LasFileCollections[LasFileCounts]);
                LasFileCounts++;
            }
            for (int i = 0; i < dataGridView1.ColumnCount; i++)
            {
                dataGridView1.Columns[i].Width = 50;
            }
        }
        private void IdentificationLasFile(string FilePath, LasParametrs Filename)
        {
            dataGridView1.Columns.Clear();
            RowsCount = 0;
            //InStream = new StreamReader(FilePath, Encoding.GetEncoding(1251));
            string readText = File.ReadAllText(FilePath, Encoding.GetEncoding(1251));

            string[] lines = Regex.Split(readText, "\r\n");
            bool     startReadDescription = false;
            bool     startReadLog         = false;
            string   tempSeriesString;
            int      descriptionCount = 0;
            string   lasString;

            double[] tempIcoming;
            label1.Visible       = true;
            progressBar1.Visible = true;
            progressBar1.Value   = 0;
            double step     = 100.0 / (lines.Length - 1);
            double progress = 0;

            for (int linesCount = 0; linesCount < lines.Length - 1; linesCount++)
            {
                progress += step;
                if (progress > 1)
                {
                    progress--;
                    progressBar1.Value++;
                }
                //this.Refresh();
                lasString      = lines[linesCount];
                Filename.Body += lasString + Environment.NewLine;

                if (lasString.Contains("NULL."))
                {
                    Filename.Null = mRegLine.Match(lasString).ToString();
                }

                if (lasString.Replace(" ", "") == "#MNEM.UNITAPICODECURVEDESCRIPTION")
                {
                    Filename.Body += linesCount + Environment.NewLine;
                    linesCount++;
                    lasString            = lines[linesCount];
                    Filename.Body       += lasString + Environment.NewLine;
                    startReadDescription = true;
                    linesCount++;
                    lasString = lines[linesCount];
                    //dataGridView1.Columns.Add("DEPT.M", "DEPT.M");
                }

                if ((startReadDescription == true && lasString.Contains("~")) | descriptionCount > 40)
                {
                    startReadDescription = false;
                }


                if (lasString.Replace(" ", "").Contains("~ASCII"))
                {
                    startReadLog = true;
                    linesCount++;
                    lasString = lines[linesCount];
                }

                if (startReadDescription)
                {
                    descriptionCount++;
                    if (descriptionCount != 1)
                    {
                        CollectionsPointPairList.Add(new PointPairList());
                    }
                    char[]   seps  = { ':' };
                    string[] parts = lasString.Split(seps, StringSplitOptions.RemoveEmptyEntries);
                    tempSeriesString = listBox1.Items[(listBox1.Items.Count - 1)].ToString() + "_" + parts[1];
                    checkedListBox1.Items.Add(tempSeriesString);
                    dataGridView1.Columns.Add(tempSeriesString, tempSeriesString);
                    Filename.CurveNames.Add(tempSeriesString);
                    CollectionsPointPairListNames.Add(tempSeriesString);
                }

                if (startReadLog == true)
                {
                    tempIcoming = new double[descriptionCount];
                    char[] seps = { ' ', '\t' };
                    lasString.Remove(0, 1);
                    string[] parts = lasString.Split(seps, StringSplitOptions.RemoveEmptyEntries);
                    dataGridView1.Rows.Add();
                    for (int i = 0; i < descriptionCount; i++)
                    {
                        if (parts[i] != Filename.Null)
                        {
                            tempIcoming[i] = parts[i].ToDblSlow();
                        }
                        else
                        {
                            tempIcoming[i] = double.NaN;
                        }
                        dataGridView1[i, RowsCount].Value = tempIcoming[i];
                        if (i > 0)
                        {
                            CollectionsPointPairList[i - 1].Add(tempIcoming[i], tempIcoming[0]);
                        }
                    }
                    RowsCount++;
                    Filename.Dept.Add(tempIcoming);
                    Filename.DescriptionCount = descriptionCount;
                }
            }
            label1.Visible       = false;
            progressBar1.Visible = false;
            tempIcoming          = new double[descriptionCount];
            for (int i = 0; i < Filename.Dept.Count; i++)
            {
                tempIcoming = Filename.Dept[i];
            }
            RichTextBoxLasContent.Text = Filename.Body;
            PointPairList temp = new PointPairList();
            //for (int j = 1; j < descriptionCount; j++)
            //{
            //    temp.Clear();
            //    for (int jj = 0; jj < dataGridView1.RowCount; j++)
            //    {
            //        temp.Add(Convert.ToDouble(dataGridView1[12, j].Value), Convert.ToDouble(dataGridView1[0, j].Value));
            //    }
            //}
            Random rnd = new Random();

            for (int i = 1; i < descriptionCount; i++)
            {
                DrawGraph(ZedGraphView, CollectionsPointPairListNames[i - 1], CollectionsPointPairList[i - 1], _colors[rnd.Next(_colors.Length)]);
            }
            VisibleCurves();
        }