Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            cerrar = false;
            Play.Visible = false;
            progressBar1.Maximum = 8;
            progressBar1.Value = 1;
            Invoke(myDelegate, new Object[] { "Loading... Please Wait." });
            Play.Enabled = false;//DESABILITO PLAY

            //byte[] m_soundBytes = new byte[Properties.Resources.iniciando1.Length];
            //Properties.Resources.iniciando1.Read(m_soundBytes, 0, (int)Properties.Resources.iniciando1.Length);
              //  new System.Media.SoundPlayer(
            //System.IO.Stream stream = (System.IO.Stream)Properties.Resources.ResourceManager.BaseName. "iniciando1",false,false);
               // System.Media.SoundPlayer player = new System.Media.SoundPlayer(stream);
               //     Properties.Resources.iniciando1.Play();
            //WSounds ws1 = ;

               // string patch = System.AppDomain.CurrentDomain.BaseDirectory.ToString() BaseDirectory;// BaseDirectory;
            string _appFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            string dirSonido = _appFolder + @"\Sounds\iniciando.wav";//\Sounds\\Sonidos"\\Tarjeta de almacenamiento\\FLEET_MOBILE_14d\\MisSonidos\\iniciando.wav";//Properties.Resources.ResourceManager.BaseName+"\\// "..\\Resources\\iniciando.wav";//\\Tarjeta de almacenamiento\\FLEET_MOBILE_14d\\MisSonidos\\iniciando.wav";
            dirSonido = "\\Tarjeta de almacenamiento\\FLEET_MOBILE_14d\\MisSonidos\\iniciando.wav";

            try
            {
                WSounds ws = new WSounds();
                ws.Play(dirSonido, ws.SND_FILENAME | ws.SND_ASYNC);
            }
            catch (Exception ex)
            {
                Invoke(myDelegate, new Object[] { "Error: " + ex.Message });
            }

            Hardware detect = new Hardware();
            if (detect.BluetoothOn())//habilita bluetooth
                Invoke(myDelegate, new Object[] { "Enabled Bluetooth successfully." });
            if (detect.WifiOn())// habilita wifi
                Invoke(myDelegate, new Object[] { "Enabled Wifi successfully." });
            if (detect.conectawifi("vaipho"))//conecta a la red vaipho
                Invoke(myDelegate, new Object[] { "VAiPho connected successfully." });
            progressBar1.Value = 2;

            //Si el manos libres del coche se apaga, VAiPho se apagará también (para evitar atascos inexistentes)
            int key = (int)Registry.GetValue(registryKey, "Bluetooth", -1);
            rg = new RegistryState(registryKey, registryValueName);
            rg.Changed += new ChangeEventHandler(bluetooth_Changed);

            progressBar1.Value = 3;
            //LA CREACION DE LA BD NO SE DEBE EJECUTAR EN LA VERSIÓN FINAL
            Invoke(myDelegate, new Object[] { "Generating DB." });
            BD basededatos = new BD(this);
            progressBar1.Value = 4;
               /* if (basededatos.crearTablas())//comentar inserts en crear tablas.
            {
                basededatos.creaActualizaBD();
            }*/

            //if (basededatos.crearBD())
                if (basededatos.crearTablas())
                {
                    progressBar1.Value = 5;
                    Server Servidor = new Server(this);//, 9050);
                    Cliente Cliente1 = new Cliente(this, "9050");
                    string hostName = Dns.GetHostName();
                    progressBar1.Value = 6;
                    IPHostEntry thisHost = Dns.GetHostEntry(hostName);
                    labelPseu.Text = basededatos.recuperamyPseu();
                    labelIP.Text = thisHost.AddressList[0].ToString();
                    labelPseu.Text = basededatos.recuperamyPseu();
                    Thread hiloCliente = new Thread(new ThreadStart(Cliente1.beacon));
                    hiloCliente.Start();
                    progressBar1.Value = 7;
                    DetectaIncidente VigilaCarretera = new DetectaIncidente(this);
                    VigilaCarretera.DetectaIncidenteStart();
                    VigilaCarretera.posibleparking();
                    progressBar1.Value = 8;
                    /*Prueba VigilaCarretera = new Prueba(this);
                    VigilaCarretera.DetectaIncidenteStart();*/
                }
                progressBar1.Value = 0;
        }
Beispiel #2
0
        //Iniciamos aplicacion
        private void Play_Click(object sender, EventArgs e)
        {
            progressBar1.Maximum = 7;
            progressBar1.Value = 1;
            cerrar = false;
            Invoke(myDelegate, new Object[] { "Loading... Please Wait." });
            Play.Enabled = false;//DESABILITO PLAY
            Play.Visible = false;

            //Habilitamos hardware
            Hardware detect = new Hardware();
            if (detect.BluetoothOn())//habilita bluetooth
                Invoke(myDelegate, new Object[] { "Enabled Bluetooth successfully." });
            if (detect.WifiOn())// habilita wifi
                Invoke(myDelegate, new Object[] { "Enabled Wifi successfully." });
            if (detect.conectawifi("vaipho"))//conecta a la red vaipho
                Invoke(myDelegate, new Object[] { "VAiPho conected successfully." });
            progressBar1.Value = 2;
            //Si el manos libres del coche se apaga, VAiPho se apagará también (para evitar atascos inexistentes)
            int key = (int)Registry.GetValue(registryKey, "Bluetooth", -1);
            rg = new RegistryState(registryKey, registryValueName);
            rg.Changed += new ChangeEventHandler(bluetooth_Changed);
            progressBar1.Value = 3;

            //LA CREACION DE LA BD NO SE DEBE EJECUTAR EN LA VERSIÓN FINAL
            Invoke(myDelegate, new Object[] { "Generating DB." });
            BD basededatos = new BD(this);
            //if (basededatos.crearBD())
                if (basededatos.crearTablas())
                {
                    progressBar1.Value = 4;
                    Server Servidor = new Server(this);//, 9050);
                    Cliente Cliente1 = new Cliente(this, "9050");

                    progressBar1.Value = 5;
                    string hostName = Dns.GetHostName();
                    IPHostEntry thisHost = Dns.GetHostEntry(hostName);
                    labelIP.Text = thisHost.AddressList[0].ToString();
                    labelPseu.Text = basededatos.recuperamyPseu();
                    Thread hiloCliente = new Thread(new ThreadStart(Cliente1.beacon));
                    hiloCliente.Start();
                    progressBar1.Value = 6;
                    DetectaIncidente VigilaCarretera = new DetectaIncidente(this);//Aquí dentro se lleva a cabo todo lo de detectarIncidentes
                    VigilaCarretera.DetectaIncidenteStart();
                    //VigilaCarretera.posibleparking();//señala un posible aparcamiento(al encenderse el servicio, no en el play)
                    progressBar1.Value = 7;
                    /*Prueba VigilaCarretera = new Prueba(this);
                    VigilaCarretera.DetectaIncidenteStart();*/
                }
                progressBar1.Value = 0;
        }
Beispiel #3
0
        //Cerramos aplicación y GPS
        private void cerrandoAplicacion()
        {
            try
            {
                cerrar = true;
                Cliente cierracliente = new Cliente(this, "9050");//,"127.0.0.1","bye");
                cierracliente.respuesta("01", Server.myPseudonimo, "-", "127.0.0.1");//,
                 string _appFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                 string dirSonido = _appFolder + @"\Sounds\apagando.wav";
                dirSonido = "\\Tarjeta de almacenamiento\\FLEET_MOBILE_14d\\MisSonidos\\apagando.wav";//parking.wav";

                WSounds ws = new WSounds();
                ws.Play(dirSonido, ws.SND_FILENAME | ws.SND_ASYNC);

                DriveHandler.EndApplication(0);
                DriveHandler.CloseApi();
                Hardware detect = new Hardware();
                detect.WifiOff();

            }
            catch
            {
                //    Formulario.Invoke(Formulario.myDelegate, new Object[] { "Error software GPS: " + e.Message });
            }
        }