//automatically select last obtained capture from Neb
            private async void fileSystemWatcher7_Created(object sender, FileSystemEventArgs e)
            {
                FileInfo file = new FileInfo(e.FullPath);//returns name of file that triggered FSW7
                Log(file.Name.ToString());
               GlobalVariables.SolveImage = file.ToString();
               Thread.Sleep(1000);//? remove
            if (GlobalVariables.LocalPlateSolve)
                Solve();
            else
            {
                //if (backgroundWorker1.IsBusy != true)
                //{
                //    backgroundWorker1.RunWorkerAsync();
                //}
                AstrometryNet ast = new AstrometryNet();
                await ast.OnlineSolve(GlobalVariables.SolveImage);
                solveRequested = true;
                //while (astrometryRunning)
                //    Thread.Sleep(100);
                //Solve();

            }
            }
            public void ParseXYRD()
            {
            try
            {

              //  string dataFile = "";
                //  FitsCorrReader();  // done in astrometry Class
                if (GlobalVariables.LocalPlateSolve)
                {
                    AstrometryNet ast = new AstrometryNet();
                    ast.MakeDataFile();
                    Thread.Sleep(200);
                    ast.Close();
                 }

                StreamReader reader2 = new StreamReader(GlobalVariables.Path2 + "\\corr2text.txt"); //read text3 which is corr.fits converted. X, Y, RA, Dec
               // StreamReader reader2 = new StreamReader(dataFile);
                string content;
                // while ((line = reader.ReadToEnd()) != null) {
                content = reader2.ReadToEnd();
                string[] lines = content.Split('\n');

                //  starsXY[,] xy = new string[lines.Length, lines.Length];
                // string[] y = new string[lines.Length];
                // string[] ra = new string[lines.Length];
                // string[] dec = new string[lines.Length];
                FileLog2("        X      " + "     Y     " + "      RA     " + "       DEC");
               // string find = "   1 ";
             //   int count = 0;
                int k = 0;
                foreach (var line in lines)
                {

                    //if (GlobalVariables.LocalPlateSolve)
                    //{
                    //    if (line.Contains(find) && count < 10) // skip until "    1" if found , count stays 0
                    //    {
                    //        RDfound = true;
                    //    }
                    //}
                    //else
                    //    RDfound = true;

                    //    if (RDfound && count < 10)
                    //    {
                            if (k < 10)
                    {
                                var values = line.Split('\t');

                                // X = values [0] = 2407.794
                                // Y =         [1] = 1167.264
                                // RA=         [2] = 68.48058
                                // DEC=         [3[ = 2407.93/r
                                if (IsDouble(values[0]))
                                    starsXY[k, 0] = Convert.ToDouble(values[0]);
                                else
                                    parseError = true;
                                if (IsDouble(values[1]))
                                    starsXY[k, 1] = Convert.ToDouble(values[1]);
                                else
                                    parseError = true;
                                if (IsDouble(values[2]))
                                    starsRD[k, 0] = Convert.ToDouble(values[2]);
                                else
                                    parseError = true;
                                if (IsDouble(values[3]))
                                    starsRD[k, 1] = Convert.ToDouble(values[3]);
                                else
                                    parseError = true;

                                FileLog2("    " + starsXY[k, 0] + "    " + starsXY[k, 1] + "     " + starsRD[k, 0] + "    " + starsRD[k, 1]);
                                // FileLog2(starsRD[count, 0] + "    " + starsRD[count, 1]);
                                k++;
                                if (parseError)
                                {
                                    Log("Erro parsing X/Y and RA/DEC data");
                                    FileLog("failed to parse X/Y and RA/Dec data");
                                    return;
                                }

                    }
                    else
                    {
                        XYfound = true;
                        RDfound = true;
                    }

                }
            }
            catch (Exception e)
            {
                Log("failed to parse X/Y and RA/Dec data");
                FileLog("failed to parse X?Y and RA/Dec data:  " + e.ToString());
            }
            }