Added System.Device.Location GeoCoordinate event for Updated Location

This commit is contained in:
2022-04-30 10:55:10 -05:00
parent b432db6af7
commit 13165a156a
3 changed files with 32 additions and 1 deletions

View File

@@ -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
};
}
}
}

View File

@@ -20,8 +20,12 @@ namespace KollNet.Lib {
#region "Public Events" #region "Public Events"
internal static void OnSatellitesUpdated(SatellitesUpdatedEventArgs e) { SatellitesUpdated?.Invoke(null, e); } internal static void OnSatellitesUpdated(SatellitesUpdatedEventArgs e) { SatellitesUpdated?.Invoke(null, e); }
public static event EventHandler<SatellitesUpdatedEventArgs> SatellitesUpdated; public static event EventHandler<SatellitesUpdatedEventArgs> 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<GpsCoordinatesChangedEventArgs> PositionChanged; public static event EventHandler<GpsCoordinatesChangedEventArgs> PositionChanged;
public static event EventHandler<GeoCoordinatesChangedEventArgs> GeoPositionChanged;
internal static void OnConnected() { Connected?.Invoke(null, EventArgs.Empty); } internal static void OnConnected() { Connected?.Invoke(null, EventArgs.Empty); }
public static event EventHandler Connected; public static event EventHandler Connected;
internal static void OnDisconnected() { Disconnected?.Invoke(null, EventArgs.Empty); } internal static void OnDisconnected() { Disconnected?.Invoke(null, EventArgs.Empty); }

View File

@@ -33,6 +33,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Device" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@@ -41,6 +42,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="EventArguments\GeoCoordinatesChangedEventArgs.cs" />
<Compile Include="EventArguments\GpsCoordinatesChangedEventArgs.cs" /> <Compile Include="EventArguments\GpsCoordinatesChangedEventArgs.cs" />
<Compile Include="EventArguments\NmeaReceivedEventArgs.cs" /> <Compile Include="EventArguments\NmeaReceivedEventArgs.cs" />
<Compile Include="EventArguments\SatellitesUpdatedEventArgs.cs" /> <Compile Include="EventArguments\SatellitesUpdatedEventArgs.cs" />