Example #1
0
 public RegVuelos(ref ListaVuelos listavuelos, ref ListaCiudades listaciudades)
 {
     InitializeComponent();
     this.listavuelos           = listavuelos;
     this.listaciudades         = listaciudades;
     dateTimePicker1.Format     = DateTimePickerFormat.Short;
     dateTimePicker2.Format     = DateTimePickerFormat.Time;
     dateTimePicker2.ShowUpDown = true;
 }
Example #2
0
        public UsuariosLista(ref ListaVuelos listaVuelos)
        {
            InitializeComponent();
            button_buscar.Enabled = false;
            VueloId          = 0;
            button1.Enabled  = false;
            this.listaVuelos = listaVuelos;
            refreshListview();

            //     if (userList.Items.Count <= 0)
            //   {
            //      button1.Enabled = false;
            //  }
        }
Example #3
0
        public GrafoVisual(ref ListaCiudades listaciudades, ref ListaVuelos listaVuelos)
        {
            InitializeComponent();
            checkBoxCosto.Checked = true;
            this.listaVuelos      = listaVuelos;
            buttonDelete.Enabled  = false;
            this.listaciudades    = listaciudades;
            refreshListView();


            pictureBox1.Image = new Bitmap(pictureBox1.Image);


            buttonDijk.Enabled = false;


            g = Graphics.FromImage(pictureBox1.Image);
            g.SmoothingMode     = SmoothingMode.AntiAlias;              // The smoothing mode specifies whether lines, curves, and the edges of filled areas use smoothing (also called antialiasing). One exception is that path gradient brushes do not obey the smoothing mode. Areas filled using a PathGradientBrush are rendered the same way (aliased) regardless of the SmoothingMode property.
            g.InterpolationMode = InterpolationMode.HighQualityBicubic; // The interpolation mode determines how intermediate values between two endpoints are calculated.
            g.PixelOffsetMode   = PixelOffsetMode.HighQuality;          // Use this property to specify either higher quality, slower rendering, or lower quality, faster rendering of the contents of this Graphics object.
            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;


            penarrow.StartCap = LineCap.ArrowAnchor;
            penarrow.EndCap   = LineCap.ArrowAnchor;



            foreach (CiudadNodo c in listaciudades)
            {
                comboBox1.Items.Add(c.name);
                comboBox2.Items.Add(c.name);

                g.DrawEllipse(pen1, c.X, c.Y, 10, 10);
                g.DrawString(c.getName(), new Font("Tahoma", 8), Brushes.White, c.X, c.Y);

                foreach (AristaCiudad a in c.Aristas)
                {
                    penarrow.Color = Color.FromArgb(100, Color.Red);
                    g.DrawLine(penarrow, a.X, a.Y, c.X, c.Y);
                    g.DrawString(a.getCosto().ToString() + "  " + a.getTiempo().ToString(), new Font("Tahoma", 8), Brushes.Blue, calcMedPoint(a.X, c.X), calcMedPoint(a.Y, c.Y));
                    // g.DrawEllipse(pen1,a.X, a.Y, 10, 10);
                }
            }
        }
Example #4
0
        public VuelosLista(ref ListaVuelos listaVuelos, ref ListaCiudades listaciudades)
        {
            InitializeComponent();

            Buscar.Enabled        = false;
            this.listaVuelos      = listaVuelos;
            this.listaciudades    = listaciudades;
            Button_delete.Enabled = false;



            int index = 0;

            foreach (Vuelo v in listaVuelos)
            {
                string[]     datav = v.ToString('|').Split('|');
                ListViewItem dv    = new ListViewItem(datav);
                dv.SubItems.Add(index.ToString());
                listView1.Items.Add(dv);
                index++;
            }
        }
Example #5
0
 public Principal(ref ListaVuelos listaVuelos, ref ListaCiudades listaciudades)
 {
     InitializeComponent();
     this.listaVuelos   = listaVuelos;
     this.listaciudades = listaciudades;
 }
Example #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Principal());



            ListaVuelos   listaVuelos   = new ListaVuelos();
            ListaCiudades listaciudades = new ListaCiudades();


            try
            {   // Open the text file using a stream reader.
                using (StreamReader sr = new StreamReader("infoVuelos.txt"))
                {
                    // Read the stream to a string, and write the string to the console.

                    while (!sr.EndOfStream)
                    {
                        String   line      = sr.ReadLine();
                        string[] datavuelo = line.Split('|');
                        Console.WriteLine(datavuelo[5]);
                        DateTime date  = DateTime.Parse(datavuelo[5]);
                        Vuelo    vuelo = new Vuelo(int.Parse(datavuelo[0]), datavuelo[1], datavuelo[2], int.Parse(datavuelo[4]), int.Parse(datavuelo[3]), date);
                        listaVuelos.Add(vuelo);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file Info vueloes could not be read:");
                Console.WriteLine(e.Message);
                return;
            }

            //Leyendo usuarios

            try {
                using (StreamReader ifile = new StreamReader("usuarios.txt"))
                {
                    while (!ifile.EndOfStream)
                    {
                        string   uline  = ifile.ReadLine();
                        string[] du     = uline.Split('|');
                        int      indexV = int.Parse(du[0]);
                        //indice es igual a al primer campo de du
                        Usuario user = new Usuario(du[1], du[2], du[4], int.Parse(du[3]));

                        listaVuelos[indexV].userlist.Add(user);
                        listaVuelos[indexV].setAsientoTomado(int.Parse(du[3]));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }


            //Leyendo Ciudades


            try
            {
                using (StreamReader ifile = new StreamReader("Ciudades.txt"))
                {
                    while (!ifile.EndOfStream)
                    {
                        string              cline   = ifile.ReadLine();
                        string[]            cu      = cline.Split('|');
                        List <AristaCiudad> aristas = new List <AristaCiudad>();

                        CiudadNodo city = new CiudadNodo(float.Parse(cu[0]), float.Parse(cu[1]), cu[2], aristas);

                        listaciudades.Add(city);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            //Leyendo Aristas



            try
            {
                using (StreamReader ifile = new StreamReader("Aristas.txt"))
                {
                    while (!ifile.EndOfStream)
                    {
                        string       aline  = ifile.ReadLine();
                        string[]     au     = aline.Split('|');
                        AristaCiudad arista = new AristaCiudad(float.Parse(au[1]), float.Parse(au[2]), au[0], au[3], int.Parse(au[4]), int.Parse(au[5]));
                        int          ind    = listaciudades.getcityIndex(au[0]);
                        listaciudades[ind].Aristas.Add(arista);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }



            Principal ventanaPrincipal = new Principal(ref listaVuelos, ref listaciudades);

            ventanaPrincipal.ShowDialog();
            //codigo para escribir
            //string lines = "First line.\r\nSecond line.\r\nThird line.";

            StreamWriter file  = new StreamWriter("infoVuelos.txt");
            StreamWriter file2 = new StreamWriter("usuarios.txt");

            int vindex = 0;

            foreach (Vuelo v in listaVuelos)
            {
                file.WriteLine(v.ToString('|'));

                foreach (Usuario u in v.userlist)
                {
                    file2.WriteLine(vindex.ToString() + '|' + u.ToString());
                }

                vindex++;
            }
            file.Close();
            file2.Close();


            StreamWriter filecity = new StreamWriter("Ciudades.txt");
            StreamWriter fileari  = new StreamWriter("Aristas.txt");

            foreach (CiudadNodo c in listaciudades)
            {
                filecity.WriteLine(c.X.ToString() + '|' + c.Y.ToString() + '|' + c.getName());

                foreach (AristaCiudad a in c.Aristas)
                {
                    fileari.WriteLine(c.getName() + '|' + a.ToString());
                }
            }

            filecity.Close();
            fileari.Close();


            Console.WriteLine("fin del programa");
        }