示例#1
0
        public void ResultadosLoad() //establece el valor de las label de info despues de cargar un .ast
        {
            string nombreInformativo  = this.openFileDialog1.SafeFileName;
            string nombreInformativo1 = "";
            string nombreInformativo2 = "";

            if (nombreInformativo.Count() > 34)//Controla que el titulo no sea demasiado largo y salga de la form
            {
                for (int i = 0; i < 34; i++)
                {
                    nombreInformativo1 = nombreInformativo1 + Convert.ToString(nombreInformativo[i]);
                }
                for (int i = 34; i < nombreInformativo.Count(); i++)
                {
                    nombreInformativo2 = nombreInformativo2 + Convert.ToString(nombreInformativo[i]);
                }
            }
            string avionesDetectados = "";
            int    aircraftDetected  = myList.AircraftDetected();

            if (aircraftDetected != 0)
            {
                avionesDetectados = "\n            from " + aircraftDetected +
                                    " different transponders";
            }
            if (nombreInformativo1 != "")
            {
                labelInformativa.Text = nombreInformativo1 + "\n" + nombreInformativo2 + " correctly\nloaded\n\n" +
                                        myList.GetNumList() + " packages readed" + avionesDetectados + "\n\nbetween " + myList.GetPlanI(0).ConvertUTC("SinDecimas") +
                                        " hours\n         and " + myList.GetPlanI(myList.GetNumList() - 1).ConvertUTC("SinDecimas") + " hours";
                labelInformativa.Location = new Point(labelInfoLoc.X - 20, labelInfoLoc.Y - 20);
            }
            else
            {
                labelInformativa.Text = this.openFileDialog1.SafeFileName + " correctly\nloaded\n\n" +
                                        myList.GetNumList() + " packages readed" + avionesDetectados + "\n\nbetween " + myList.GetPlanI(0).ConvertUTC("SinDecimas") +
                                        " hours\n         and " + myList.GetPlanI(myList.GetNumList() - 1).ConvertUTC("SinDecimas") + " hours";
                labelInformativa.Location = new Point(labelInfoLoc.X, labelInfoLoc.Y);
            }
        }
示例#2
0
        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;
                }
            }
        }