2021-12-11 21:47:59 -05:00
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
using PatchClient.ViewModels;
|
|
|
|
using PatchClient.Views;
|
2023-09-04 16:12:31 -04:00
|
|
|
using ReactiveUI;
|
|
|
|
using System.Reactive;
|
|
|
|
using System;
|
2023-11-09 20:49:40 -05:00
|
|
|
using System.Linq;
|
2023-11-17 11:33:19 -05:00
|
|
|
using System.Reflection;
|
2023-09-04 16:12:31 -04:00
|
|
|
using PatcherUtils.Model;
|
2021-12-11 21:47:59 -05:00
|
|
|
|
|
|
|
namespace PatchClient
|
|
|
|
{
|
|
|
|
public class App : Application
|
|
|
|
{
|
|
|
|
public override void Initialize()
|
|
|
|
{
|
|
|
|
AvaloniaXamlLoader.Load(this);
|
2023-09-04 16:12:31 -04:00
|
|
|
|
|
|
|
RxApp.DefaultExceptionHandler = Observer.Create<Exception>((exception) =>
|
|
|
|
{
|
|
|
|
PatchLogger.LogException(exception);
|
|
|
|
});
|
2021-12-11 21:47:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnFrameworkInitializationCompleted()
|
|
|
|
{
|
|
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
2022-05-15 17:36:16 -04:00
|
|
|
bool autoClose = false;
|
2023-11-09 20:49:40 -05:00
|
|
|
bool debugOutput = false;
|
2022-05-15 17:36:16 -04:00
|
|
|
|
2023-11-09 20:49:40 -05:00
|
|
|
if (desktop.Args != null && desktop.Args.Length >= 1)
|
|
|
|
{
|
|
|
|
autoClose = desktop.Args.Any(x => x.ToLower() == "autoclose");
|
|
|
|
debugOutput = desktop.Args.Any(x => x.ToLower() == "debug");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (debugOutput)
|
|
|
|
{
|
|
|
|
PatchLogger.LogInfo("Running in debug mode");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (autoClose)
|
|
|
|
{
|
|
|
|
PatchLogger.LogInfo("Running with autoclose");
|
|
|
|
}
|
2022-05-15 17:36:16 -04:00
|
|
|
|
2023-11-17 11:33:19 -05:00
|
|
|
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
|
|
|
|
|
|
|
PatchLogger.LogInfo($"Patch Client v{version?.ToString() ?? "N/A"}");
|
|
|
|
|
2021-12-11 21:47:59 -05:00
|
|
|
desktop.MainWindow = new MainWindow
|
|
|
|
{
|
2023-11-09 20:49:40 -05:00
|
|
|
DataContext = new MainWindowViewModel(autoClose, debugOutput),
|
2021-12-11 21:47:59 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|