using System.Text.Json; using XFEEDToolBox.Controls; using XFEEDToolBox.Views; namespace XFEEDToolBox; public partial class App { private static async Task RunShipStatusProbeAsync(string reportPath) { var dir=Path.GetDirectoryName(Path.GetFullPath(reportPath))!;Directory.CreateDirectory(dir); var system=Runtime.Player.Navigation.CurrentSystemAddress;var jump=Runtime.Player.Navigation.LastJumpAt; object? readings=null;string? failure=null; try { MainWindow.AppWindow.Move(new(-30000,-30000));MainWindow.AppWindow.Resize(new(1600,1150));MainWindow.AppWindow.Show(false); AppShellPage.Current!.Navigate(typeof(ShipPage));await Task.Delay(1500); var page=AppShellPage.Current.CurrentPage!;var panel=Descendants(page).OfType().Single(); var tabs=(SelectorBar)panel.FindName("StatusTabs"); if(ViewModel.LiveFlightStatus.Count<15||ViewModel.LiveCockpitStatus.Count<20)throw new InvalidOperationException("Ship status rows failed to load."); var first=ViewModel.LiveFlightStatus.First();var resets=0; System.Collections.Specialized.NotifyCollectionChangedEventHandler changed=(_,_)=>resets++; ViewModel.LiveFlightStatus.CollectionChanged+=changed;await Task.Delay(700);ViewModel.LiveFlightStatus.CollectionChanged-=changed; if(resets!=0||!ReferenceEquals(first,ViewModel.LiveFlightStatus.First()))throw new InvalidOperationException("Live ship status reset its list."); await CaptureRefinementElementAsync(panel,Path.Combine(dir,"ship-properties.png")); tabs.SelectedItem=tabs.Items[1];await Task.Delay(100); await CaptureRefinementElementAsync(panel,Path.Combine(dir,"flight-status.png")); tabs.SelectedItem=tabs.Items[2];await Task.Delay(100); if(((FrameworkElement)panel.FindName("AmmoView")).Visibility!=Visibility.Visible)throw new InvalidOperationException("Ammo tab failed."); await CaptureRefinementElementAsync(panel,Path.Combine(dir,"ammunition.png")); tabs.SelectedItem=tabs.Items[3];await Task.Delay(100);await CaptureRefinementElementAsync(panel,Path.Combine(dir,"cockpit-status.png")); readings=new{state=ViewModel.ShipTelemetryStatus,flight=ViewModel.LiveFlightStatus.Select(r=>r.Record),cockpit=ViewModel.LiveCockpitStatus.Select(r=>r.Record),ammo=ViewModel.LiveShipAmmunition.Select(r=>r.Record),collectionEvents=resets}; AppShellPage.Current.Navigate(typeof(MainPage));await Task.Delay(250); if(!Descendants(AppShellPage.Current.CurrentPage).OfType().Any())throw new InvalidOperationException("Home ship status entry is missing."); if(Runtime.Player.Navigation.CurrentSystemAddress!=system||Runtime.Player.Navigation.LastJumpAt!=jump)throw new InvalidOperationException("Game location changed during read-only status verification."); } catch(Exception error){failure=error.ToString();} await File.WriteAllTextAsync(reportPath,JsonSerializer.Serialize(new{passed=failure is null,failure,readings,system,actualSystem=Runtime.Player.Navigation.CurrentSystemAddress,screenUse=false,osInputSent=false,flightCommands=0},new JsonSerializerOptions{WriteIndented=true})); MainWindow.Close(); } }