Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1.         /// <summary>
  2.         /// Create the window
  3.         /// </summary>
  4.         public MainWindow()
  5.         {
  6.             // Create a new window and apply the necessary properties
  7.             this.Height = SystemMetrics.ScreenHeight;
  8.             this.Width = SystemMetrics.ScreenWidth;
  9.             this.Background = new SolidColorBrush(Colors.Black);
  10.  
  11.             // Create a new stack panel, set margins, and bind it to the window
  12.             Stack = new StackPanel(Orientation.Vertical);
  13.             this.Child = Stack;
  14.  
  15.             GPS = new MicroGPS("COM1", 9600);
  16.             GPS.GPSUpdate += new GPSUpdateDelegate(GPS_GPSUpdate);
  17.  
  18.             InitLabel(ref Fix, "Waiting for GPS data");
  19.             InitLabel(ref Lat, "Lat: --");
  20.             InitLabel(ref Lon, "Lon: --");
  21.            
  22.             this.Visibility = Visibility.Visible;
  23.         }
  24.  
  25.         void  GPS_GPSUpdate(RMCOutput rmc)
  26.         {
  27.             this.RootUIElement.Dispatcher.Invoke(new TimeSpan(0, 0, 0), DoUIGPSUpdate, rmc);
  28.         }
  29.  
  30.         private void DoUIGPSUpdate(RMCOutput rmc)
  31.         {
  32.             switch (rmc.Fix)
  33.             {
  34.                 case FixType.Active:
  35.                     Fix.TextContent = "Fix Active";
  36.                     break;
  37.  
  38.                 case FixType.Unknown:
  39.                 case FixType.Void:
  40.                     Fix.TextContent = "No Fix";
  41.                     break;
  42.             }
  43.  
  44.             Lat.TextContent = "Lat: " + rmc.Coords.Latitude.ToString();
  45.             Lat.TextContent = "Lon: " + rmc.Coords.Longitude.ToString();
  46.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement