Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Create the window
- /// </summary>
- public MainWindow()
- {
- // Create a new window and apply the necessary properties
- this.Height = SystemMetrics.ScreenHeight;
- this.Width = SystemMetrics.ScreenWidth;
- this.Background = new SolidColorBrush(Colors.Black);
- // Create a new stack panel, set margins, and bind it to the window
- Stack = new StackPanel(Orientation.Vertical);
- this.Child = Stack;
- GPS = new MicroGPS("COM1", 9600);
- GPS.GPSUpdate += new GPSUpdateDelegate(GPS_GPSUpdate);
- InitLabel(ref Fix, "Waiting for GPS data");
- InitLabel(ref Lat, "Lat: --");
- InitLabel(ref Lon, "Lon: --");
- this.Visibility = Visibility.Visible;
- }
- void GPS_GPSUpdate(RMCOutput rmc)
- {
- this.RootUIElement.Dispatcher.Invoke(new TimeSpan(0, 0, 0), DoUIGPSUpdate, rmc);
- }
- private void DoUIGPSUpdate(RMCOutput rmc)
- {
- switch (rmc.Fix)
- {
- case FixType.Active:
- Fix.TextContent = "Fix Active";
- break;
- case FixType.Unknown:
- case FixType.Void:
- Fix.TextContent = "No Fix";
- break;
- }
- Lat.TextContent = "Lat: " + rmc.Coords.Latitude.ToString();
- Lat.TextContent = "Lon: " + rmc.Coords.Longitude.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement