2021-12-11 21:47:59 -05:00
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
|
|
using Avalonia.Markup.Xaml;
|
2021-12-25 20:24:00 -05:00
|
|
|
using PatchGenerator.Models;
|
2021-12-11 21:47:59 -05:00
|
|
|
using PatchGenerator.ViewModels;
|
|
|
|
using PatchGenerator.Views;
|
2023-09-04 16:12:31 -04:00
|
|
|
using ReactiveUI;
|
|
|
|
using System.Reactive;
|
|
|
|
using System;
|
|
|
|
using PatcherUtils.Model;
|
2021-12-11 21:47:59 -05:00
|
|
|
|
|
|
|
namespace PatchGenerator
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2021-12-25 20:24:00 -05:00
|
|
|
desktop.Startup += Desktop_Startup;
|
|
|
|
}
|
|
|
|
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Desktop_Startup(object? sender, ControlledApplicationLifetimeStartupEventArgs e)
|
|
|
|
{
|
|
|
|
if (sender is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
|
|
|
GenStartupArgs genArgs = GenStartupArgs.Parse(e.Args);
|
|
|
|
|
2021-12-11 21:47:59 -05:00
|
|
|
desktop.MainWindow = new MainWindow
|
|
|
|
{
|
2021-12-25 20:24:00 -05:00
|
|
|
DataContext = new MainWindowViewModel(genArgs)
|
2021-12-11 21:47:59 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|