private void LoadFileButton_Click(object sender, EventArgs e) { string nombre; //try //{ this.openFileDialog1.FileName = ""; this.openFileDialog1.Filter = "File documents (.ast)|*.ast"; Program.SetNoCerrar(true); this.openFileDialog1.ShowDialog(); Program.SetNoCerrar(false); if (this.openFileDialog1.FileName.Equals("") == false) { nombre = (this.openFileDialog1.FileName); Cursor.Current = Cursors.WaitCursor; LectorMensaje listTemporal = new LectorMensaje(); //Si ya hemos cargado una lista, no queremos que se sobre escriba con una list que no se cargue correctamente Program.SetNoCerrar(true); listTemporal.CargarListaDeDirectorio(nombre); Program.SetNoCerrar(false); if (listTemporal.GetNumList() != 0) { if (!listTemporal.TodoSMR()) { Program.SetNoCerrar(true); if (nuevoFicheroMain) { cerrarMain = true; nuevoFicheroMain = false; } myListConDescartados = listTemporal; bool diferentesSIC = myListConDescartados.ComprobarDiferentesSIC(); //Controla si hay SMR y MLAT en un mismo fichero if (diferentesSIC) { CrearFormInformativa("This file contains both SMR and MLAT packages. Only MLAT", "can be evaluated. SMR packages will be discarded.", 518, 201, 17, 41); Cursor.Current = Cursors.WaitCursor; LectorMensaje listaTemporal = new LectorMensaje(); listaTemporal = myListConDescartados.SepararSMRyADSB(); myListConDescartados.ClearList(); myListConDescartados = listaTemporal; } myListConDescartados.OrdenarPaquetesPorTiempo(); //Corrige algunos paquetes no ordenados myListConDescartados.SetUTCcorregido(); //Coregimos la hora para cambio de dia. Se hace despues de separar MLAT y SMR, ya que //cuando estan juntos los ficheros no estan perfectamente ordenados en tiempo y la funcion no funciona myList = myListConDescartados.DescartarVehiculosSquitter(); //Tambien ordenamos en tiempo los vehiculos Squitter, puesto que despues se pueden //llegar a usar en MainForm nombreFichero = this.openFileDialog1.SafeFileName; labelWelcome.Visible = false; labelSubWelcome.Visible = false; ResultadosLoad(); AvaluateButton.Visible = true; AddDGPSButton.BackColor = Color.FromArgb(255, 128, 0); AddDGPSButton.FlatAppearance.MouseOverBackColor = Color.FromArgb(255, 128, 0); myListDGPS.ClearList(); AddDGPSButton.Visible = true; LoadFileButton.Visible = false; Program.SetNoCerrar(false); } else { CrearFormInformativa("The file only contains SMR data. This program only evaluates MLAT.", "The program is also able to filter MLAT from (SMR + MLAT) files.", 575, 225, 22, 42); if (nuevoFicheroMain) { this.Close(); } } } else { CrearFormInformativa("Error while loading the file.", "Maybe wrong .ast category?", 280, 80, 22, 12); //Valores puestos a mano para cuadradrar el texto segun la longitud del propio texto if (nuevoFicheroMain) { this.Close(); } } } else { CrearFormInformativa("Please, ", "select a file first.", 173, 28, 46, 15); if (nuevoFicheroMain) { this.Close(); } } //} //catch (FormatException) //{ // CrearFormInformativa("Error while loading the file,", "incorrect data structure.", 261, 73, 17, 18); // return; //} //catch (FileNotFoundException) //{ // CrearFormInformativa("File not", "found.", 155, 19, 40, 43); // return; //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); // return; //} }
private void AddDGPSButton_Click(object sender, EventArgs e) { string nombre; string icao = ""; ICAOcode address = new ICAOcode(); address.ShowDialog(); icao = address.ExportarIcao(); if (icao != " ") { try { List <string> descartados = myListConDescartados.LeerVehiculosSquitter(); int i = 0; bool encontrado = false; bool respuesta = false; while ((i < descartados.Count()) && (!encontrado)) { if (icao == descartados[i]) { encontrado = true; respuesta = CrearFormInformativaYesNo("This ICAO Address is in the list of discarded vehicles.", "Do you want to remove it from the list?", 476, 97, 241, 27, 71); //Si el ICAO Address D-GPS esta en la lista de descartados if (respuesta) { Cursor.Current = Cursors.WaitCursor; descartados.Remove(icao); File.Delete("VehiculosAEliminar.txt"); File.WriteAllLines("VehiculosAEliminar.txt", descartados); myList.ClearList(); myList = myListConDescartados.DescartarVehiculosSquitter(); ResultadosLoad(); } } i++; } if ((encontrado && respuesta) || (!encontrado))//Si esta en la lista de descartados y se elimina, o sino esta en la lista { this.openFileDialog1.FileName = ""; this.openFileDialog1.Filter = "File documents (.txt)|*.txt"; this.openFileDialog1.ShowDialog(); if (this.openFileDialog1.FileName.Equals("") == false) { nombre = (this.openFileDialog1.FileName); Cursor.Current = Cursors.WaitCursor; LectorMensaje listTemporal = new LectorMensaje();//Si ya hemos cargado una lista, no queremos que se sobre escriba con una list que no se cargue correctamente listTemporal.CargarListaDeDirectorioDGPS(nombre, icao); if (listTemporal.GetNumList() != 0) { int matches = listTemporal.SetIndicesDGPS(myList);//Devuelve matches y hace SetIndiceDGPS() List <int> a = new List <int>(); for (int j = 0; j < listTemporal.GetNumList(); j++) { if (listTemporal.GetPlanI(j).GetIndiceDGPS() != -1) { a.Add(j); } } Matches form = new Matches(); form.ImportarMatches(matches); form.ShowDialog(); if (matches != 0) { myListDGPS = listTemporal; AddDGPSButton.BackColor = Color.LimeGreen; AddDGPSButton.FlatAppearance.MouseOverBackColor = Color.LimeGreen; } } else { CrearFormInformativa("Error while loading the file.", "Maybe wrong format?", 261, 73, 17, 18); } } else { CrearFormInformativa("Please, ", "select a file first.", 173, 28, 46, 15); } } } catch (FormatException) { CrearFormInformativa("Error while loading the file,", "incorrect data structure.", 261, 73, 17, 18); return; } catch (System.IndexOutOfRangeException) { CrearFormInformativa("Error while loading the file,", "incorrect data structure.", 261, 73, 17, 18); return; } catch (FileNotFoundException) { CrearFormInformativa("File not", "found.", 155, 19, 40, 43); return; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } }