From 47889255b777dac5d272afd2ae67b7f974ca2309 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Tue, 21 Nov 2023 12:33:22 +0000 Subject: [PATCH] Finished CG slider and alpha5 revive - Updated libraries to fix security issues and bugs - Added CG slider to advanced weight and balance section - Fixed w&b section still using simconnect instead of unified sim interface - New design for aircraft position arrow - Added update aircraft type, both for adding new updated type and added db upgrade panel from client as well - Fixed departure range bug in flight state code - Added support for newly cleaned up payload station names - Support for actualy missing manufacturer instead of dummy one --- OpenSky.Agent.SimConnectMSFS/SimConnect.cs | 4 +- .../OpenAPIs/ModelExtensions/AircraftType.cs | 6 +- OpenSky.Agent.Simulator/Simulator.Flight.cs | 4 +- .../Simulator.Process.FlightPhases.cs | 12 +- OpenSky.Agent.Simulator/Simulator.Process.cs | 5 +- OpenSky.Agent.Simulator/Simulator.simBrief.cs | 8 + OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs | 4 +- OpenSky.Agent/App.xaml.cs | 4 +- OpenSky.Agent/Controls/FuelTankControl.xaml | 2 +- .../Controls/FuelTankControl.xaml.cs | 8 +- .../Controls/PayloadStationControl.xaml | 2 +- .../Controls/PayloadStationControl.xaml.cs | 8 +- OpenSky.Agent/Native/PInvoke/Structs/Rect.cs | 1 + OpenSky.Agent/OpenSky.Agent.csproj | 20 +- OpenSky.Agent/VectorGraphics.xaml | 19 ++ OpenSky.Agent/Views/AircraftTypes.xaml | 48 ++- OpenSky.Agent/Views/FlightTracking.xaml | 14 +- OpenSky.Agent/Views/FlightTracking.xaml.cs | 16 +- .../Views/Models/AircraftTypesViewModel.cs | 284 +++++++++++++++++- ...FlightTrackingViewModel.PayloadStations.cs | 6 +- .../Views/Models/FlightTrackingViewModel.cs | 205 ++++++------- changelog.txt | 15 +- 22 files changed, 534 insertions(+), 161 deletions(-) diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.cs index a97d3a4..5885d97 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.cs @@ -633,10 +633,10 @@ private void ReadFromSimconnect() foreach (Requests request in Enum.GetValues(typeof(Requests))) { - if (this.SampleRates.ContainsKey(request)) + if (this.SampleRates.TryGetValue(request, out var rate)) { var lastTime = this.LastReceivedTimes[request]; - if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > this.SampleRates[request])) + if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > rate)) { this.fsConnect.RequestData(request, request); } diff --git a/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs index 00600cd..f1510b1 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs @@ -217,17 +217,17 @@ public bool MatchesAircraftInSimulator() // Skip these checks if detailed checks are TEMPORARILY disabled if (!this.DetailedChecksDisabled) { - if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.EmptyWeight - this.EmptyWeight) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.EmptyWeight - this.EmptyWeight) > 0.05 * this.EmptyWeight) { return false; } - if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.FuelTotalCapacity - this.FuelTotalCapacity) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.FuelTotalCapacity - this.FuelTotalCapacity) > 0.05 * this.FuelTotalCapacity) { return false; } - if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.MaxGrossWeight - this.MaxGrossWeight) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.MaxGrossWeight - this.MaxGrossWeight) > 0.05 * this.MaxGrossWeight) { return false; } diff --git a/OpenSky.Agent.Simulator/Simulator.Flight.cs b/OpenSky.Agent.Simulator/Simulator.Flight.cs index 5885ad9..1befc4b 100644 --- a/OpenSky.Agent.Simulator/Simulator.Flight.cs +++ b/OpenSky.Agent.Simulator/Simulator.Flight.cs @@ -197,7 +197,7 @@ public Flight Flight return; } - Debug.WriteLine("SimConnect flight changing..."); + Debug.WriteLine("Simulator flight changing..."); if (value != null && this.TrackingStatus != TrackingStatus.NotTracking) { Debug.WriteLine("Throwing error: You need to abort the current flight before changing to a new one!"); @@ -211,7 +211,7 @@ public Flight Flight if (value != null) { // Start the ground handling thread for this flight - new Thread(this.DoGroundHandling) { Name = "OpenSky.SimConnect.GroundHandling" }.Start(); + new Thread(this.DoGroundHandling) { Name = "OpenSky.Simulator.GroundHandling" }.Start(); // Add airport markers to map (do this in both new and restore, save file doesn't contain these cause the data would just be redundant) UpdateGUIDelegate addAirports = () => diff --git a/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs index c01ba76..72af551 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs @@ -271,7 +271,8 @@ private void TransitionFlightPhase() } // Departure - if (distanceToDepartureAirport < 10 && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) + var approachDepartureDistance = this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop ? 40 : 10; + if (distanceToDepartureAirport < approachDepartureDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -286,8 +287,7 @@ private void TransitionFlightPhase() } // Climb - var approachDistance = this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop ? 40 : 10; - if (distanceToDepartureAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) + if (distanceToDepartureAirport >= approachDepartureDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -302,7 +302,7 @@ private void TransitionFlightPhase() } // Cruise - if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Level && !this.PrimaryTracking.OnGround) + if (distanceToDestinationAirport >= approachDepartureDistance && distanceToAlternateAirport >= approachDepartureDistance && this.VerticalProfile == VerticalProfile.Level && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -317,7 +317,7 @@ private void TransitionFlightPhase() } // Descent - if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Descending && !this.PrimaryTracking.OnGround) + if (distanceToDestinationAirport >= approachDepartureDistance && distanceToAlternateAirport >= approachDepartureDistance && this.VerticalProfile == VerticalProfile.Descending && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -332,7 +332,7 @@ private void TransitionFlightPhase() } // Approach - if ((distanceToDestinationAirport < approachDistance || distanceToAlternateAirport < approachDistance) && !this.PrimaryTracking.OnGround && this.PrimaryTracking.RadioHeight > 500) + if ((distanceToDestinationAirport < approachDepartureDistance || distanceToAlternateAirport < approachDepartureDistance) && !this.PrimaryTracking.OnGround && this.PrimaryTracking.RadioHeight > 500) { if (unknownFlightPhase) { diff --git a/OpenSky.Agent.Simulator/Simulator.Process.cs b/OpenSky.Agent.Simulator/Simulator.Process.cs index 0f472d7..f58c156 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.cs @@ -337,6 +337,8 @@ private void ProcessLandingAnalysis() } } + private DateTime lastLocationUpdate=DateTime.MinValue; + /// ------------------------------------------------------------------------------------------------- /// /// Process the primary tracking data (old vs new). @@ -362,8 +364,9 @@ private void ProcessPrimaryTracking() this.TrackFlight(ppt); // Fire the location changed event? - if (!ppt.Old.MapLocation.Equals(ppt.New.MapLocation)) + if (!ppt.Old.MapLocation.Equals(ppt.New.MapLocation) || (DateTime.Now-this.lastLocationUpdate).TotalSeconds>5) { + this.lastLocationUpdate = DateTime.Now; newLocation = ppt.New.MapLocation; } diff --git a/OpenSky.Agent.Simulator/Simulator.simBrief.cs b/OpenSky.Agent.Simulator/Simulator.simBrief.cs index 9ceb7fb..8ff975c 100644 --- a/OpenSky.Agent.Simulator/Simulator.simBrief.cs +++ b/OpenSky.Agent.Simulator/Simulator.simBrief.cs @@ -39,6 +39,13 @@ public partial class Simulator /// ------------------------------------------------------------------------------------------------- private bool simbriefOfpLoaded; + /// ------------------------------------------------------------------------------------------------- + /// + /// Occurs when simbrief ofp loaded property changed. + /// + /// ------------------------------------------------------------------------------------------------- + public event EventHandler SimbriefOfpLoadedChanged; + /// ------------------------------------------------------------------------------------------------- /// /// Occurs when SimConnect adds a new simbrief waypoint marker. @@ -64,6 +71,7 @@ private set this.simbriefOfpLoaded = value; this.OnPropertyChanged(); + this.SimbriefOfpLoadedChanged?.Invoke(this, value); } } diff --git a/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs b/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs index c2c13c4..b18dad7 100644 --- a/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs +++ b/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs @@ -446,10 +446,10 @@ private void ReadFromXPlane() } foreach (Requests request in Enum.GetValues(typeof(Requests))) { - if (this.SampleRates.ContainsKey(request)) + if (this.SampleRates.TryGetValue(request, out var rate)) { var lastTime = this.LastReceivedTimes[request]; - if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > this.SampleRates[request])) + if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > rate)) { if (request == Requests.Secondary) { diff --git a/OpenSky.Agent/App.xaml.cs b/OpenSky.Agent/App.xaml.cs index 943be05..4644bfb 100644 --- a/OpenSky.Agent/App.xaml.cs +++ b/OpenSky.Agent/App.xaml.cs @@ -301,13 +301,13 @@ private static void AppDispatcherUnhandledException( crashReport += "\r\n\r\n"; Debug.WriteLine(crashReport); - var filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\OpenSky.Agent.Crash.txt"; + var filePath = Environment.ExpandEnvironmentVariables("%localappdata%\\OpenSky\\agent_crash.log"); try { File.AppendAllText(filePath, crashReport); ModernWpf.MessageBox.Show( - e.Exception.Message + "\r\n\r\nPlease check OpenSky.Agent.Crash.txt for details!", + e.Exception.Message + "\r\n\r\nPlease check agent_crash.log for details!", "Unexpected error!", MessageBoxButton.OK, MessageBoxImage.Error); diff --git a/OpenSky.Agent/Controls/FuelTankControl.xaml b/OpenSky.Agent/Controls/FuelTankControl.xaml index b4a6db0..060638f 100644 --- a/OpenSky.Agent/Controls/FuelTankControl.xaml +++ b/OpenSky.Agent/Controls/FuelTankControl.xaml @@ -29,7 +29,7 @@ - + diff --git a/OpenSky.Agent/Controls/FuelTankControl.xaml.cs b/OpenSky.Agent/Controls/FuelTankControl.xaml.cs index b8d0d0b..bb412cf 100644 --- a/OpenSky.Agent/Controls/FuelTankControl.xaml.cs +++ b/OpenSky.Agent/Controls/FuelTankControl.xaml.cs @@ -21,28 +21,28 @@ public partial class FuelTankControl /// The fuel tangent capacity property. /// /// ------------------------------------------------------------------------------------------------- - public static readonly DependencyProperty FuelTankCapacityProperty = DependencyProperty.Register("FuelTankCapacity", typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0)); + public static readonly DependencyProperty FuelTankCapacityProperty = DependencyProperty.Register(nameof(FuelTankCapacity), typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0)); /// ------------------------------------------------------------------------------------------------- /// /// The fuel tank name property. /// /// ------------------------------------------------------------------------------------------------- - public static readonly DependencyProperty FuelTankNameProperty = DependencyProperty.Register("FuelTankName", typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("Unknown tank")); + public static readonly DependencyProperty FuelTankNameProperty = DependencyProperty.Register(nameof(FuelTankName), typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("Unknown tank")); /// ------------------------------------------------------------------------------------------------- /// /// The fuel tank info property. /// /// ------------------------------------------------------------------------------------------------- - public static readonly DependencyProperty FuelTankInfoProperty = DependencyProperty.Register("FuelTankInfo", typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("??")); + public static readonly DependencyProperty FuelTankInfoProperty = DependencyProperty.Register(nameof(FuelTankInfo), typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("??")); /// ------------------------------------------------------------------------------------------------- /// /// The fuel tank quantity property. /// /// ------------------------------------------------------------------------------------------------- - public static readonly DependencyProperty FuelTankQuantityProperty = DependencyProperty.Register("FuelTankQuantity", typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0)); + public static readonly DependencyProperty FuelTankQuantityProperty = DependencyProperty.Register(nameof(FuelTankQuantity), typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0)); /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent/Controls/PayloadStationControl.xaml b/OpenSky.Agent/Controls/PayloadStationControl.xaml index f95d16e..a23125b 100644 --- a/OpenSky.Agent/Controls/PayloadStationControl.xaml +++ b/OpenSky.Agent/Controls/PayloadStationControl.xaml @@ -26,6 +26,6 @@ - + diff --git a/OpenSky.Agent/Controls/PayloadStationControl.xaml.cs b/OpenSky.Agent/Controls/PayloadStationControl.xaml.cs index 920f272..20d1bd4 100644 --- a/OpenSky.Agent/Controls/PayloadStationControl.xaml.cs +++ b/OpenSky.Agent/Controls/PayloadStationControl.xaml.cs @@ -21,14 +21,14 @@ public partial class PayloadStationControl /// The payload station name property. /// /// ------------------------------------------------------------------------------------------------- - public static readonly DependencyProperty PayloadStationNameProperty = DependencyProperty.Register("PayloadStationName", typeof(string), typeof(PayloadStationControl), new UIPropertyMetadata("Unknown")); + public static readonly DependencyProperty PayloadStationNameProperty = DependencyProperty.Register(nameof(PayloadStationName), typeof(string), typeof(PayloadStationControl), new UIPropertyMetadata("Unknown")); /// ------------------------------------------------------------------------------------------------- /// /// The payload station weight property. /// /// ------------------------------------------------------------------------------------------------- - public static readonly DependencyProperty PayloadStationWeightProperty = DependencyProperty.Register("PayloadStationWeight", typeof(double), typeof(PayloadStationControl), new UIPropertyMetadata(0.0)); + public static readonly DependencyProperty PayloadStationWeightProperty = DependencyProperty.Register(nameof(PayloadStationWeight), typeof(double), typeof(PayloadStationControl), new UIPropertyMetadata(0.0)); /// ------------------------------------------------------------------------------------------------- /// @@ -61,9 +61,9 @@ public string PayloadStationName /// /// ------------------------------------------------------------------------------------------------- [Bindable(true)] - public string PayloadStationWeight + public double PayloadStationWeight { - get => (string)this.GetValue(PayloadStationWeightProperty); + get => (double)this.GetValue(PayloadStationWeightProperty); set => this.SetValue(PayloadStationWeightProperty, value); } } diff --git a/OpenSky.Agent/Native/PInvoke/Structs/Rect.cs b/OpenSky.Agent/Native/PInvoke/Structs/Rect.cs index e887551..44d1bc2 100644 --- a/OpenSky.Agent/Native/PInvoke/Structs/Rect.cs +++ b/OpenSky.Agent/Native/PInvoke/Structs/Rect.cs @@ -25,6 +25,7 @@ public struct Rect : IEquatable /// Empty Rect structure. /// /// ------------------------------------------------------------------------------------------------- + // ReSharper disable once UnassignedReadonlyField public static readonly Rect Empty; /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.Agent/OpenSky.Agent.csproj b/OpenSky.Agent/OpenSky.Agent.csproj index cce9ccb..a65c0d3 100644 --- a/OpenSky.Agent/OpenSky.Agent.csproj +++ b/OpenSky.Agent/OpenSky.Agent.csproj @@ -365,19 +365,19 @@ 2.5.13 - 1.0.175 + 1.2.1.24 1.1.0 - 2022.1.0 + 2023.3.0 - 1.13.0 + 1.21.0 - 6.0.0 + 8.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -388,28 +388,28 @@ 0.5.2 - 0.9.4 + 0.9.6 1.2.0 - 13.0.1 + 13.0.3 0.1.6 - 20.1.0.52 + 23.1.44 - 20.1.0.52 + 23.1.44 - 20.1.0.52 + 23.1.44 - 2.7.6 + 2.10.0 5.0.6 diff --git a/OpenSky.Agent/VectorGraphics.xaml b/OpenSky.Agent/VectorGraphics.xaml index 7472490..d8f3564 100644 --- a/OpenSky.Agent/VectorGraphics.xaml +++ b/OpenSky.Agent/VectorGraphics.xaml @@ -23,6 +23,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/OpenSky.Agent/Views/AircraftTypes.xaml b/OpenSky.Agent/Views/AircraftTypes.xaml index 70f2fae..d2a0e0d 100644 --- a/OpenSky.Agent/Views/AircraftTypes.xaml +++ b/OpenSky.Agent/Views/AircraftTypes.xaml @@ -26,7 +26,7 @@ mc:Ignorable="d" d:DesignWidth="2000" Loaded="AircraftTypesOnLoaded" Title="Aircraft Types" Height="800" Width="1400" HorizontalScrollBar="False" VerticalScrollBar="False" LoadingText="{Binding LoadingText}"> - + @@ -64,6 +64,7 @@ + @@ -76,6 +77,7 @@ + @@ -289,6 +291,7 @@ + @@ -297,6 +300,11 @@ + + + + + @@ -604,5 +612,43 @@ + + + + Upgrade aircraft types + + + + + + + + + + + + + + + + + + + + From type: + To type: + #Aircraft: + + + + + + + + + + + + diff --git a/OpenSky.Agent/Views/FlightTracking.xaml b/OpenSky.Agent/Views/FlightTracking.xaml index 1636f08..1a4d222 100644 --- a/OpenSky.Agent/Views/FlightTracking.xaml +++ b/OpenSky.Agent/Views/FlightTracking.xaml @@ -172,7 +172,7 @@ Set - Plane model + Aircraft model Sim: @@ -202,11 +202,11 @@ Tips for resuming tracking while airborne: ➤ Start engines, prepare cockpit and remaining flight plan ➤ Did you set the correct lights? - ➤ Slew plane into position + ➤ Slew aircraft into position ➤ Exit slew (press Y) to adjust gear and flaps, enable AP? - ➤ Slew plane back into position again + ➤ Slew aircraft back into position again ➤ "Resume tracking", starts a five second countdown - ➤ Fly the plane 🙃 + ➤ Fly the aircraft 🙃 If resuming on the ground you can also exit slew and resume without the five second countdown. @@ -318,7 +318,7 @@ - While waiting for the ground crew to finish fueling and loading your plane you can start tracking your flight. You can use this time to check your plane, prepare the cockpit and run your checklists... + While waiting for the ground crew to finish fueling and loading your aircraft you can start tracking your flight. You can use this time to check your aircraft, prepare the cockpit and run your checklists... Fuel loading estimated completion time @@ -646,7 +646,7 @@ - Follow plane + Follow aircraft @@ -673,7 +673,7 @@ No flight ready for tracking - Please assign a new flight from the OpenSky client or if you have the Alpha debugging client, create one using the "Test Flight" option from the main menu. + Please start a new flight from the OpenSky client first. diff --git a/OpenSky.Agent/Views/FlightTracking.xaml.cs b/OpenSky.Agent/Views/FlightTracking.xaml.cs index 49e36f5..10e6e75 100644 --- a/OpenSky.Agent/Views/FlightTracking.xaml.cs +++ b/OpenSky.Agent/Views/FlightTracking.xaml.cs @@ -102,14 +102,14 @@ private void AddAircraftAndTrailsToMap() this.MapView.Children.Add(aircraftTrail); // Add aircraft position to map - var aircraftPosition = new Image { Width = 40, Height = 40 }; + var aircraftPosition = new Image { Width = 30, Height = 30 }; aircraftPosition.SetValue(Panel.ZIndexProperty, 999); aircraftPosition.SetValue(MapLayer.PositionOriginProperty, PositionOrigin.Center); - var rotateTransform = new RotateTransform { CenterX = 20, CenterY = 20 }; + var rotateTransform = new RotateTransform { CenterX = 15, CenterY = 15 }; var headingBinding = new Binding { Source = this.DataContext, Path = new PropertyPath("AircraftHeading"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(rotateTransform, RotateTransform.AngleProperty, headingBinding); aircraftPosition.RenderTransform = rotateTransform; - var aircraftDrawingImage = this.FindResource("OpenSkyLogoPointingUpForMap") as DrawingImage; + var aircraftDrawingImage = this.FindResource("AircraftPositionUpForMap") as DrawingImage; aircraftPosition.Source = aircraftDrawingImage; var positionBinding = new Binding { Source = this.DataContext, Path = new PropertyPath("AircraftLocation"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(aircraftPosition, MapLayer.PositionProperty, positionBinding); @@ -169,11 +169,11 @@ private void FlightTrackingLoaded(object sender, RoutedEventArgs e) foreach (FuelTank tank in Enum.GetValues(typeof(FuelTank))) { var control = new FuelTankControl { FuelTankName = tank.GetStringValue(), Margin = new Thickness(5, 2, 5, 2) }; - var capacityBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"SimConnect.FuelTanks.Capacities[{(int)tank}]"), Mode = BindingMode.OneWay }; + var capacityBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"Simulator.FuelTanks.Capacities[{(int)tank}]"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(control, FuelTankControl.FuelTankCapacityProperty, capacityBinding); var quantityBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"FuelTankQuantities[{(int)tank}]"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; BindingOperations.SetBinding(control, FuelTankControl.FuelTankQuantityProperty, quantityBinding); - var visibilityBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"SimConnect.FuelTanks.Capacities[{(int)tank}]"), Mode = BindingMode.OneWay, Converter = new FuelTankCapacityVisibilityConverter() }; + var visibilityBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"Simulator.FuelTanks.Capacities[{(int)tank}]"), Mode = BindingMode.OneWay, Converter = new FuelTankCapacityVisibilityConverter() }; BindingOperations.SetBinding(control, VisibilityProperty, visibilityBinding); var infoStringBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"FuelTankInfos[{(int)tank}]"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(control, FuelTankControl.FuelTankInfoProperty, infoStringBinding); @@ -181,15 +181,15 @@ private void FlightTrackingLoaded(object sender, RoutedEventArgs e) } // Add payload station controls - for (var i = 0; i < 15; i++) + for (var i = 0; i < 20; i++) { var control = new PayloadStationControl { Margin = new Thickness(5, 2, 5, 2) }; - var nameBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"SimConnect.PayloadStations.Names[{i}]"), Mode = BindingMode.OneWay }; + var nameBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"Simulator.PayloadStations.Names[{i}]"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(control, PayloadStationControl.PayloadStationNameProperty, nameBinding); var weightBinding = new Binding { Source = this.DataContext, Path = new PropertyPath($"PayloadStationWeights[{i}]"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; BindingOperations.SetBinding(control, PayloadStationControl.PayloadStationWeightProperty, weightBinding); var visibilityBinding = new Binding - { Source = this.DataContext, Path = new PropertyPath("SimConnect.PayloadStations.Count"), Mode = BindingMode.OneWay, Converter = new PayloadStationsVisibilityConverter(), ConverterParameter = i + 1 }; + { Source = this.DataContext, Path = new PropertyPath("Simulator.PayloadStations.Count"), Mode = BindingMode.OneWay, Converter = new PayloadStationsVisibilityConverter(), ConverterParameter = i + 1 }; BindingOperations.SetBinding(control, VisibilityProperty, visibilityBinding); this.PayloadStationsPanel.Children.Add(control); } diff --git a/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs b/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs index b44e2b7..59f7efa 100644 --- a/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs +++ b/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs @@ -247,11 +247,13 @@ public AircraftTypesViewModel() this.ExistingAircraftTypes = new ObservableCollection(); this.SelectedAircraftTypes = new ObservableCollection(); this.Manufacturers = new ObservableCollection(); + this.AircraftUpgrades = new ObservableCollection(); this.GetUserRolesCommand = new AsynchronousCommand(this.GetUserRoles); this.RefreshAircraftTypesCommand = new AsynchronousCommand(this.RefreshAircraftTypes); this.AddAircraftTypeCommand = new AsynchronousCommand(this.AddAircraftType); this.StartAddAircraftCommand = new Command(this.StartAddAircraft); + this.StartUpdateAircraftCommand = new Command(this.StartUpdateAircraft, false); this.CancelAddAircraftCommand = new Command(this.CancelAddAircraft); this.ClearVariantOfNewCommand = new Command(this.ClearVariantOfNew); this.ClearTypeSelectionCommand = new Command(this.ClearTypeSelection); @@ -268,11 +270,134 @@ public AircraftTypesViewModel() this.IdentifyAircraftCommand = new Command(this.IdentifyAircraft); this.UploadImageCommand = new AsynchronousCommand(this.UploadImage); this.GetAircraftManufacturersCommand = new AsynchronousCommand(this.GetAircraftManufacturers); + this.GetAircraftUpgradesCommand = new AsynchronousCommand(this.GetAircraftUpgrades, false); + this.CloseUpgradeAircraftCommand = new Command(this.CloseUpgradeAircraft); + this.UpdateAircraftTypeCommand = new AsynchronousCommand(this.UpdateAircraftType); this.GetUserRolesCommand.DoExecute(null); this.GetAircraftManufacturersCommand.DoExecute(null); } + /// ------------------------------------------------------------------------------------------------- + /// + /// Perform the specified aircraft type upgrade. + /// + /// + /// sushi.at, 29/11/2021. + /// + /// + /// The parameter. + /// + /// ------------------------------------------------------------------------------------------------- + private void UpdateAircraftType(object parameter) + { + if (parameter is AircraftTypeUpgrade upgrade) + { + this.LoadingText = "Upgrading aircraft..."; + try + { + var result = AgentOpenSkyService.Instance.UpgradeAircraftTypeAsync(upgrade).Result; + if (!result.IsError) + { + this.UpdateAircraftTypeCommand.ReportProgress(() => this.GetAircraftUpgradesCommand.DoExecute(null)); + } + else + { + this.UpdateAircraftTypeCommand.ReportProgress( + () => + { + Debug.WriteLine("Error performing aircraft type upgrade: " + result.Message); + if (!string.IsNullOrEmpty(result.ErrorDetails)) + { + Debug.WriteLine(result.ErrorDetails); + } + + var notification = new OpenSkyNotification("Error performing aircraft type upgrade", result.Message, MessageBoxButton.OK, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + }); + } + } + catch (Exception ex) + { + ex.HandleApiCallException(this.ViewReference, this.UpdateAircraftTypeCommand, "Error performing aircraft type upgrade"); + } + finally + { + this.LoadingText = null; + } + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the update aircraft type command. + /// + /// ------------------------------------------------------------------------------------------------- + public AsynchronousCommand UpdateAircraftTypeCommand { get; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The upgrade aircraft visibility. + /// + /// ------------------------------------------------------------------------------------------------- + private Visibility upgradeAircraftVisibility = Visibility.Collapsed; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the upgrade aircraft visibility. + /// + /// ------------------------------------------------------------------------------------------------- + public Visibility UpgradeAircraftVisibility + { + get => this.upgradeAircraftVisibility; + + set + { + if (Equals(this.upgradeAircraftVisibility, value)) + { + return; + } + + this.upgradeAircraftVisibility = value; + this.NotifyPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the close upgrade aircraft command. + /// + /// ------------------------------------------------------------------------------------------------- + public Command CloseUpgradeAircraftCommand { get; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Closes the upgrade aircraft view and clears the upgrades collection. + /// + /// + /// sushi.at, 29/11/2021. + /// + /// ------------------------------------------------------------------------------------------------- + public void CloseUpgradeAircraft() + { + this.UpgradeAircraftVisibility = Visibility.Collapsed; + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the get aircraft upgrades command. + /// + /// ------------------------------------------------------------------------------------------------- + public AsynchronousCommand GetAircraftUpgradesCommand { get; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the aircraft upgrades. + /// + /// ------------------------------------------------------------------------------------------------- + public ObservableCollection AircraftUpgrades { get; } + /// ------------------------------------------------------------------------------------------------- /// /// Gets the add aircraft type command. @@ -955,6 +1080,7 @@ public AircraftType SelectedAircraftType this.selectedAircraftType = value; this.NotifyPropertyChanged(); this.AircraftTypeDetailsVisibility = value != null ? Visibility.Visible : Visibility.Collapsed; + this.StartUpdateAircraftCommand.CanExecute = value != null; if (UserSessionService.Instance.IsModerator) { @@ -1022,6 +1148,13 @@ public AircraftManufacturer SelectedManufacturer /// ------------------------------------------------------------------------------------------------- public Command StartEditAircraftCommand { get; } + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the start update aircraft command. + /// + /// ------------------------------------------------------------------------------------------------- + public Command StartUpdateAircraftCommand { get; } + /// ------------------------------------------------------------------------------------------------- /// /// Gets the upload image command. @@ -1165,6 +1298,13 @@ private void AddAircraftType() } } + // The special "Missing" manufacturer was selected + if (this.SelectedManufacturer.Id == "miss") + { + newAircraftType.ManufacturerID = null; + newAircraftType.DeliveryLocations = null; + } + this.LoadingText = "Adding new aircraft type"; try { @@ -1301,6 +1441,95 @@ private void ClearVariantOfNew() this.IsVariantOf = null; } + /// ------------------------------------------------------------------------------------------------- + /// + /// Copies the selected aircraft type to be updated using the add aircraft panel. + /// + /// + /// sushi.at, 20/11/2023. + /// + /// ------------------------------------------------------------------------------------------------- + private void CopySelectedTypeToBeUpdated() + { + this.Name = this.SelectedAircraftType.Name; + this.VersionNumber = this.SelectedAircraftType.VersionNumber + 1; + this.SelectedManufacturer = this.SelectedAircraftType.Manufacturer; + this.ManufacturerDeliveryAirportICAOs = this.SelectedAircraftType.ManufacturerDeliveryLocationICAOs; + this.Category = this.SelectedAircraftType.Category; + this.IsVanilla = this.SelectedAircraftType.IsVanilla; + this.IncludeInWorldPopulation = this.SelectedAircraftType.IncludeInWorldPopulation; + this.NeedsCoPilot = this.SelectedAircraftType.NeedsCoPilot; + this.NeedsFlightEngineer = this.SelectedAircraftType.NeedsFlightEngineer; + this.RequiresManualFuelling = this.SelectedAircraftType.RequiresManualFuelling; + this.RequiresManualLoading = this.SelectedAircraftType.RequiresManualLoading; + this.MinimumRunwayLength = this.SelectedAircraftType.MinimumRunwayLength; + this.MinimumPrice = this.SelectedAircraftType.MinPrice; + this.MaximumPrice = this.SelectedAircraftType.MaxPrice; + this.MaxPayloadDeltaAllowed = this.SelectedAircraftType.MaxPayloadDeltaAllowed; + this.Comments = this.SelectedAircraftType.Comments; + this.EngineModel = this.SelectedAircraftType.EngineModel; + this.OverrideFuelType = this.SelectedAircraftType.OverrideFuelType; + this.IsHistoric = this.SelectedAircraftType.IsHistoric; + + this.AddAircraftVisibility = Visibility.Visible; + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the available aircraft upgrades. + /// + /// + /// sushi.at, 29/11/2021. + /// + /// ------------------------------------------------------------------------------------------------- + private void GetAircraftUpgrades() + { + if (!UserSessionService.Instance.IsModerator) + { + return; + } + + this.LoadingText = "Checking for available aircraft type upgrades..."; + try + { + var result = AgentOpenSkyService.Instance.GetAircraftTypeUpgradesAsync().Result; + if (!result.IsError) + { + this.GetAircraftUpgradesCommand.ReportProgress( + () => + { + this.AircraftUpgrades.Clear(); + this.AircraftUpgrades.AddRange(result.Data); + this.UpgradeAircraftVisibility = Visibility.Visible; + }); + } + else + { + this.GetAircraftUpgradesCommand.ReportProgress( + () => + { + Debug.WriteLine("Error checking for aircraft type upgrades: " + result.Message); + if (!string.IsNullOrEmpty(result.ErrorDetails)) + { + Debug.WriteLine(result.ErrorDetails); + } + + var notification = new OpenSkyNotification("Error checking for aircraft type upgrades", result.Message, MessageBoxButton.OK, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + }); + } + } + catch (Exception ex) + { + ex.HandleApiCallException(this.ViewReference, this.GetAircraftUpgradesCommand, "Error checking for aircraft type upgrades"); + } + finally + { + this.LoadingText = null; + } + } + /// ------------------------------------------------------------------------------------------------- /// /// Deletes the selected aircraft type. @@ -1678,6 +1907,7 @@ private void GetUserRoles() if (result) { this.GetUserRolesCommand.ReportProgress(() => this.RefreshAircraftTypesCommand.DoExecute(null)); + this.GetAircraftUpgradesCommand.CanExecute = UserSessionService.Instance.IsModerator; } else { @@ -1687,6 +1917,8 @@ private void GetUserRoles() var notification = new OpenSkyNotification("Error", "Error fetching your user roles.", MessageBoxButton.OK, ExtendedMessageBoxImage.Error, 30); notification.SetErrorColorStyle(); this.ViewReference.ShowNotification(notification); + + this.GetAircraftUpgradesCommand.CanExecute = false; }); } @@ -1751,7 +1983,7 @@ private void RefreshAircraftTypes() () => { this.ExistingAircraftTypes.Clear(); - foreach (var type in result.Data) + foreach (var type in result.Data.OrderBy(t => t.Name).ThenBy(t => t.VersionNumber)) { this.ExistingAircraftTypes.Add(type); } @@ -1967,6 +2199,56 @@ private void StartEditAircraft() this.ManufacturerDeliveryAirportICAOs = this.ManufacturerDeliveryAirportICAOs.TrimEnd(','); } + /// ------------------------------------------------------------------------------------------------- + /// + /// Starts updating the selected aircraft type. + /// + /// + /// sushi.at, 20/11/2023. + /// + /// ------------------------------------------------------------------------------------------------- + private void StartUpdateAircraft() + { + if (!this.Simulator.Connected) + { + var notification = new OpenSkyNotification("Update aircraft type", "Not connected to sim!", MessageBoxButton.OK, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + return; + } + + AircraftType matchedType = null; + foreach (var type in this.ExistingAircraftTypes) + { + if (type.MatchesAircraftInSimulator()) + { + matchedType = type; + break; + } + } + + if (matchedType != null) + { + var messageBox = new OpenSkyMessageBox( + "Update aircraft type", + $"The aircraft currently loaded in the sim seems to be a match for the existing type: {matchedType}\r\n\r\nAre you sure you an update is necessary?", + MessageBoxButton.YesNo, + ExtendedMessageBoxImage.Question); + messageBox.Closed += (_, _) => + { + if (messageBox.Result == ExtendedMessageBoxResult.Yes) + { + this.CopySelectedTypeToBeUpdated(); + } + }; + this.ViewReference.ShowMessageBox(messageBox); + } + else + { + this.CopySelectedTypeToBeUpdated(); + } + } + /// ------------------------------------------------------------------------------------------------- /// /// Upload aircraft type image. diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs index 2bf0091..5b855b7 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs @@ -156,8 +156,6 @@ private void SetPayloadStations() } } - private double[] sliderPositionStarts = new[] { 2, 1.8, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.2, 0 }; - /// ------------------------------------------------------------------------------------------------- /// /// Suggest payload loading. @@ -175,7 +173,7 @@ private void SuggestPayload() var nonPilotStations = 0; for (var i = 0; i < this.Simulator.PayloadStations.Count; i++) { - if (this.Simulator.PayloadStations.Names[i].Contains("PILOT")) + if (this.Simulator.PayloadStations.Names[i].ToLowerInvariant().Contains("pilot")) { var payload = Math.Min(170, payloadToLoad); this.PayloadStationWeights[i] = payload; @@ -212,7 +210,7 @@ private void SuggestPayload() var nonPilotIndex = 0; for (var i = 0; i < this.Simulator.PayloadStations.Count; i++) { - if (!this.Simulator.PayloadStations.Names[i].Contains("PILOT") || nonPilotOverride) + if (!this.Simulator.PayloadStations.Names[i].ToLowerInvariant().Contains("pilot") || nonPilotOverride) { this.PayloadStationWeights[i] = payloadShare * payloadMultipliers[nonPilotIndex++]; payloadToLoad -= payloadShare; diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs index 7ed7f40..109d414 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs @@ -89,6 +89,13 @@ public partial class FlightTrackingViewModel : ViewModel /// ------------------------------------------------------------------------------------------------- private string showHideOFPButtonText = "Show OFP"; + /// ------------------------------------------------------------------------------------------------- + /// + /// The skip ground handling visibility. + /// + /// ------------------------------------------------------------------------------------------------- + private Visibility skipGroundHandlingVisibility = Visibility.Collapsed; + /// ------------------------------------------------------------------------------------------------- /// /// The start/resume tracking button text. @@ -124,36 +131,6 @@ public partial class FlightTrackingViewModel : ViewModel /// ------------------------------------------------------------------------------------------------- private Visibility weightAndBalancesVisibility = Visibility.Visible; - /// ------------------------------------------------------------------------------------------------- - /// - /// The skip ground handling visibility. - /// - /// ------------------------------------------------------------------------------------------------- - private Visibility skipGroundHandlingVisibility = Visibility.Collapsed; - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets or sets the skip ground handling visibility. - /// - /// ------------------------------------------------------------------------------------------------- - public Visibility SkipGroundHandlingVisibility - { - get => this.skipGroundHandlingVisibility; - - set - { - if (Equals(this.skipGroundHandlingVisibility, value)) - { - return; - } - - this.skipGroundHandlingVisibility = value; - this.NotifyPropertyChanged(); - } - } - - - /// ------------------------------------------------------------------------------------------------- /// /// Initializes a new instance of the class. @@ -188,6 +165,7 @@ public FlightTrackingViewModel() this.Simulator.TrackingStatusChanged += this.SimulatorTrackingStatusChanged; this.Simulator.FlightChanged += this.SimulatortFlightChanged; this.Simulator.LocationChanged += this.SimulatorLocationChanged; + this.Simulator.SimbriefOfpLoadedChanged += this.SimulatorOfpLoadedChanged; // Create commands this.SetFuelAndPayloadCommand = new Command(this.SetFuelAndPayload); @@ -421,6 +399,27 @@ public string ShowHideOFPButtonText /// ------------------------------------------------------------------------------------------------- public Command SkipGroundHandlingCommand { get; } + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the skip ground handling visibility. + /// + /// ------------------------------------------------------------------------------------------------- + public Visibility SkipGroundHandlingVisibility + { + get => this.skipGroundHandlingVisibility; + + set + { + if (Equals(this.skipGroundHandlingVisibility, value)) + { + return; + } + + this.skipGroundHandlingVisibility = value; + this.NotifyPropertyChanged(); + } + } + /// ------------------------------------------------------------------------------------------------- /// /// Gets the slew into position command. @@ -602,10 +601,7 @@ private void AbortFlight() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Hand); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => - { - answer = messageBox.Result; - }; + messageBox.Closed += (_, _) => { answer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); while (answer == null && !SleepScheduler.IsShutdownInProgress) @@ -650,6 +646,25 @@ private void SetFuelAndPayload() this.SetPayloadStations(); } + /// ------------------------------------------------------------------------------------------------- + /// + /// Simulator ofp loaded changed. + /// + /// + /// sushi.at, 18/11/2023. + /// + /// + /// Source of the event. + /// + /// + /// True if the data was loaded. + /// + /// ------------------------------------------------------------------------------------------------- + private void SimulatorOfpLoadedChanged(object sender, bool loaded) + { + this.ImportSimbriefVisibility = loaded ? Visibility.Collapsed : Visibility.Visible; + } + /// ------------------------------------------------------------------------------------------------- /// /// Simulator flight changed. @@ -851,12 +866,13 @@ private void SlewIntoPosition() catch (Exception ex) { Debug.WriteLine("Error slewing plane into position: " + ex); - this.SlewIntoPositionCommand.ReportProgress(() => - { - var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error slewing into position", ex.Message, ExtendedMessageBoxImage.Error, 30); - notification.SetErrorColorStyle(); - this.ViewReference.ShowNotification(notification); - }); + this.SlewIntoPositionCommand.ReportProgress( + () => + { + var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error slewing into position", ex.Message, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + }); } } @@ -895,12 +911,13 @@ private void StartTracking() if (!this.Simulator.CanStartTracking) { Debug.WriteLine("Tracking conditions not met"); - this.StartTrackingCommand.ReportProgress(() => - { - var notification = new OpenSkyNotification("Start tracking", "Not all tracking conditions are met, please review, correct and try again.", MessageBoxButton.OK, ExtendedMessageBoxImage.Warning, 10); - notification.SetWarningColorStyle(); - this.ViewReference.ShowNotification(notification); - }); + this.StartTrackingCommand.ReportProgress( + () => + { + var notification = new OpenSkyNotification("Start tracking", "Not all tracking conditions are met, please review, correct and try again.", MessageBoxButton.OK, ExtendedMessageBoxImage.Warning, 10); + notification.SetWarningColorStyle(); + this.ViewReference.ShowNotification(notification); + }); this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; } @@ -943,10 +960,7 @@ private void StartTracking() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Warning); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => - { - answer = messageBox.Result; - }; + messageBox.Closed += (_, _) => { answer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); while (answer == null && !SleepScheduler.IsShutdownInProgress) @@ -974,10 +988,7 @@ private void StartTracking() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Warning); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => - { - answer = messageBox.Result; - }; + messageBox.Closed += (_, _) => { answer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); while (answer == null && !SleepScheduler.IsShutdownInProgress) @@ -1005,10 +1016,7 @@ private void StartTracking() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Warning); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => - { - answer = messageBox.Result; - }; + messageBox.Closed += (_, _) => { answer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); while (answer == null && !SleepScheduler.IsShutdownInProgress) @@ -1035,10 +1043,7 @@ private void StartTracking() "The total weight exceeds the limits specified for this plane, are you sure you want to continue?", MessageBoxButton.YesNo, ExtendedMessageBoxImage.Question); - messageBox.Closed += (_, _) => - { - answer = messageBox.Result; - }; + messageBox.Closed += (_, _) => { answer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); while (answer == null && !SleepScheduler.IsShutdownInProgress) @@ -1065,10 +1070,7 @@ private void StartTracking() "Ground handling not yet completed, do you want to skip it?", MessageBoxButton.YesNo, ExtendedMessageBoxImage.Question); - messageBox.Closed += (_, _) => - { - answer = messageBox.Result; - }; + messageBox.Closed += (_, _) => { answer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); while (answer == null && !SleepScheduler.IsShutdownInProgress) @@ -1099,12 +1101,13 @@ private void StartTracking() if (!this.Simulator.CanStartTracking) { Debug.WriteLine("Tracking conditions not met"); - this.StartTrackingCommand.ReportProgress(() => - { - var notification = new OpenSkyNotification("Start tracking", "Not all tracking conditions are met, please review, correct and try again.", MessageBoxButton.OK, ExtendedMessageBoxImage.Warning, 10); - notification.SetWarningColorStyle(); - this.ViewReference.ShowNotification(notification); - }); + this.StartTrackingCommand.ReportProgress( + () => + { + var notification = new OpenSkyNotification("Start tracking", "Not all tracking conditions are met, please review, correct and try again.", MessageBoxButton.OK, ExtendedMessageBoxImage.Warning, 10); + notification.SetWarningColorStyle(); + this.ViewReference.ShowNotification(notification); + }); this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; } @@ -1153,12 +1156,13 @@ private void StartTracking() catch (Exception ex) { Debug.WriteLine("Error starting/resuming tracking: " + ex); - this.StartTrackingCommand.ReportProgress(() => - { - var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error starting tracking", ex.Message, ExtendedMessageBoxImage.Error, 30); - notification.SetErrorColorStyle(); - this.ViewReference.ShowNotification(notification); - }); + this.StartTrackingCommand.ReportProgress( + () => + { + var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error starting tracking", ex.Message, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + }); this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); } } @@ -1184,10 +1188,7 @@ private void StopTracking() MessageBoxButton.YesNoCancel, ExtendedMessageBoxImage.Hand); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => - { - answer = messageBox.Result; - }; + messageBox.Closed += (_, _) => { answer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); while (answer == null && !SleepScheduler.IsShutdownInProgress) @@ -1209,12 +1210,13 @@ private void StopTracking() catch (Exception ex) { Debug.WriteLine("Error saving flight: " + ex); - this.StopTrackingCommand.ReportProgress(() => - { - var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error saving flight", ex.Message, ExtendedMessageBoxImage.Error, 30); - notification.SetErrorColorStyle(); - this.ViewReference.ShowNotification(notification); - }); + this.StopTrackingCommand.ReportProgress( + () => + { + var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error saving flight", ex.Message, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + }); } } else @@ -1231,12 +1233,13 @@ private void StopTracking() catch (Exception ex) { Debug.WriteLine("Error stopping tracking: " + ex); - this.StopTrackingCommand.ReportProgress(() => - { - var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error stopping tracking", ex.Message, ExtendedMessageBoxImage.Error, 30); - notification.SetErrorColorStyle(); - this.ViewReference.ShowNotification(notification); - }); + this.StopTrackingCommand.ReportProgress( + () => + { + var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error stopping tracking", ex.Message, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + }); } } } @@ -1273,13 +1276,13 @@ private void ToggleFlightPause() catch (Exception ex) { Debug.WriteLine("Error pausing/resuming sim: " + ex); - this.ToggleFlightPauseCommand.ReportProgress(() => - { - var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error pausing/resuming simulator", ex.Message, ExtendedMessageBoxImage.Error, 30); - notification.SetErrorColorStyle(); - this.ViewReference.ShowNotification(notification); - }); - + this.ToggleFlightPauseCommand.ReportProgress( + () => + { + var notification = new OpenSkyNotification(new ErrorDetails { DetailedMessage = ex.Message, Exception = ex }, "Error pausing/resuming simulator", ex.Message, ExtendedMessageBoxImage.Error, 30); + notification.SetErrorColorStyle(); + this.ViewReference.ShowNotification(notification); + }); } } diff --git a/changelog.txt b/changelog.txt index 6de2736..19b7cf7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,20 @@ ====================================================================================== -OpenSky Agent for MSFS Changelog +OpenSky Flight Tracking Agent Changelog ====================================================================================== +-------------------------------------------------------------------------------------- +Version 0.5.0 (ALPHA5) +-------------------------------------------------------------------------------------- +- Updated libraries to fix security issues and bugs +- Added CG slider to advanced weight and balance section +- Fixed w&b section still using simconnect instead of unified sim interface +- New design for aircraft position arrow +- Added update aircraft type, both for adding new updated type and added db upgrade + panel from client as well +- Fixed departure range bug in flight state code +- Added support for newly cleaned up payload station names +- Support for actualy missing manufacturer instead of dummy one + -------------------------------------------------------------------------------------- Version 0.4.5 (ALPHA4) --------------------------------------------------------------------------------------