using Microsoft.UI.Xaml;
using XFEExtension.NetCore.WinUIHelper.Utilities;
using XFEExtension.NetCore.WinUIHelper.Utilities.Helper;
using XFEWarframe.Admin.Interface.Services;
using XFEWarframe.Admin.Profiles.CrossVersionProfiles;
using XFEWarframe.Admin.Utilities;
using XFEWarframe.Admin.Views;
namespace XFEWarframe.Admin;
public partial class App : Application
{
private static readonly CancellationTokenSource lifetime = new();
public static CancellationToken Lifetime => lifetime.Token;
public static MainWindow MainWindow { get; private set; } = null!;
public static IAdminService Service { get; private set; } = null!;
public App()
{
AppPath.TraceVerification("App constructor");
if (AppPath.Argument("verify-ui") is not null)
{
DebugSettings.IsBindingTracingEnabled = true;
DebugSettings.BindingFailed += (_, args) => Utilities.Diagnostics.DesktopVerification.BindingErrors.Add(args.Message);
}
XFEWarframe.Desktop.Editing.UiText.Language = AppPath.Argument("ui-language") ?? SystemProfile.UiLanguage;
InitializeComponent();
AppPath.TraceVerification("App resources initialized");
PageManager.RegisterPage(typeof(AppShellPage));
PageManager.RegisterPage(typeof(MainPage));
PageManager.RegisterPage(typeof(PlayersPage));
PageManager.RegisterPage(typeof(InventoryPage));
PageManager.RegisterPage(typeof(EditorPage));
PageManager.RegisterPage(typeof(EquipmentPage));
PageManager.RegisterPage(typeof(PermissionsPage));
PageManager.RegisterPage(typeof(ServerSettingsPage));
PageManager.RegisterPage(typeof(RivenPage));
PageManager.RegisterPage(typeof(CatalogPage));
PageManager.RegisterPage(typeof(RoutesPage));
PageManager.RegisterPage(typeof(LogViewPage));
PageManager.RegisterPage(typeof(NewsPage));
PageManager.RegisterPage(typeof(MailPage));
PageManager.RegisterPage(typeof(SettingPage));
UnhandledException += (_, args) => AppPath.LogException(args.Exception);
TaskScheduler.UnobservedTaskException += (_, args) => { AppPath.LogException(args.Exception); args.SetObserved(); };
}
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
AppPath.TraceVerification("OnLaunched");
MainWindow = new MainWindow();
AppPath.TraceVerification("MainWindow created");
AppThemeHelper.MainWindow = MainWindow;
XFEWarframe.Desktop.Editing.FormDialogButton.ShowDialogAsync = ServiceManager.GetService<IInteractionService>().ShowAsync;
_ = ServiceManager.GetService<IAdminDialogService>();
Service = ServiceManager.GetService<IAdminService>();
MainWindow.Content = new AppShellPage();
AppPath.TraceVerification("AppShellPage attached");
AppThemeHelper.Theme = SystemProfile.Theme;
AppThemeHelper.ChangeTheme(SystemProfile.Theme);
AppPath.TraceVerification("Theme applied");
if (AppPath.Argument("verify-ui") is string report)
{
if (AppPath.Argument("verify-dialogs") == "true") { MainWindow.Activate(); MainWindow.AppWindow.Show(); for (var attempt = 0; attempt < 100 && ((FrameworkElement)MainWindow.Content).XamlRoot is null; attempt++) await Task.Delay(20); }
await Utilities.Diagnostics.DesktopVerification.RunAsync(report);
if (AppPath.Argument("verify-visible") == "true") { MainWindow.Activate(); return; }
await ShutdownAsync();
MainWindow.Close();
Exit();
}
else MainWindow.Activate();
}
public static async Task ShutdownAsync()
{
lifetime.Cancel();
try
{
await Service.StopAsync();
SystemProfile.SaveProfile();
}
catch (Exception ex) { AppPath.LogException(ex); }
}
}
using Microsoft.UI.Xaml;
using XFEExtension.NetCore.WinUIHelper.Utilities;
using XFEExtension.NetCore.WinUIHelper.Utilities.Helper;
using XFEWarframe.Admin.Interface.Services;
using XFEWarframe.Admin.Profiles.CrossVersionProfiles;
using XFEWarframe.Admin.Utilities;
using XFEWarframe.Admin.Views;
namespace XFEWarframe.Admin;
public partial class App : Application
{
private static readonly CancellationTokenSource lifetime = new();
public static CancellationToken Lifetime => lifetime.Token;
public static MainWindow MainWindow { get; private set; } = null!;
public static IAdminService Service { get; private set; } = null!;
public App()
{
AppPath.TraceVerification("App constructor");
if (AppPath.Argument("verify-ui") is not null)
{
DebugSettings.IsBindingTracingEnabled = true;
DebugSettings.BindingFailed += (_, args) => Utilities.Diagnostics.DesktopVerification.BindingErrors.Add(args.Message);
}
XFEWarframe.Desktop.Editing.UiText.Language = AppPath.Argument("ui-language") ?? SystemProfile.UiLanguage;
InitializeComponent();
AppPath.TraceVerification("App resources initialized");
PageManager.RegisterPage(typeof(AppShellPage));
PageManager.RegisterPage(typeof(MainPage));
PageManager.RegisterPage(typeof(PlayersPage));
PageManager.RegisterPage(typeof(InventoryPage));
PageManager.RegisterPage(typeof(EditorPage));
PageManager.RegisterPage(typeof(EquipmentPage));
PageManager.RegisterPage(typeof(PermissionsPage));
PageManager.RegisterPage(typeof(ServerSettingsPage));
PageManager.RegisterPage(typeof(RivenPage));
PageManager.RegisterPage(typeof(CatalogPage));
PageManager.RegisterPage(typeof(RoutesPage));
PageManager.RegisterPage(typeof(LogViewPage));
PageManager.RegisterPage(typeof(NewsPage));
PageManager.RegisterPage(typeof(MailPage));
PageManager.RegisterPage(typeof(SettingPage));
UnhandledException += (_, args) => AppPath.LogException(args.Exception);
TaskScheduler.UnobservedTaskException += (_, args) => { AppPath.LogException(args.Exception); args.SetObserved(); };
}
protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
AppPath.TraceVerification("OnLaunched");
MainWindow = new MainWindow();
AppPath.TraceVerification("MainWindow created");
AppThemeHelper.MainWindow = MainWindow;
XFEWarframe.Desktop.Editing.FormDialogButton.ShowDialogAsync = ServiceManager.GetService<IInteractionService>().ShowAsync;
_ = ServiceManager.GetService<IAdminDialogService>();
Service = ServiceManager.GetService<IAdminService>();
MainWindow.Content = new AppShellPage();
AppPath.TraceVerification("AppShellPage attached");
AppThemeHelper.Theme = SystemProfile.Theme;
AppThemeHelper.ChangeTheme(SystemProfile.Theme);
AppPath.TraceVerification("Theme applied");
if (AppPath.Argument("verify-ui") is string report)
{
if (AppPath.Argument("verify-dialogs") == "true") { MainWindow.Activate(); MainWindow.AppWindow.Show(); for (var attempt = 0; attempt < 100 && ((FrameworkElement)MainWindow.Content).XamlRoot is null; attempt++) await Task.Delay(20); }
await Utilities.Diagnostics.DesktopVerification.RunAsync(report);
if (AppPath.Argument("verify-visible") == "true") { MainWindow.Activate(); return; }
await ShutdownAsync();
MainWindow.Close();
Exit();
}
else MainWindow.Activate();
}
public static async Task ShutdownAsync()
{
lifetime.Cancel();
try
{
await Service.StopAsync();
SystemProfile.SaveProfile();
}
catch (Exception ex) { AppPath.LogException(ex); }
}
}