using System.Text.Json; using Microsoft.UI.Xaml.Media; using XFEEDToolBox.Core.Galaxy; using XFEEDToolBox.Core.Navigation; using XFEEDToolBox.Views; namespace XFEEDToolBox; public partial class App { private static async Task RunSystemAtlasProbeAsync(string directory) { if(!ViewModel.OfflinePreview)throw new InvalidOperationException("Atlas acceptance requires an isolated offline profile."); var args=Environment.GetCommandLineArgs(); using var bodies=JsonDocument.Parse(await File.ReadAllTextAsync(GetArgument(args,"--atlas-bodies")??throw new ArgumentException("Recorded public bodies required."))); using var stations=JsonDocument.Parse(await File.ReadAllTextAsync(GetArgument(args,"--atlas-stations")??throw new ArgumentException("Recorded public stations required."))); var system=new GalacticSystem(bodies.RootElement.GetProperty("name").GetString()!,new(0,0,0),bodies.RootElement.GetProperty("id64").GetInt64(),Source:"公开目录离线核验"); var atlas=SystemMapCatalogueClient.Parse(system,bodies.RootElement,stations.RootElement); ViewModel.SetSystemMapCatalogueForProbe(atlas);AppShellPage.Current!.Navigate(typeof(SystemMapCataloguePage));await Task.Delay(250); var page=(SystemMapCataloguePage)AppShellPage.Current.CurrentPage!;var map=page.MapForProbe;var checks=new List(); void Require(bool condition,string description){checks.Add(new{passed=condition,description});if(!condition)throw new InvalidOperationException(description);} async Task Capture(string name) { await Task.Delay(120);page.UpdateLayout();map.RenderNowForProbe();using var frozen=await map.FreezeForXamlProbeAsync(); await CapturePageAsync(page,Path.Combine(directory,name+".png")); } await Capture("atlas-overview"); Require(atlas.Preview.DisplayOnly&&atlas.Preview.Orbits.Count==0,"Public positions are explicitly illustrative; unknown orbital planes are not presented as verified orbits."); Require(Math.Abs(map.ActualWidth-page.ActualWidth)<2&&Math.Abs(map.ActualHeight-page.ActualHeight)<2,"The atlas viewport fills its page behind both floating panels."); var allModels=map.ProjectedLocations.Count; var selected=ViewModel.RemoteMapLocations.First(row=>atlas.Stations.ContainsKey(row.Record.Identity)&&!atlas.Stations[row.Record.Identity].IsPlanetary); ViewModel.RemoteMapSelection=selected;await Capture("atlas-station-selected"); Require(map.ProjectedLocations.Any(point=>point.Selected&&point.Node.Location.Identity==selected.Record.Identity),"Selecting a catalogue station updates the map selection."); var hit=map.InteractiveLocations.FirstOrDefault(point=>point.X>340&&point.X100&&point.Ypoint.Node.Location.Name.Contains(selected.Record.Name,StringComparison.OrdinalIgnoreCase)),"Search hides icons and names while retaining all 3D bodies."); ViewModel.RemoteMapSearch="";MainWindow.AppWindow.Resize(new(1280,800));await Capture("atlas-1280"); Require(!ViewModel.StartRemoteJourneyCommand.CanExecute(null)&&!Runtime.FlightAutomation.IsActive,"Offline browsing cannot start a flight or submit a trade."); ViewModel.GalaxyCatalogueBusy=true;ViewModel.GalaxyBusy=false;AppShellPage.Current.Navigate(typeof(NavigationPage));await Task.Delay(180); var navigation=(NavigationPage)AppShellPage.Current.CurrentPage!; IEnumerable Descendants(DependencyObject parent) {for(var i=0;i().Where(ring=>ring.IsActive&&ring.ActualWidth>0&&ring.ActualHeight>0) .Any(ring=>{var point=ring.TransformToVisual(navigation).TransformPoint(new(0,0));return Math.Abs(point.X+ring.ActualWidth*.5-navigation.ActualWidth*.5)<40&&Math.Abs(point.Y+ring.ActualHeight*.5-navigation.ActualHeight*.5)<40;}); Require(ViewModel.GalaxyLoading&&!central,"Background catalogue activity has no spinning progress ring in the middle of the galaxy map."); await CapturePageAsync(navigation,Path.Combine(directory,"galaxy-background-loading.png"));ViewModel.GalaxyCatalogueBusy=false; return new{checks,stationCount=atlas.Stations.Count,bodyAndStationCount=atlas.Preview.Locations.Count,gameCommandsInvoked=false,tradeOrdersSubmitted=false,previewPositionsAreIllustrative=true}; } }