public GPSGeoFenceMsgBox(bool bIn, GPSGeoFenceData geoFence, GPSSource gpsSource) { m_bIn = bIn; m_GeoFence = geoFence; m_GpsSource = gpsSource; InitializeComponent(); pictureBoxGeoFence.ImageLocation = m_GpsSource.sIconPath; labelMessage.Text = m_GpsSource.sDescription + " is "; if (bIn) labelMessage.Text += "inside "; else labelMessage.Text += "outside "; labelMessage.Text += "GeoFence Zone " + geoFence.sName; labelLatitude.Text = ""; labelLongitude.Text = ""; string sLocation = ""; string sNS; if (m_GpsSource.GpsPos.m_fLat >= (float)0) sNS = "N"; else sNS = "S"; double dLat = Math.Abs(m_GpsSource.GpsPos.m_fLat); double dWhole = Math.Floor(dLat); double dFraction = dLat - dWhole; double dMin = dFraction * (double)60; double dMinWhole = Math.Floor(dMin); double dSeconds = (dMin - dMinWhole) * (double)60; int iDegrees = Convert.ToInt32(dWhole); int iMinutes = Convert.ToInt32(dMinWhole); float fSeconds = Convert.ToSingle(dSeconds); sLocation = Convert.ToString(iDegrees) + "°" + Convert.ToString(iMinutes) + "'" + Convert.ToString(fSeconds) + "\" " + sNS; labelLatitude.Text = sLocation; string sEW; if (m_GpsSource.GpsPos.m_fLon >= (float)0) sEW = "E"; else sEW = "W"; double dLon = Math.Abs(m_GpsSource.GpsPos.m_fLon); dWhole = Math.Floor(dLon); dFraction = dLon - dWhole; dMin = dFraction * (double)60; dMinWhole = Math.Floor(dMin); dSeconds = (dMin - dMinWhole) * (double)60; iDegrees = Convert.ToInt32(dWhole); iMinutes = Convert.ToInt32(dMinWhole); fSeconds = Convert.ToSingle(dSeconds); sLocation = Convert.ToString(iDegrees) + "°" + Convert.ToString(iMinutes) + "'" + Convert.ToString(fSeconds) + "\" " + sEW; labelLongitude.Text = sLocation; labelTime.Text = DateTime.Now.ToString(); Thread threadMsg = new Thread(new ThreadStart(this.threadShowMsg)); threadMsg.IsBackground = true; threadMsg.Priority = System.Threading.ThreadPriority.Normal; threadMsg.Start(); }
public GPSSource() { GpsPos = new GPSPositionVariables(); GeoFence = new GPSGeoFenceData(); GeoFence.arrayLat = new ArrayList(); GeoFence.arrayLon = new ArrayList(); GeoFence.SourcesIn = new ArrayList(); GeoFence.SourcesOut = new ArrayList(); GeoFence.sEmail = ""; GeoFence.sName = ""; GeoFence.sSound = GpsTrackerPlugin.m_sPluginDirectory + "\\GeoFence.wav"; GeoFence.sSoundOut = GpsTrackerPlugin.m_sPluginDirectory + "\\GeoFenceOut.wav"; GeoFence.bEmailIn = false; GeoFence.bEmailOut = false; GeoFence.bMsgBoxIn = false; GeoFence.bMsgBoxOut = false; GeoFence.bSoundIn = true; GeoFence.bSoundOut = true; }
public GPSGeoFenceMsgBox(bool bIn, GPSGeoFenceData geoFence, GPSSource gpsSource) { m_bIn = bIn; m_GeoFence = geoFence; m_GpsSource = gpsSource; InitializeComponent(); pictureBoxGeoFence.ImageLocation = m_GpsSource.sIconPath; labelMessage.Text = m_GpsSource.sDescription + " is "; if (bIn) { labelMessage.Text += "inside "; } else { labelMessage.Text += "outside "; } labelMessage.Text += "GeoFence Zone " + geoFence.sName; labelLatitude.Text = ""; labelLongitude.Text = ""; string sLocation = ""; string sNS; if (m_GpsSource.GpsPos.m_fLat >= (float)0) { sNS = "N"; } else { sNS = "S"; } double dLat = Math.Abs(m_GpsSource.GpsPos.m_fLat); double dWhole = Math.Floor(dLat); double dFraction = dLat - dWhole; double dMin = dFraction * (double)60; double dMinWhole = Math.Floor(dMin); double dSeconds = (dMin - dMinWhole) * (double)60; int iDegrees = Convert.ToInt32(dWhole); int iMinutes = Convert.ToInt32(dMinWhole); float fSeconds = Convert.ToSingle(dSeconds); sLocation = Convert.ToString(iDegrees) + "?" + Convert.ToString(iMinutes) + "'" + Convert.ToString(fSeconds) + "\" " + sNS; labelLatitude.Text = sLocation; string sEW; if (m_GpsSource.GpsPos.m_fLon >= (float)0) { sEW = "E"; } else { sEW = "W"; } double dLon = Math.Abs(m_GpsSource.GpsPos.m_fLon); dWhole = Math.Floor(dLon); dFraction = dLon - dWhole; dMin = dFraction * (double)60; dMinWhole = Math.Floor(dMin); dSeconds = (dMin - dMinWhole) * (double)60; iDegrees = Convert.ToInt32(dWhole); iMinutes = Convert.ToInt32(dMinWhole); fSeconds = Convert.ToSingle(dSeconds); sLocation = Convert.ToString(iDegrees) + "?" + Convert.ToString(iMinutes) + "'" + Convert.ToString(fSeconds) + "\" " + sEW; labelLongitude.Text = sLocation; labelTime.Text = DateTime.Now.ToString(); Thread threadMsg = new Thread(new ThreadStart(this.threadShowMsg)); threadMsg.IsBackground = true; threadMsg.Priority = System.Threading.ThreadPriority.Normal; threadMsg.Start(); }
public void AddGeoFence(GPSGeoFenceData geoFence) { lock ("RenderAccess") { //Resize array if necessary if (m_iGpsGeoFenceIndex >= m_uGeoFenceResize) { m_uGeoFenceResize += 5; Array.Resize(ref m_gpsGeoFence, (int)m_uGeoFenceResize); } if (m_gpsGeoFence[m_iGpsGeoFenceIndex] == null) { m_gpsGeoFence[m_iGpsGeoFenceIndex] = new GPSGeoFence(ParentApplication.WorldWindow.CurrentWorld, "New Geo Fence", Plugin); m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bDone = false; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sDescription = geoFence.sName; m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLat = (ArrayList)geoFence.arrayLat.Clone(); m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLat.Add(m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLat[0]); m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLon = (ArrayList)geoFence.arrayLon.Clone(); m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLon.Add(m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLon[0]); m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sEmail = geoFence.sEmail; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bEmailIn = geoFence.bEmailIn; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bEmailOut = geoFence.bEmailOut; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sSound = geoFence.sSound; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sSoundOut = geoFence.sSoundOut; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bSoundIn = geoFence.bSoundIn; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bSoundOut = geoFence.bSoundOut; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bMsgBoxIn = geoFence.bMsgBoxIn; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bMsgBoxOut = geoFence.bMsgBoxOut; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bShowInfo = geoFence.bShowInfo; m_gpsGeoFence[m_iGpsGeoFenceIndex].Initialize(this.drawArgs); Add(m_gpsGeoFence[m_iGpsGeoFenceIndex]); m_iGpsGeoFenceIndex++; } } }
/// <summary> /// Handle mouse click /// </summary> public override bool PerformSelectionAction(DrawArgs drawArgs) { Point pLastMousePoint = DrawArgs.LastMousePosition; foreach(RenderableObject ro in ChildObjects) { if(!ro.IsOn || !ro.isSelectable) continue; if (ro.PerformSelectionAction(drawArgs)) return true; } byte [] pbKeyState = new byte[256]; GetKeyboardState(pbKeyState); if ((pbKeyState[VK_LSHIFT] & 0x80)==0x80) { Angle StartLatitude; Angle StartLongitude; drawArgs.WorldCamera.PickingRayIntersection( pLastMousePoint.X, pLastMousePoint.Y, out StartLatitude, out StartLongitude); if (!double.IsNaN(StartLatitude.Degrees) && !double.IsNaN(StartLongitude.Degrees)) { POIName poiName = new POIName(this); m_sPOIName=""; poiName.ShowDialog(); poiName.Dispose(); Plugin.pluginAddPOI(m_sPOIName, (float)StartLatitude.Degrees, (float)StartLongitude.Degrees); } } else if ((pbKeyState[VK_LALT] & 0x80) == 0x80) { lock ("RenderAccess") { //Resize array if necessary if (m_iGpsGeoFenceIndex >= m_uGeoFenceResize) { m_uGeoFenceResize += 5; Array.Resize(ref m_gpsGeoFence, (int)m_uGeoFenceResize); } if (m_gpsGeoFence[m_iGpsGeoFenceIndex]==null) { m_gpsGeoFence[m_iGpsGeoFenceIndex] = new GPSGeoFence(ParentApplication.WorldWindow.CurrentWorld, "New Geo Fence", Plugin); m_gpsGeoFence[m_iGpsGeoFenceIndex].Initialize(this.drawArgs); m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bDone = false; m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bShowInfo = true; Add(m_gpsGeoFence[m_iGpsGeoFenceIndex]); } m_gpsGeoFence[m_iGpsGeoFenceIndex].AddGeoFence(drawArgs, pLastMousePoint); if (m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bDone && m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bCancel == false) { GPSGeoFenceData geoFence = new GPSGeoFenceData(); geoFence.sName = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sDescription; geoFence.sSource = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sSource; geoFence.arrayLat = m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLat; geoFence.arrayLon = m_gpsGeoFence[m_iGpsGeoFenceIndex].arrayLon; geoFence.sEmail = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sEmail; geoFence.sSound = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sSound; geoFence.sSoundOut = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_sSoundOut; geoFence.bEmailIn = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bEmailIn; geoFence.bEmailOut = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bEmailOut; geoFence.bSoundIn = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bSoundIn; geoFence.bSoundOut = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bSoundOut; geoFence.bMsgBoxIn = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bMsgBoxIn; geoFence.bMsgBoxOut = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bMsgBoxOut; geoFence.bShowInfo = m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bShowInfo; geoFence.SourcesIn = new ArrayList(); geoFence.SourcesOut = new ArrayList(); Plugin.pluginAddGeoFenceToGpsTracker(geoFence); m_iGpsGeoFenceIndex++; } else if (m_gpsGeoFence[m_iGpsGeoFenceIndex].m_bCancel) { Remove(m_gpsGeoFence[m_iGpsGeoFenceIndex]); m_gpsGeoFence[m_iGpsGeoFenceIndex].Dispose(); m_gpsGeoFence[m_iGpsGeoFenceIndex] = null; } } } return false; }
public void pluginAddGeoFenceToGpsTracker(GPSGeoFenceData geoFence) { gpsTracker.AddGeoFence(geoFence); }
public void pluginAddGeoFence(GPSGeoFenceData geoFence) { gpsOverlay.AddGeoFence(geoFence); }
public void AddGeoFence(GPSGeoFenceData geoFence) { lock ("GeoFenceAccess") { m_bHandleControlValueChangeEvent = false; GPSSource gpsSource = new GPSSource(); TreeNode treeNode; gpsSource.sType = "GeoFence"; gpsSource.sDescription = geoFence.sName; gpsSource.GeoFence = geoFence; gpsSource.iNameIndex = GetAvailableIndex(); gpsSource.bSave = true; gpsSource.bTrack = false; gpsSource.bSetup = true; gpsSource.bNeedApply = false; treeNode = new TreeNode(gpsSource.sDescription); treeNode.ImageIndex = 1; treeNode.SelectedImageIndex = 1; treeNode.Tag = gpsSource; gpsSource.treeNode = treeNode; m_gpsSourceList.Add(gpsSource); m_treeNodeGeoFence.Nodes.Add(treeNode); m_treeNodeGeoFence.ExpandAll(); listViewGeoFence.Items.Clear(); for (int i = 0; i < 100; i++) { ListViewItem lvItem = new ListViewItem(); lvItem.Text = Convert.ToString(i); lvItem.SubItems.Add(""); lvItem.SubItems.Add(""); listViewGeoFence.Items.Add(lvItem); } for (int i = 0; i < gpsSource.GeoFence.arrayLat.Count; i++) { listViewGeoFence.Items[i].SubItems[1].Text = Convert.ToString(gpsSource.GeoFence.arrayLat[i]); listViewGeoFence.Items[i].SubItems[2].Text = Convert.ToString(gpsSource.GeoFence.arrayLon[i]); } //textBoxGeoFenceName.Text = geoFence.sName; textBoxEmailAddress.Text = geoFence.sEmail; textBoxSoundFile.Text = geoFence.sSound; textBoxSoundFileOut.Text = geoFence.sSoundOut; checkBoxGeoFenceEmailIn.Checked = geoFence.bEmailIn; checkBoxGeoFenceEmailOut.Checked = geoFence.bEmailOut; checkBoxGeoFenceMsgBoxIn.Checked = geoFence.bMsgBoxIn; checkBoxGeoFenceMsgBoxOut.Checked = geoFence.bMsgBoxOut; checkBoxGeoFenceSoundIn.Checked = geoFence.bSoundIn; checkBoxGeoFenceSoundOut.Checked = geoFence.bSoundOut; comboBoxGeoFenceSource.Items.Clear(); comboBoxGeoFenceSource.Items.Add("All Gps Sources"); for (int i = 0; i < m_gpsSourceList.Count; i++) { GPSSource gpsSourceFence = (GPSSource)m_gpsSourceList[i]; if (gpsSourceFence.sType != "POI" && gpsSourceFence.sType != "GeoFence" && gpsSourceFence.bWaypoints == false && gpsSourceFence.bSetup) comboBoxGeoFenceSource.Items.Add(gpsSourceFence.sDescription); } comboBoxGeoFenceSource.Text = "All Gps Sources"; comboBoxGeoFenceSource.Text = geoFence.sSource; labelGeoFenceSelectedSource.Text = geoFence.sSource; ApplySettings(gpsSource, true, false, true); m_iSourceNameCount++; m_bHandleControlValueChangeEvent = true; } }
void SignalGeoFence(bool bIn, GPSGeoFenceData geoFence, GPSSource gpsSource) { string sBody = ""; string sSubject = ""; try { if (bIn) //Signal In { //Audio if (geoFence.bSoundIn && geoFence.sSound != "") { System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer(); soundPlayer.SoundLocation = geoFence.sSound; soundPlayer.Play(); } //MessageBox if (geoFence.bMsgBoxIn) { GPSGeoFenceMsgBox geoFenceMsgBox = new GPSGeoFenceMsgBox(bIn, geoFence, gpsSource); } } else //Signal Out { //Audio if (geoFence.bSoundOut && geoFence.sSoundOut != "") { System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer(); soundPlayer.SoundLocation = geoFence.sSoundOut; soundPlayer.Play(); } //MessageBox if (geoFence.bMsgBoxOut) { GPSGeoFenceMsgBox geoFenceMsgBox = new GPSGeoFenceMsgBox(bIn, geoFence, gpsSource); } } if (((geoFence.bEmailIn && bIn) || (geoFence.bEmailOut && !bIn)) && geoFence.sEmail != "" && textBoxEmailServer.Text!="" && textBoxEmailFrom.Text!="") { sSubject = "GpsTracker :: GeoFence detected message"; sBody = gpsSource.sDescription + " is "; if (bIn) sBody += "inside "; else sBody += "outside "; sBody += "GeoFence Zone " + geoFence.sName; sBody += "\r\n\r\n"; sBody += "Location:\r\n"; string sLocation = ""; string sNS; if (gpsSource.GpsPos.m_fLat >= (float)0) sNS = "N"; else sNS = "S"; double dLat = Math.Abs(gpsSource.GpsPos.m_fLat); double dWhole = Math.Floor(dLat); double dFraction = dLat - dWhole; double dMin = dFraction * (double)60; double dMinWhole = Math.Floor(dMin); double dSeconds = (dMin - dMinWhole) * (double)60; int iDegrees = Convert.ToInt32(dWhole); int iMinutes = Convert.ToInt32(dMinWhole); float fSeconds = Convert.ToSingle(dSeconds); sLocation = Convert.ToString(iDegrees) + "°" + Convert.ToString(iMinutes) + "'" + Convert.ToString(fSeconds) + "\" " + sNS; sBody+= "Latitude: " + sLocation + "\r\n"; string sEW; if (gpsSource.GpsPos.m_fLon >= (float)0) sEW = "E"; else sEW = "W"; double dLon = Math.Abs(gpsSource.GpsPos.m_fLon); dWhole = Math.Floor(dLon); dFraction = dLon - dWhole; dMin = dFraction * (double)60; dMinWhole = Math.Floor(dMin); dSeconds = (dMin - dMinWhole) * (double)60; iDegrees = Convert.ToInt32(dWhole); iMinutes = Convert.ToInt32(dMinWhole); fSeconds = Convert.ToSingle(dSeconds); sLocation = Convert.ToString(iDegrees) + "°" + Convert.ToString(iMinutes) + "'" + Convert.ToString(fSeconds) + "\" " + sEW; sBody+= "Longitude: " + sLocation + "\r\n\r\n"; sBody+= "Date and Time: " + DateTime.Now.ToString() + "\r\n"; // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient(textBoxEmailServer.Text.Trim()); // Specify the e-mail sender. // Create a mailing address that includes a UTF8 character // in the display name. MailAddress from = new MailAddress(textBoxEmailFrom.Text.Trim(), textBoxEmailFrom.Text.Trim(), System.Text.Encoding.UTF8); // Set destinations for the e-mail message. MailAddress to = new MailAddress(geoFence.sEmail.Trim()); // Specify the message content. MailMessage message = new MailMessage(from, to); message.Body = sBody; message.BodyEncoding = System.Text.Encoding.UTF8; message.Subject = sSubject; message.SubjectEncoding = System.Text.Encoding.UTF8; client.UseDefaultCredentials = true; client.Send(message); // Clean up. message.Dispose(); client = null; } } catch (Exception) { } }
public GPSSource() { GpsPos = new GPSPositionVariables(); GeoFence = new GPSGeoFenceData(); GeoFence.arrayLat = new ArrayList(); GeoFence.arrayLon = new ArrayList(); GeoFence.SourcesIn = new ArrayList(); GeoFence.SourcesOut = new ArrayList(); GeoFence.sEmail = ""; GeoFence.sName = ""; GeoFence.sSound = GpsTrackerPlugin.m_sPluginDirectory + "\\GeoFence.wav"; GeoFence.sSoundOut = GpsTrackerPlugin.m_sPluginDirectory + "\\GeoFenceOut.wav"; GeoFence.bEmailIn=false; GeoFence.bEmailOut=false; GeoFence.bMsgBoxIn=false; GeoFence.bMsgBoxOut=false; GeoFence.bSoundIn=true; GeoFence.bSoundOut=true; }