using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Automation.Provider;
using XFEEDToolBox.Core.Engineering;
using XFEEDToolBox.Views;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunUpgradeListProbeAsync()
{
var before=ViewModel.UpgradeEntries.Count;
ViewModel.EngineeringType="Multi-cannon";ViewModel.EngineeringGrade=3;ViewModel.EngineeringQuality=100;
ViewModel.EngineeringSource=ViewModel.EngineeringSources.FirstOrDefault(s=>s.Key.Length==0);
ViewModel.EngineeringEngineer=ViewModel.CompatibleEngineers.FirstOrDefault(e=>e.Unlocked);
ViewModel.EngineeringCount=2;ViewModel.EngineeringPurchase=true;ViewModel.EngineeringPriceKnown=true;ViewModel.EngineeringUnitPrice=100000;
await ViewModel.AddEngineeringToListCommand.ExecuteAsync(null);
var added=ViewModel.UpgradeEntries.Count==before+1;
var button=Descendants(MainWindow.Content as FrameworkElement).OfType<Button>().FirstOrDefault(b=>b.Name=="UpgradeListButton");
if(button is not null&&new ButtonAutomationPeer(button).GetPattern(PatternInterface.Invoke) is IInvokeProvider invoke)invoke.Invoke();
await Task.Delay(150);
var titleButtonWorks=AppShellPage.Current?.CurrentPage is UpgradeListPage;
var rows=ViewModel.UpgradeNeeds.Select(r=>r.Record).ToArray();var collections=0;var updates=new List<string>();
var row=ViewModel.UpgradeNeeds.FirstOrDefault();var bound=false;
System.Collections.Specialized.NotifyCollectionChangedEventHandler collection=(_,_)=>collections++;
ViewModel.UpgradeNeeds.CollectionChanged+=collection;
if(row is not null)
{
row.PropertyChanged+=(_,e)=>updates.Add(e.PropertyName??"");
ViewModel.UpgradeNeeds.Apply(rows.Select(r=>r.Key==row.Key?r with{Owned=r.Owned+1}:r),false);await Task.Delay(120);
bound=Descendants(AppShellPage.Current!.CurrentPage).OfType<TextBlock>().Any(t=>t.Text==row.Detail);
}
ViewModel.UpgradeNeeds.CollectionChanged-=collection;ViewModel.UpgradeNeeds.Apply(rows,false);
return new{added,titleButtonWorks,entries=ViewModel.UpgradeEntries.Count,summary=ViewModel.UpgradeSummary,credits=ViewModel.UpgradeCreditSummary,materialRows=rows.Length,collectionEvents=collections,updatedProperties=updates,materialTextBound=bound,persistenceFiles=Directory.Exists(Path.Combine(Runtime.DataDirectory,"plans"))?Directory.GetFiles(Path.Combine(Runtime.DataDirectory,"plans"),"*.json").Length:0,gameActionsInvoked=false};
}
}
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Automation.Provider;
using XFEEDToolBox.Core.Engineering;
using XFEEDToolBox.Views;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunUpgradeListProbeAsync()
{
var before=ViewModel.UpgradeEntries.Count;
ViewModel.EngineeringType="Multi-cannon";ViewModel.EngineeringGrade=3;ViewModel.EngineeringQuality=100;
ViewModel.EngineeringSource=ViewModel.EngineeringSources.FirstOrDefault(s=>s.Key.Length==0);
ViewModel.EngineeringEngineer=ViewModel.CompatibleEngineers.FirstOrDefault(e=>e.Unlocked);
ViewModel.EngineeringCount=2;ViewModel.EngineeringPurchase=true;ViewModel.EngineeringPriceKnown=true;ViewModel.EngineeringUnitPrice=100000;
await ViewModel.AddEngineeringToListCommand.ExecuteAsync(null);
var added=ViewModel.UpgradeEntries.Count==before+1;
var button=Descendants(MainWindow.Content as FrameworkElement).OfType<Button>().FirstOrDefault(b=>b.Name=="UpgradeListButton");
if(button is not null&&new ButtonAutomationPeer(button).GetPattern(PatternInterface.Invoke) is IInvokeProvider invoke)invoke.Invoke();
await Task.Delay(150);
var titleButtonWorks=AppShellPage.Current?.CurrentPage is UpgradeListPage;
var rows=ViewModel.UpgradeNeeds.Select(r=>r.Record).ToArray();var collections=0;var updates=new List<string>();
var row=ViewModel.UpgradeNeeds.FirstOrDefault();var bound=false;
System.Collections.Specialized.NotifyCollectionChangedEventHandler collection=(_,_)=>collections++;
ViewModel.UpgradeNeeds.CollectionChanged+=collection;
if(row is not null)
{
row.PropertyChanged+=(_,e)=>updates.Add(e.PropertyName??"");
ViewModel.UpgradeNeeds.Apply(rows.Select(r=>r.Key==row.Key?r with{Owned=r.Owned+1}:r),false);await Task.Delay(120);
bound=Descendants(AppShellPage.Current!.CurrentPage).OfType<TextBlock>().Any(t=>t.Text==row.Detail);
}
ViewModel.UpgradeNeeds.CollectionChanged-=collection;ViewModel.UpgradeNeeds.Apply(rows,false);
return new{added,titleButtonWorks,entries=ViewModel.UpgradeEntries.Count,summary=ViewModel.UpgradeSummary,credits=ViewModel.UpgradeCreditSummary,materialRows=rows.Length,collectionEvents=collections,updatedProperties=updates,materialTextBound=bound,persistenceFiles=Directory.Exists(Path.Combine(Runtime.DataDirectory,"plans"))?Directory.GetFiles(Path.Combine(Runtime.DataDirectory,"plans"),"*.json").Length:0,gameActionsInvoked=false};
}
}