/*******************************/ private void Form1_Load(object sender, EventArgs e) { if (frmMapPoint == null) { frmMapPoint = new frmMapPoint(); frmMapPoint.mainFrm = this; frmMapPoint.Show(); frmMapPoint.loadMap(); } if (frmSatelliteMap == null) { frmSatelliteMap = new frmMap(); frmSatelliteMap.satelliteMap.Navigate(@AppDomain.CurrentDomain.BaseDirectory + "map.htm"); frmSatelliteMap.satelliteMap.Document.InvokeScript("SetMapStyle", new object[] { "VEMapStyle.Hybrid" }); //frmSatelliteMap.Show(); } if (frmAllarm == null) { frmAllarm = new frmAllarm(); frmAllarm.mainFrm = this; frmAllarm.Show(); } port = null; receiveNow = new AutoResetEvent(false); if (CommSetting.comm != null && CommSetting.comm.IsOpen()) { CommSetting.comm.Close(); CommSetting.comm = null; } if (loadOptions()) { try { this.portf = OpenPort("COM" + COM_PORT); Cursor.Current = Cursors.WaitCursor; // Check connection try { ExecCommand("AT", 300, "No phone connected at COM" + COM_PORT + "."); } catch { string command = " " + char.ConvertFromUtf32(26) + "\r"; ExecCommand(command, 3000, "Failed to send message"); //3 seconds ExecCommand("AT", 300, "No phone connected"); } // Use message format "Text mode" ExecCommand("AT+CMGF=1", 300, "Failed to set message format."); // Use character set "ISO 8859-1" ExecCommand("AT+CSCS=\"8859-1\"", 300, "Failed to set character set."); // Select SIM storage ExecCommand("AT+CPMS=\"SM\"", 300, "Failed to select message storage."); //sendMsg("3486526983", "Messaggio di prova"); } catch(Exception ex) { Output(ex.Message); } } else { options opt = new options(); opt.mainFrm = this; loadOptions(); opt.textBox1.Text = COM_PORT; opt.textBox2.Text = COM_SPEED; opt.textBox3.Text = COM_TIMEOUT; opt.textBox4.Text = SMS_C; opt.ShowDialog(); try { this.portf = OpenPort("COM" + COM_PORT); Cursor.Current = Cursors.WaitCursor; // Check connection ExecCommand("AT", 300, "No phone connected at " + "COM20" + "."); // Use message format "Text mode" ExecCommand("AT+CMGF=1", 300, "Failed to set message format."); // Use character set "ISO 8859-1" ExecCommand("AT+CSCS=\"8859-1\"", 300, "Failed to set character set."); // Select SIM storage ExecCommand("AT+CPMS=\"SM\"", 300, "Failed to select message storage."); // sendMsg("+393486526983", "Messaggio di prova"); } catch { } } port = new SerialCOMPort(); loadDevices(); //Carica i dispositivi da file StopRcvSMS = false; StartSend = false; Thread smsRcv = new Thread(checkSMS); smsRcv.Start(); Thread listen = new Thread(listenClient); listen.Start(); updateConnectionString(); }
private void classicaToolStripMenuItem_Click(object sender, EventArgs e) { if (frmSatelliteMap != null) if (frmSatelliteMap.Visible == true) frmSatelliteMap.Visible = false; if (frmMapPoint != null) { try { if (frmMapPoint.Visible == false) { frmMapPoint.Visible = true; frmMapPoint.loadMap(); } } catch { frmMapPoint = new frmMapPoint(); frmMapPoint.mainFrm = this; frmMapPoint.Show(); frmMapPoint.loadMap(); } } }