-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,303 additions
and
607 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace TRViS.Services; | ||
|
||
public interface ILocationLonLat_deg : IEquatable<ILocationLonLat_deg> | ||
{ | ||
bool HasLonLatLocation { get; } | ||
double Location_lon_deg { get; } | ||
double Location_lat_deg { get; } | ||
|
||
bool IEquatable<ILocationLonLat_deg>.Equals(ILocationLonLat_deg? other) | ||
{ | ||
if (other is null) | ||
return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
return true; | ||
|
||
return | ||
HasLonLatLocation == other.HasLonLatLocation | ||
&& | ||
Location_lon_deg == other.Location_lon_deg | ||
&& | ||
Location_lat_deg == other.Location_lat_deg | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
|
||
namespace TRViS.Services; | ||
|
||
public interface ILocationService | ||
{ | ||
bool IsEnabled { get; set; } | ||
bool CanUseService { get; } | ||
event EventHandler<bool>? CanUseServiceChanged; | ||
|
||
event EventHandler<LocationStateChangedEventArgs>? LocationStateChanged; | ||
|
||
StaLocationInfo[]? StaLocationInfo { get; set; } | ||
|
||
int CurrentStationIndex { get; } | ||
|
||
bool IsRunningToNextStation { get; } | ||
|
||
void ResetLocationInfo(); | ||
|
||
void ForceSetLocationInfo(int stationIndex, bool isRunningToNextStation); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
|
||
namespace TRViS.Services; | ||
|
||
public class LocationLonLat_deg : ILocationLonLat_deg, IEquatable<LocationLonLat_deg> | ||
{ | ||
public bool HasLonLatLocation { get; } | ||
public double Location_lon_deg { get; } | ||
public double Location_lat_deg { get; } | ||
|
||
public LocationLonLat_deg( | ||
double location_lon_deg, | ||
double location_lat_deg | ||
) | ||
{ | ||
Location_lon_deg = location_lon_deg; | ||
Location_lat_deg = location_lat_deg; | ||
HasLonLatLocation = true; | ||
} | ||
|
||
public bool Equals(LocationLonLat_deg? other) | ||
{ | ||
if (other is null) | ||
return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
return true; | ||
|
||
return | ||
((IEquatable<ILocationLonLat_deg>)this).Equals(other) | ||
&& | ||
Location_lon_deg == other.Location_lon_deg | ||
&& | ||
Location_lat_deg == other.Location_lat_deg | ||
; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
=> Equals(obj as LocationLonLat_deg); | ||
|
||
public override int GetHashCode() | ||
=> HashCode.Combine(Location_lon_deg, Location_lat_deg); | ||
|
||
public override string ToString() | ||
{ | ||
return $"{nameof(LocationLonLat_deg)} {{ lon:{Location_lon_deg}, lat:{Location_lat_deg} }}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
|
||
namespace TRViS.Services; | ||
|
||
public class LocationStateChangedEventArgs( | ||
int newStationIndex, | ||
bool isRunningToNextStation | ||
) : EventArgs, IEquatable<LocationStateChangedEventArgs> | ||
{ | ||
public int NewStationIndex { get; } = newStationIndex; | ||
public bool IsRunningToNextStation { get; } = isRunningToNextStation; | ||
|
||
public bool Equals(LocationStateChangedEventArgs? other) | ||
{ | ||
if (other is null) | ||
return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
return true; | ||
|
||
return | ||
NewStationIndex == other.NewStationIndex | ||
&& | ||
IsRunningToNextStation == other.IsRunningToNextStation | ||
; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
=> Equals(obj as LocationStateChangedEventArgs); | ||
|
||
public override int GetHashCode() | ||
=> HashCode.Combine(NewStationIndex, IsRunningToNextStation); | ||
|
||
public override string ToString() | ||
{ | ||
return $"{nameof(LocationStateChangedEventArgs)} {{ {nameof(NewStationIndex)}: {NewStationIndex}, {nameof(IsRunningToNextStation)}: {IsRunningToNextStation} }}"; | ||
} | ||
} |
71 changes: 2 additions & 69 deletions
71
TRViS.LocationService/StaLocationInfo.cs → TRViS.ILocationService/StaLocationInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<LangVersion>12.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.