0
0
mirror of https://github.com/sp-tarkov/patcher.git synced 2025-02-13 07:30:45 -05:00
patcher/Patcher/PatchClient/App.axaml.cs

64 lines
1.8 KiB
C#
Raw Normal View History

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;
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;
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);
});
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
bool autoClose = false;
bool debugOutput = false;
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");
}
2023-11-17 11:33:19 -05:00
var version = Assembly.GetExecutingAssembly().GetName().Version;
PatchLogger.LogInfo($"Patch Client v{version?.ToString() ?? "N/A"}");
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(autoClose, debugOutput),
};
}
base.OnFrameworkInitializationCompleted();
}
}
}