From 82285c3f4198c11e095e12b3c7c4ae0824cca769 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Wed, 20 Dec 2023 12:32:15 +0000 Subject: [PATCH] Added support for my jobs distances Bumped version to 5.9 --- .../Converters/PayloadDistanceConverter.cs | 20 ++++++++++++++++++- OpenSky.Client/OpenAPIs/swagger.cs | 12 +++++++++++ OpenSky.Client/OpenAPIs/swagger.json | 12 +++++++++++ OpenSky.Client/Pages/MyJobs.xaml | 3 +++ OpenSky.Client/Pages/Notifications.xaml | 4 ++-- OpenSky.Client/Properties/AssemblyInfo.cs | 4 ++-- changelog.txt | 6 ++++++ 7 files changed, 56 insertions(+), 5 deletions(-) diff --git a/OpenSky.Client/Converters/PayloadDistanceConverter.cs b/OpenSky.Client/Converters/PayloadDistanceConverter.cs index 680fe40..0986f02 100644 --- a/OpenSky.Client/Converters/PayloadDistanceConverter.cs +++ b/OpenSky.Client/Converters/PayloadDistanceConverter.cs @@ -56,7 +56,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn { if (value is Payload payload) { - if (!string.IsNullOrWhiteSpace(payload.AirportICAO)) + if (!string.IsNullOrEmpty(payload.AirportICAO)) { var airportPackage = AirportPackageClientHandler.GetPackage(); var origin = airportPackage?.Airports.SingleOrDefault(a => a.ICAO == payload.AirportICAO); @@ -73,6 +73,24 @@ public object Convert(object value, Type targetType, object parameter, CultureIn return distance; } } + + if (!string.IsNullOrEmpty(payload.AircraftRegistry)) + { + var airportPackage = AirportPackageClientHandler.GetPackage(); + var destination = airportPackage?.Airports.SingleOrDefault(a => a.ICAO == payload.DestinationICAO); + + if (destination != null) + { + var distance = new GeoCoordinate(payload.AircraftLatitude ?? 0, payload.AircraftLongitude ?? 0).GetDistanceTo(new GeoCoordinate(destination.Latitude, destination.Longitude)) / 1852; + + if (targetType == typeof(string)) + { + return new SettingsUnitConverter().Convert(distance, typeof(string), "distance|F0|true", CultureInfo.CurrentCulture); + } + + return distance; + } + } } if (targetType == typeof(string)) diff --git a/OpenSky.Client/OpenAPIs/swagger.cs b/OpenSky.Client/OpenAPIs/swagger.cs index 61ad9e4..483b381 100644 --- a/OpenSky.Client/OpenAPIs/swagger.cs +++ b/OpenSky.Client/OpenAPIs/swagger.cs @@ -13698,6 +13698,18 @@ public enum OnlineNetwork [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")] public partial class Payload { + /// + /// Gets or sets the aircraft latitude (if currently loaded onto an aircraft). + /// + [Newtonsoft.Json.JsonProperty("aircraftLatitude", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public double? AircraftLatitude { get; set; } + + /// + /// Gets or sets the aircraft longitude (if currently loaded onto an aircraft). + /// + [Newtonsoft.Json.JsonProperty("aircraftLongitude", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public double? AircraftLongitude { get; set; } + /// /// Gets or sets the aircraft registry the payload is currently loaded on, or NULL if stored at an airport. /// diff --git a/OpenSky.Client/OpenAPIs/swagger.json b/OpenSky.Client/OpenAPIs/swagger.json index 5a0a624..2834461 100644 --- a/OpenSky.Client/OpenAPIs/swagger.json +++ b/OpenSky.Client/OpenAPIs/swagger.json @@ -8798,6 +8798,18 @@ ], "type": "object", "properties": { + "aircraftLatitude": { + "type": "number", + "description": "Gets or sets the aircraft latitude (if currently loaded onto an aircraft).", + "format": "double", + "nullable": true + }, + "aircraftLongitude": { + "type": "number", + "description": "Gets or sets the aircraft longitude (if currently loaded onto an aircraft).", + "format": "double", + "nullable": true + }, "aircraftRegistry": { "maxLength": 12, "minLength": 6, diff --git a/OpenSky.Client/Pages/MyJobs.xaml b/OpenSky.Client/Pages/MyJobs.xaml index 72c05e1..a20fcb5 100644 --- a/OpenSky.Client/Pages/MyJobs.xaml +++ b/OpenSky.Client/Pages/MyJobs.xaml @@ -35,6 +35,7 @@ + @@ -89,6 +90,7 @@ + @@ -99,6 +101,7 @@ > + diff --git a/OpenSky.Client/Pages/Notifications.xaml b/OpenSky.Client/Pages/Notifications.xaml index 34d0bbe..d029770 100644 --- a/OpenSky.Client/Pages/Notifications.xaml +++ b/OpenSky.Client/Pages/Notifications.xaml @@ -107,7 +107,7 @@ ItemsSource="{Binding Recipients}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" MinColumnWidth="80" HeadersVisibility="Column" Margin="30,20,0,40" - ColumnHeaderStyle="{StaticResource FilteredDataGridColumnHeaderStyle}" CellStyle="{StaticResource FullRowSelectDataGridCellStyle}"> + ColumnHeaderStyle="{StaticResource FilteredDataGridColumnHeaderStyle}" CellStyle="{StaticResource FullRowSelectDataGridCellStyle}" MaxHeight="500"> @@ -155,7 +155,7 @@ ItemsSource="{Binding Recipients}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" MinColumnWidth="80" HeadersVisibility="Column" Margin="30,20,0,40" - ColumnHeaderStyle="{StaticResource FilteredDataGridColumnHeaderStyle}" CellStyle="{StaticResource FullRowSelectDataGridCellStyle}"> + ColumnHeaderStyle="{StaticResource FilteredDataGridColumnHeaderStyle}" CellStyle="{StaticResource FullRowSelectDataGridCellStyle}" MaxHeight="200"> diff --git a/OpenSky.Client/Properties/AssemblyInfo.cs b/OpenSky.Client/Properties/AssemblyInfo.cs index d299e2c..6232203 100644 --- a/OpenSky.Client/Properties/AssemblyInfo.cs +++ b/OpenSky.Client/Properties/AssemblyInfo.cs @@ -21,8 +21,8 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("0.5.8")] -[assembly: AssemblyFileVersion("0.5.8")] +[assembly: AssemblyVersion("0.5.9")] +[assembly: AssemblyFileVersion("0.5.9")] // This allows us to detect debug mode in XAML #if DEBUG diff --git a/changelog.txt b/changelog.txt index 4e127c1..f8d1c17 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,12 @@ OpenSky Client Changelog ====================================================================================== +-------------------------------------------------------------------------------------- +Version 0.5.9 (ALPHA5) +-------------------------------------------------------------------------------------- +- Fixed max grid height in notifications page +- Added distance information to "My jobs" page + -------------------------------------------------------------------------------------- Version 0.5.8 (ALPHA5) --------------------------------------------------------------------------------------