From 13165a156ae5ccaa0f243f097b7353edf2c9a443 Mon Sep 17 00:00:00 2001 From: Russ Kollmansberger Date: Sat, 30 Apr 2022 10:55:10 -0500 Subject: [PATCH] Added System.Device.Location GeoCoordinate event for Updated Location --- .../GeoCoordinatesChangedEventArgs.cs | 25 +++++++++++++++++++ GpsClient/GpsClient.cs | 6 ++++- GpsClient/GpsClient.csproj | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 GpsClient/EventArguments/GeoCoordinatesChangedEventArgs.cs diff --git a/GpsClient/EventArguments/GeoCoordinatesChangedEventArgs.cs b/GpsClient/EventArguments/GeoCoordinatesChangedEventArgs.cs new file mode 100644 index 0000000..8dbd5ad --- /dev/null +++ b/GpsClient/EventArguments/GeoCoordinatesChangedEventArgs.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Device.Location; +using KollNet.Lib.Models; + +namespace KollNet.Lib.EventArguments { + public class GeoCoordinatesChangedEventArgs : EventArgs { + public GeoCoordinate Coordinate { get; set; } + + public GeoCoordinatesChangedEventArgs() { } + public GeoCoordinatesChangedEventArgs(GeoCoordinate gc) { Coordinate = gc; } + public GeoCoordinatesChangedEventArgs(GpsCoordinates gc) { + Coordinate = new GeoCoordinate() { + Latitude = gc.Latitude, + Longitude = gc.Longitude, + Speed = gc.Speed, + Course = gc.Course, + Altitude = gc.Altitude + }; + } + } +} diff --git a/GpsClient/GpsClient.cs b/GpsClient/GpsClient.cs index 890b47e..6f96ba9 100644 --- a/GpsClient/GpsClient.cs +++ b/GpsClient/GpsClient.cs @@ -20,8 +20,12 @@ namespace KollNet.Lib { #region "Public Events" internal static void OnSatellitesUpdated(SatellitesUpdatedEventArgs e) { SatellitesUpdated?.Invoke(null, e); } public static event EventHandler SatellitesUpdated; - internal static void OnPositionChanged(GpsCoordinatesChangedEventArgs e) { PositionChanged?.Invoke(null, e); } + internal static void OnPositionChanged(GpsCoordinatesChangedEventArgs e) { + PositionChanged?.Invoke(null, e); + GeoPositionChanged?.Invoke(null, new GeoCoordinatesChangedEventArgs(e.Coordinates)); + } public static event EventHandler PositionChanged; + public static event EventHandler GeoPositionChanged; internal static void OnConnected() { Connected?.Invoke(null, EventArgs.Empty); } public static event EventHandler Connected; internal static void OnDisconnected() { Disconnected?.Invoke(null, EventArgs.Empty); } diff --git a/GpsClient/GpsClient.csproj b/GpsClient/GpsClient.csproj index 502fa5c..1c11b39 100644 --- a/GpsClient/GpsClient.csproj +++ b/GpsClient/GpsClient.csproj @@ -33,6 +33,7 @@ + @@ -41,6 +42,7 @@ +