Beispiel #1
0
 private void DatosForm_Load(object sender, EventArgs e)
 {
     idBox.Text        = miPlan.GetID();
     compañiaBox.Text  = miPlan.GetCompañía();
     origenXBox.Text   = Convert.ToString(Math.Round(miPlan.GetIX(), 2, MidpointRounding.ToEven));
     OrigenYBox.Text   = Convert.ToString(Math.Round(miPlan.GetIY(), 2, MidpointRounding.ToEven));
     destinoYBox.Text  = Convert.ToString(Math.Round(miPlan.GetFX(), 2, MidpointRounding.ToEven));
     DestinoXbox.Text  = Convert.ToString(Math.Round(miPlan.GetFY(), 2, MidpointRounding.ToEven));
     velocidadBox.Text = Convert.ToString(Math.Round(miPlan.GetVelocidad(), 2, MidpointRounding.ToEven));
 }
        private void MostrarTodosForm_Load(object sender, EventArgs e)
        {
            vuelosGrid.ColumnCount           = 5;
            vuelosGrid.RowHeadersVisible     = false;
            vuelosGrid.Columns[0].HeaderText = "ID";
            vuelosGrid.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            vuelosGrid.Columns[1].HeaderText = "Actual X";
            vuelosGrid.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            vuelosGrid.Columns[2].HeaderText = "Actual Y";
            vuelosGrid.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            vuelosGrid.Columns[3].HeaderText = "Velocidad";
            vuelosGrid.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            vuelosGrid.Columns[4].HeaderText = "Distancia";
            vuelosGrid.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            vuelosGrid.Rows.Add(miPlan1.GetID(), miPlan1.GetIX(), miPlan1.GetIY(), miPlan1.GetVelocidad(), miPlan1.Distance(miPlan2));
            vuelosGrid.Rows.Add(miPlan2.GetID(), miPlan2.GetIX(), miPlan1.GetIY(), miPlan2.GetVelocidad(), miPlan2.Distance(miPlan1));

            vuelosGrid.ClearSelection();
        }
Beispiel #3
0
        private void Form5_Load(object sender, EventArgs e)
        {
            //creamos el data grid view
            panelgrid.ColumnCount          = mylist.getcount() + 1;
            panelgrid.RowCount             = 7;
            panelgrid.ColumnHeadersVisible = false;
            panelgrid.RowHeadersVisible    = false;
            panelgrid.AutoSizeColumnsMode  = DataGridViewAutoSizeColumnsMode.AllCells;

            //ponemos las cabeceras
            panelgrid[0, 0].Value = "ID";
            panelgrid[0, 1].Value = "Compañia";
            panelgrid[0, 2].Value = "Velocidad";
            panelgrid[0, 3].Value = "Inicio";
            panelgrid[0, 4].Value = "Fin";
            panelgrid[0, 5].Value = "Email";
            panelgrid[0, 6].Value = "Telefono";

            //abrimos la bbdd para coger los datos
            baseops misops = new baseops();

            misops.open();

            //Check nos dice si la compañía está en la bbdd
            bool check = false;

            //Recorremos la lista
            int i = 0;

            while (i < mylist.getcount())
            {
                //cogemos el fp
                FlightPlan fp = mylist.getposicion(i);

                //ponemos los datos del fp en el datagridview
                panelgrid[i + 1, 0].Value = fp.GetID();
                panelgrid[i + 1, 2].Value = Convert.ToString(fp.GetVelocidad());
                panelgrid[i + 1, 3].Value = Convert.ToString("(" + fp.GetIX() + "," + fp.GetIY() + ")");
                panelgrid[i + 1, 4].Value = Convert.ToString("(" + fp.GetFX() + "," + fp.GetFY() + ")");

                //comprobamos si la compañía de ese vuelo está o no en la bbdd
                check = misops.compruebacomp(Convert.ToString(fp.GetCompañia()));

                //Si está:
                if (check == true)
                {
                    //Cogemos los datos de esa compañía
                    DataTable res = misops.GetCompañia(Convert.ToString(fp.GetCompañia()));

                    //Los escribimos en el datagridview
                    panelgrid[i + 1, 5].Value = res.Rows[0]["Email"];
                    panelgrid[i + 1, 6].Value = Convert.ToString(res.Rows[0]["Telefono"]);
                    panelgrid[i + 1, 1].Value = res.Rows[0]["Name"];
                }

                //si la compañía no está en la bbdd:
                if (check == false)
                {
                    //En el datagridview marcamos los datos correspondientes como no disponibles
                    panelgrid[i + 1, 5].Value = "(No Disponible)";
                    panelgrid[i + 1, 6].Value = "(No Disponible)";
                    panelgrid[i + 1, 1].Value = Convert.ToString(fp.GetCompañia());
                }

                //Cerramos la bbdd
                misops.close();

                i++;
            }
        }
Beispiel #4
0
        private void Form4_Load(object sender, EventArgs e) //insertamos en cada TextBox su valor
        {
            //Ponemos en cada textbox el valor correspondiente
            idbox.Text    = Convert.ToString(myfp.GetID());
            compbox.Text  = Convert.ToString(myfp.GetCompañia());
            velbox.Text   = Convert.ToString(myfp.GetVelocidad());
            posinbox.Text = "(" + Convert.ToString(myfp.GetIX()) + "," + Convert.ToString(myfp.GetIY()) + ")";
            decimal posactualx = Decimal.Round(Convert.ToDecimal(myfp.GetAX()), 2);
            decimal posactualy = Decimal.Round(Convert.ToDecimal(myfp.GetAY()), 2);

            posactbox.Text = "(" + Convert.ToString(posactualx) + "," + Convert.ToString(posactualy) + ")";
            posfinbox.Text = "(" + Convert.ToString(myfp.GetFX()) + "," + Convert.ToString(myfp.GetFY()) + ")";

            //Abrimos la bbdd para coger los datos de las compañías
            baseops misops = new baseops();

            misops.open();

            //Cogemos el nombre de la compañía (que es un atributo de la clase flightplan
            string name = Convert.ToString(myfp.GetCompañia());

            //Comprobamos que esté en la bbdd
            bool check = misops.compruebacomp(name);

            //Si está:
            if (check == true)
            {
                //Cogemos los datos de la compañía con nombre name
                DataTable res = misops.GetCompañia(name);

                //Los escribimos en los textbox
                emailbox.Text = Convert.ToString(res.Rows[0]["Email"]);
                telefbox.Text = Convert.ToString(res.Rows[0]["Telefono"]);

                //Para añadir el logo:
                string direclogo = Convert.ToString(res.Rows[0]["Logo"]);

                if (direclogo != null) //Si hay un logo disponible lo usamos
                {
                    try
                    {
                        string path = Path.Combine(Application.StartupPath, @"..\..\Resources", direclogo);
                        Bitmap logo = (Bitmap)Image.FromFile(path);
                        panelogo.BackgroundImage       = logo;
                        panelogo.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                    catch
                    {
                        panelogo.BackgroundImage       = Properties.Resources.missing;
                        panelogo.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                }
                if (direclogo == "missing" || direclogo == null)
                {
                    panelogo.BackgroundImage = Properties.Resources.missing;
                }
            }

            //Si no está:
            else
            {
                panelogo.BackgroundImage       = Properties.Resources.missing;
                panelogo.BackgroundImageLayout = ImageLayout.Stretch;

                emailbox.Text = "(No disponible)";
                telefbox.Text = "(No disponible)";
            }

            //Cerramos la bbdd
            misops.close();
        }
        private void panel1_Paint(object sender, PaintEventArgs e) //Para hacer los dibujos (círculo de distancia de seguridad, raya de la trayectoria y pintar círculo en caso de conflicto)
        {
            int i = 0;
            int c = 0;

            while (i < listFP.getcount())
            {
                System.Drawing.Graphics graphics = e.Graphics;

                //Cogemos el FP y recogemos sus posiciones
                FlightPlan FP = listFP.getposicion(i);

                int x = Convert.ToInt32(FP.GetAX());
                int y = Convert.ToInt32(FP.GetAY());

                int xi = Convert.ToInt32(FP.GetIX());
                int yi = Convert.ToInt32(FP.GetIY());

                int xf = Convert.ToInt32(FP.GetFX());
                int yf = Convert.ToInt32(FP.GetFY());

                //Mostramos círulo de distancia de seguridad
                int xact = x - dseg / 2;
                int yact = y - dseg / 2;

                //Definimos h como una raya de color azul para dibujar la distancia de seguridad
                Pen h = new Pen(Color.Blue, 1);

                //Definimos brush de color rojo para pintar el círculo en caso de conflicto
                SolidBrush brush = new SolidBrush(Color.Red);

                //Creamos un rectangulo con centro en la posición actual y longitud de los lados=distancia de seguridad
                System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(xact, yact, dseg, dseg);

                //Dibujamos
                if (listFP.getcount() > 1)        //Si hay más de un FP, hemos de comprobar los conflictos
                {
                    while (c < listFP.getcount()) //Recorre la lista de FP
                    {
                        try
                        {
                            //si hay conflicto entre dos o más aviones el círculo se pinta de color rojo al tocarse las distancias de seguridad entre ellas
                            if (listFP.getposicion(i).Estaenconflicto(listFP.getposicion(c), dseg) == -1 && (c != i))
                            {
                                e.Graphics.FillEllipse(brush, rectangle);
                                brush.Dispose();
                            }
                        }
                        catch
                        {
                        }
                        //Si no están en conflicto, dibujamos la raya que marca la distancia de seguridad
                        if (dseg < listFP.getposicion(i).Distance(listFP.getposicion(c)) && (c != i))
                        {
                            graphics.DrawEllipse(h, rectangle);
                        }
                        c = c + 1;
                    }
                }
                else //Si solo hay un FP, dibuja el círculo de radio distancia de seguridad
                {
                    graphics.DrawEllipse(h, rectangle);
                }
                c = 0;

                i++;

                //dibujamos la linea de trayectoria desde la posición inicial hasta la final
                Pen b = new Pen(Color.Black, 1);
                e.Graphics.DrawLine(b, xi, yi, xf, yf);
            }
        }
Beispiel #6
0
        private void SimularForm_Load(object sender, EventArgs e)
        {
            vuelo1           = new PictureBox();
            vuelo1.Size      = new Size(10, 10);
            vuelo1.BackColor = Color.Black;
            vuelo1.Location  = new Point(Convert.ToInt32(miPlan1.GetIX() - 5), Convert.ToInt32(miPlan1.GetIY() - 5));

            vuelo2           = new PictureBox();
            vuelo2.Size      = new Size(10, 10);
            vuelo2.BackColor = Color.Black;
            vuelo2.Location  = new Point(Convert.ToInt32(miPlan2.GetIX() - 5), Convert.ToInt32(miPlan2.GetIY() - 5));

            etiqueta2             = new Label();
            etiqueta2.Text        = miPlan2.GetID();
            etiqueta2.Size        = new Size(40, 20);
            etiqueta2.Location    = new Point(Convert.ToInt32(miPlan2.GetIX()), Convert.ToInt32(miPlan2.GetIY()) + 3);
            etiqueta2.Tag         = miPlan2;
            etiqueta2.MouseClick += new MouseEventHandler(Avion_click);

            etiqueta1             = new Label();
            etiqueta1.Text        = miPlan1.GetID();
            etiqueta1.Size        = new Size(40, 20);
            etiqueta1.Location    = new Point(Convert.ToInt32(miPlan1.GetIX()), Convert.ToInt32(miPlan1.GetIY()) + 3);
            etiqueta1.Tag         = miPlan1;
            etiqueta1.MouseClick += new MouseEventHandler(Avion_click);

            PictureBox destino1 = new PictureBox();

            destino1.Size      = new Size(8, 8);
            destino1.BackColor = Color.Red;
            destino1.Location  = new Point(Convert.ToInt32(miPlan1.GetFX() - 4), Convert.ToInt32(miPlan1.GetFY() - 4));

            PictureBox destino2 = new PictureBox();

            destino2.Size      = new Size(8, 8);
            destino2.BackColor = Color.Red;
            destino2.Location  = new Point(Convert.ToInt32(miPlan2.GetFX() - 4), Convert.ToInt32(miPlan2.GetFY() - 4));

            PictureBox origen1 = new PictureBox();

            origen1.Size      = new Size(8, 8);
            origen1.BackColor = Color.Red;
            origen1.Location  = new Point(Convert.ToInt32(miPlan1.GetIX() - 4), Convert.ToInt32(miPlan1.GetIY() - 4));

            PictureBox origen2 = new PictureBox();

            origen2.Size      = new Size(8, 8);
            origen2.BackColor = Color.Red;
            origen2.Location  = new Point(Convert.ToInt32(miPlan2.GetIX() - 4), Convert.ToInt32(miPlan2.GetIY() - 4));

            miPanel.Controls.Add(destino1);
            miPanel.Controls.Add(origen1);
            miPanel.Controls.Add(etiqueta1);
            miPanel.Controls.Add(destino2);
            miPanel.Controls.Add(origen2);
            miPanel.Controls.Add(etiqueta2);
            miPanel.Controls.Add(vuelo2);
            miPanel.Controls.Add(vuelo1);

            pintar = true;
            miPanel.Invalidate();

            plan1label.Text = Convert.ToString(miPlan1.GetID());
            plan2label.Text = Convert.ToString(miPlan2.GetID());
            speedV1.Text    = Convert.ToString(miPlan1.GetVelocidad());
            speedV2.Text    = Convert.ToString(miPlan2.GetVelocidad());
        }