示例#1
0
 /// <summary>Raises the <see cref="Satellite"/> event</summary>
 /// <param name="e">Event arguments</param>
 protected virtual void OnSatellite(GpsSatelliteEventArgs e)
 {
     if (Satellite != null)
     {
         Satellite(this, e);
     }
 }
示例#2
0
        private void GpsSatellite(GpsProvider sender, GpsSatelliteEventArgs e)
        {
            //Don't want the form to lock up if nothing's happening.
            System.Threading.Thread.Sleep(200);
            if (this.IsDisposed) return;
            if (InvokeRequired)
            {
                if ((DateTime.Now - lastGpsSatellite).TotalMilliseconds < 200)
                {
                    return;
                }

                BeginInvoke(new GpsSatelliteEventHandler(GpsSatellite), sender, e);
                return;
            }

            lastGpsSatellite = DateTime.Now;

            List<GpsSatellite> satl = new List<GpsSatellite>();
            foreach (GpsSatellite sat in e.Satellites)
            {
                if (sat.ID != 0)
                {
                    satl.Add(sat);
                }
            }

            if ((lblId == null) || (lblId.Length != satl.Count))
            {
                CreateLabels(satl.Count);
            }

            int i = 0;
            lvwSatellites.Items.Clear();
            foreach (var sat in satl)
            {
                lblId[i].Text = sat.ID.ToString();
                lblSnr[i].Tag = sat.SignalToNoiseRatio;
                lblSnr[i].Text = sat.SignalToNoiseRatio.ToString();
                lblSnr[i].BackColor = GetColorFromSnr(sat.SignalToNoiseRatio, sat.Active);
                lblSnr[i].ForeColor = Color.FromArgb((byte)~lblSnr[i].BackColor.R, (byte)~lblSnr[i].BackColor.G, (byte)~lblSnr[i].BackColor.B);

                ListViewItem itm = new ListViewItem(new[]{
                    sat.ID.ToString(),
                    sat.SignalToNoiseRatio.ToString(),
                    sat.Active.ToString(),
                    sat.Azimuth.ToString(),
                    sat.Elevation.ToString()
                });
                lvwSatellites.Items.Add(itm);

                ++i;
            }

            PosLabels();
            satellites = satl;
            panPosition.Invalidate();
        }
示例#3
0
 /// <summary>Called when GPS device receives information about satellites</summary>
 /// <param name="sender">A GPS provider</param>
 /// <param name="e">Event arguments containing information about sattellites</param>
 private void GpsSatelliteEvent(GpsProvider sender, GpsSatelliteEventArgs e)
 {
     if (statistic == null && InvokeRequired)
     {
         BeginInvoke(new GpsSatelliteEventHandler(GpsSatelliteEvent), sender, e);
         return;
     }
     int cnt = 0;
     foreach (GpsSatellite sat in e.Satellites)
     {
         if (sat.SignalToNoiseRatio != 0)
         {
             ++cnt;
         }
     }
     if (statistic != null)
     {
         statistic.CurrentSats = cnt;
     }
     else
     {
         lblSatellites.Text = cnt.ToString();
     }
 }
示例#4
0
 /// <summary>Raises the <see cref="Satellite"/> event</summary>
 /// <param name="e">Event arguments</param>
 protected virtual void OnSatellite(GpsSatelliteEventArgs e)
 {
     if (Satellite != null) Satellite(this, e);
 }