XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Text.Json;
using XFEEDToolBox.Views;

namespace XFEEDToolBox;

public partial class App
{
    private static async Task RunSystemReadCheckAsync(string reportPath)
    {
        var samples=new List<object>();var directory=Path.GetDirectoryName(Path.GetFullPath(reportPath))!;Directory.CreateDirectory(directory);
        MainWindow.AppWindow.Move(new(-30000,-30000));MainWindow.AppWindow.Resize(new(1900,1200));MainWindow.AppWindow.Show(false);
        AppShellPage.Current!.Navigate(typeof(CurrentSystemPage));
        for(var i=0;i<6;i++)
        {
            await ViewModel.RefreshCurrentSystemCommand.ExecuteAsync(null);
            samples.Add(new{time=DateTimeOffset.UtcNow,ViewModel.CurrentSystemTitle,ViewModel.CurrentSystemStatus,ViewModel.CurrentSystemReading,
                count=ViewModel.CurrentSystemLocations.Count,ViewModel.SystemFlightReady,ViewModel.SystemFlightStatus,ViewModel.PluginNavigationReady,
                ViewModel.NavigationNativeStatus,ViewModel.PluginStatusText,ViewModel.HasError,ViewModel.ErrorMessage});
            await File.WriteAllTextAsync(reportPath,JsonSerializer.Serialize(new{pid=Environment.ProcessId,gameFlightCommandsInvoked=false,samples,activity=Runtime.Activity.Take(10)},new JsonSerializerOptions{WriteIndented=true}));
            await Task.Delay(1200);
        }
        await CapturePageAsync(AppShellPage.Current!,Path.Combine(directory,"current-system-live.png"));MainWindow.Close();
    }
}