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<object> 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<object>();
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.X<map.ActualWidth-300&&point.Y>100&&point.Y<map.ActualHeight-120);
Require(hit is not null,"The atlas has an unobstructed clickable catalogue marker.");
var expected=Core.Rendering.LocalSystemScene.HitTest(map.InteractiveLocations,hit!.X,hit.Y).First();
map.SelectAtForProbe(new(hit.X,hit.Y));await Task.Delay(60);
Require(ViewModel.RemoteMapSelection?.Record.Identity==expected.Node.Location.Identity,"Production 3D hit testing updates the catalogue selection.");
map.ResetCamera();map.RenderNowForProbe();allModels=map.ProjectedLocations.Count;
ViewModel.RemoteMapSearch=selected.Record.Name;await Capture("atlas-search");
Require(map.ProjectedLocations.Count==allModels&&map.MarkerLocations.All(point=>point.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<DependencyObject> Descendants(DependencyObject parent)
{for(var i=0;i<VisualTreeHelper.GetChildrenCount(parent);i++){var child=VisualTreeHelper.GetChild(parent,i);yield return child;foreach(var nested in Descendants(child))yield return nested;}}
var central=Descendants(navigation).OfType<ProgressRing>().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};
}
}
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<object> 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<object>();
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.X<map.ActualWidth-300&&point.Y>100&&point.Y<map.ActualHeight-120);
Require(hit is not null,"The atlas has an unobstructed clickable catalogue marker.");
var expected=Core.Rendering.LocalSystemScene.HitTest(map.InteractiveLocations,hit!.X,hit.Y).First();
map.SelectAtForProbe(new(hit.X,hit.Y));await Task.Delay(60);
Require(ViewModel.RemoteMapSelection?.Record.Identity==expected.Node.Location.Identity,"Production 3D hit testing updates the catalogue selection.");
map.ResetCamera();map.RenderNowForProbe();allModels=map.ProjectedLocations.Count;
ViewModel.RemoteMapSearch=selected.Record.Name;await Capture("atlas-search");
Require(map.ProjectedLocations.Count==allModels&&map.MarkerLocations.All(point=>point.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<DependencyObject> Descendants(DependencyObject parent)
{for(var i=0;i<VisualTreeHelper.GetChildrenCount(parent);i++){var child=VisualTreeHelper.GetChild(parent,i);yield return child;foreach(var nested in Descendants(child))yield return nested;}}
var central=Descendants(navigation).OfType<ProgressRing>().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};
}
}