using System.Text.Json;
using XFEEDToolBox.Controls;
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunGalaxyBlackHoleProbeAsync(string directory,IReadOnlyList<GalacticSystem> recorded)
{
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
var candidates=recorded.Where(s=>s.SystemAddress is >0&&s.Position.IsValid).ToArray();
var actual=candidates.FirstOrDefault(s=>string.Equals(s.StarClass,"H",StringComparison.OrdinalIgnoreCase))??candidates.First();
// The name, address, star class and coordinates remain captured data.
// Classification41, RGBA and physical size are explicit test inputs;
// this does not establish an observed black hole at this address.
var appearance=new GalaxyOriginalStellarAppearance(0xffe0b070,0xffe0b070,1,1,41,.7f,.7f,false);
var target=actual with{OriginalAppearance=appearance};
var previous=MainWindow.Content;var host=new Grid();var map=new GalaxyMapView();host.Children.Add(map);MainWindow.Content=host;
var observations=new Dictionary<string,object>();
async Task Save(string name)
{
map.RenderNowForProbe();var pixels=map.CapturePixelsForProbe();
var peak=0;var nonBlack=0;
for(var i=0;i<pixels.Pixels.Length;i+=4)
{var rgb=Math.Max(pixels.Pixels[i],Math.Max(pixels.Pixels[i+1],pixels.Pixels[i+2]));peak=Math.Max(peak,rgb);if(rgb>0)nonBlack++;}
observations[name]=new{pixels.Width,pixels.Height,submittedBlackHoles=map.OriginalBlackHolesDrawnForProbe,
retainedModelHits=map.VisibleStars,nameLabels=map.VisibleNameLabels,gpuPeakRgb=peak,gpuNonBlackPixels=nonBlack,
submissionIsNotPixelVisibility=true};
using(await map.FreezeForXamlProbeAsync())await CaptureRefinementElementAsync(host,Path.Combine(directory,name+".png"));
}
try
{
var basis=GalaxyMapFilter.Default with{Mode=GalaxyMapMode.Realistic,Values=null,ShowLabels=true,ShowMarkers=false,
ShowRoute=true,ShowBackground=false,ShowGrid=false,ShowLinks=false,ShowConstellations=false,
ShowCurrentTradeFlows=false,ShowHistoricalTradeFlows=false,ShowRegionNames=false,ShowNebulaNames=false,
ShowGalacticZonesPlane=false,ShowGalacticZoneNames=false};
map.Filter=basis;map.Systems=[target];
await Task.Delay(180);map.SetCameraPoseForProbe(new(actual.Position,0,0,24));map.RenderNowForProbe();
Require(!map.CameraMotionPendingForProbe&&map.OriginalBlackHolesDrawnForProbe==1&&map.VisibleStars==1&&map.VisibleNameLabels==1,
"Realistic NavigationMarkers did not submit the synthetic physical black hole and its actual recorded name independently of ShowMarkers.");
map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection?.SystemAddress==target.SystemAddress,"The retained black-hole fixture did not preserve the exact recorded hit.");
map.ClearSelection();map.RenderNowForProbe();await Save("black-hole-near");
map.Filter=basis with{ShowRoute=false,ShowMarkers=true};map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==1&&map.VisibleNameLabels==1,
"The general marker switch replaced the independent NavigationMarkers gate for the special GPU pass.");
await Save("black-hole-no-special");
// A non-black original background exposes a destination-alpha
// rectangular wipe that an all-black source fixture cannot reveal.
map.Filter=basis with{ShowBackground=true};map.RenderNowForProbe();
for(var wait=0;map.OriginalMilkyWayLoadPendingForProbe&&wait<100;wait++){await Task.Delay(20);map.RenderNowForProbe();}
Require(map.OriginalBlackHolesDrawnForProbe==1,"The original background prevented the black-hole material from being submitted.");
await Save("black-hole-background");
map.Filter=map.Filter with{ShowRoute=false};map.RenderNowForProbe();await Save("black-hole-background-no-special");
map.Filter=basis with{Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.StarClass};map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==1&&map.VisibleNameLabels==1,
"Classified mode submitted the separate physical black-hole material or lost the ordinary classified point.");
map.Filter=map.Filter with{Values=new HashSet<string>(),IncludeUnknown=false};map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==0&&map.VisibleNameLabels==0&&map.FilteredModels==0,
"The special physical type bypassed an empty strict classified filter.");
map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection is null,"The strict hidden black-hole fixture retained a hit.");
await Save("black-hole-strict-empty");
map.Filter=basis;map.Systems=[target with{OriginalAppearance=appearance with{RealisticRgba=0x00e0b070}}];map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==0&&map.VisibleNameLabels==0,
"An explicit original alpha-zero style retained a black-hole model, name or GPU submission.");
map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection is null,"An alpha-zero black hole retained a hit.");
map.Systems=[target with{OriginalAppearance=appearance with{Classification=4}}];map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==1,"A non-special physical classification entered the separate black-hole material.");
var result=new{actual.Name,actual.SystemAddress,actual.Position,recordedStarClass=actual.StarClass,
classificationExplicitSyntheticFixture=41,physicalSizeExplicitSyntheticFixture=.7f,appearanceRgbaExplicitSyntheticFixture=true,
fixtureIsNotObservedBlackHole=true,generatedCatalogueCoordinates=false,cameraPoseExplicitFixture=true,cameraDistance=24,
realisticNavigationMarkersSubmitsOne=true,generalMarkerSwitchIndependent=true,navigationMarkersOffSubmitsNone=true,
classifiedUsesOrdinaryPoint=true,ordinaryClassificationHasNoSpecialSubmission=true,
strictEmptyNoSpecialModelLabelOrHit=true,explicitOriginalAlphaZeroNoModelLabelOrHit=true,
submissionCountDoesNotEstablishPixelVisibility=true,observations,gameAccess=false};
await File.WriteAllTextAsync(Path.Combine(directory,"black-hole-probe.json"),JsonSerializer.Serialize(result,new JsonSerializerOptions{WriteIndented=true}));
return result;
}
finally{map.SuspendPage();MainWindow.Content=previous;}
}
}
using System.Text.Json;
using XFEEDToolBox.Controls;
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunGalaxyBlackHoleProbeAsync(string directory,IReadOnlyList<GalacticSystem> recorded)
{
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
var candidates=recorded.Where(s=>s.SystemAddress is >0&&s.Position.IsValid).ToArray();
var actual=candidates.FirstOrDefault(s=>string.Equals(s.StarClass,"H",StringComparison.OrdinalIgnoreCase))??candidates.First();
// The name, address, star class and coordinates remain captured data.
// Classification41, RGBA and physical size are explicit test inputs;
// this does not establish an observed black hole at this address.
var appearance=new GalaxyOriginalStellarAppearance(0xffe0b070,0xffe0b070,1,1,41,.7f,.7f,false);
var target=actual with{OriginalAppearance=appearance};
var previous=MainWindow.Content;var host=new Grid();var map=new GalaxyMapView();host.Children.Add(map);MainWindow.Content=host;
var observations=new Dictionary<string,object>();
async Task Save(string name)
{
map.RenderNowForProbe();var pixels=map.CapturePixelsForProbe();
var peak=0;var nonBlack=0;
for(var i=0;i<pixels.Pixels.Length;i+=4)
{var rgb=Math.Max(pixels.Pixels[i],Math.Max(pixels.Pixels[i+1],pixels.Pixels[i+2]));peak=Math.Max(peak,rgb);if(rgb>0)nonBlack++;}
observations[name]=new{pixels.Width,pixels.Height,submittedBlackHoles=map.OriginalBlackHolesDrawnForProbe,
retainedModelHits=map.VisibleStars,nameLabels=map.VisibleNameLabels,gpuPeakRgb=peak,gpuNonBlackPixels=nonBlack,
submissionIsNotPixelVisibility=true};
using(await map.FreezeForXamlProbeAsync())await CaptureRefinementElementAsync(host,Path.Combine(directory,name+".png"));
}
try
{
var basis=GalaxyMapFilter.Default with{Mode=GalaxyMapMode.Realistic,Values=null,ShowLabels=true,ShowMarkers=false,
ShowRoute=true,ShowBackground=false,ShowGrid=false,ShowLinks=false,ShowConstellations=false,
ShowCurrentTradeFlows=false,ShowHistoricalTradeFlows=false,ShowRegionNames=false,ShowNebulaNames=false,
ShowGalacticZonesPlane=false,ShowGalacticZoneNames=false};
map.Filter=basis;map.Systems=[target];
await Task.Delay(180);map.SetCameraPoseForProbe(new(actual.Position,0,0,24));map.RenderNowForProbe();
Require(!map.CameraMotionPendingForProbe&&map.OriginalBlackHolesDrawnForProbe==1&&map.VisibleStars==1&&map.VisibleNameLabels==1,
"Realistic NavigationMarkers did not submit the synthetic physical black hole and its actual recorded name independently of ShowMarkers.");
map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection?.SystemAddress==target.SystemAddress,"The retained black-hole fixture did not preserve the exact recorded hit.");
map.ClearSelection();map.RenderNowForProbe();await Save("black-hole-near");
map.Filter=basis with{ShowRoute=false,ShowMarkers=true};map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==1&&map.VisibleNameLabels==1,
"The general marker switch replaced the independent NavigationMarkers gate for the special GPU pass.");
await Save("black-hole-no-special");
// A non-black original background exposes a destination-alpha
// rectangular wipe that an all-black source fixture cannot reveal.
map.Filter=basis with{ShowBackground=true};map.RenderNowForProbe();
for(var wait=0;map.OriginalMilkyWayLoadPendingForProbe&&wait<100;wait++){await Task.Delay(20);map.RenderNowForProbe();}
Require(map.OriginalBlackHolesDrawnForProbe==1,"The original background prevented the black-hole material from being submitted.");
await Save("black-hole-background");
map.Filter=map.Filter with{ShowRoute=false};map.RenderNowForProbe();await Save("black-hole-background-no-special");
map.Filter=basis with{Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.StarClass};map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==1&&map.VisibleNameLabels==1,
"Classified mode submitted the separate physical black-hole material or lost the ordinary classified point.");
map.Filter=map.Filter with{Values=new HashSet<string>(),IncludeUnknown=false};map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==0&&map.VisibleNameLabels==0&&map.FilteredModels==0,
"The special physical type bypassed an empty strict classified filter.");
map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection is null,"The strict hidden black-hole fixture retained a hit.");
await Save("black-hole-strict-empty");
map.Filter=basis;map.Systems=[target with{OriginalAppearance=appearance with{RealisticRgba=0x00e0b070}}];map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==0&&map.VisibleNameLabels==0,
"An explicit original alpha-zero style retained a black-hole model, name or GPU submission.");
map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection is null,"An alpha-zero black hole retained a hit.");
map.Systems=[target with{OriginalAppearance=appearance with{Classification=4}}];map.RenderNowForProbe();
Require(map.OriginalBlackHolesDrawnForProbe==0&&map.VisibleStars==1,"A non-special physical classification entered the separate black-hole material.");
var result=new{actual.Name,actual.SystemAddress,actual.Position,recordedStarClass=actual.StarClass,
classificationExplicitSyntheticFixture=41,physicalSizeExplicitSyntheticFixture=.7f,appearanceRgbaExplicitSyntheticFixture=true,
fixtureIsNotObservedBlackHole=true,generatedCatalogueCoordinates=false,cameraPoseExplicitFixture=true,cameraDistance=24,
realisticNavigationMarkersSubmitsOne=true,generalMarkerSwitchIndependent=true,navigationMarkersOffSubmitsNone=true,
classifiedUsesOrdinaryPoint=true,ordinaryClassificationHasNoSpecialSubmission=true,
strictEmptyNoSpecialModelLabelOrHit=true,explicitOriginalAlphaZeroNoModelLabelOrHit=true,
submissionCountDoesNotEstablishPixelVisibility=true,observations,gameAccess=false};
await File.WriteAllTextAsync(Path.Combine(directory,"black-hole-probe.json"),JsonSerializer.Serialize(result,new JsonSerializerOptions{WriteIndented=true}));
return result;
}
finally{map.SuspendPage();MainWindow.Content=previous;}
}
}