using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Seyounth.Hyosung.UI.Services; using Seyounth.Hyosung.UI.ViewModels.Pages; using Seyounth.Hyosung.UI.ViewModels.Windows; using Seyounth.Hyosung.UI.Views.Pages; using Seyounth.Hyosung.UI.Views.Windows; using System.IO; using System.Reflection; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Threading; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using Seyounth.Hyosung.Core.Printer; using Seyounth.Hyosung.Runtime; using Wpf.Ui; namespace Seyounth.Hyosung.UI { /// /// Interaction logic for App.xaml /// public partial class App { private static IHost _host; public App() { var builder = Host .CreateApplicationBuilder(); builder.Logging.ClearProviders(); builder.Logging.SetMinimumLevel(LogLevel.Trace); builder.Logging.AddNLog("nlog.config"); builder.Configuration.AddJsonFile("PrintTemp.json", true, true); builder.Configuration.AddJsonFile("appsettings.json", true, true); builder.Services.Configure(builder.Configuration.GetSection("Print")); builder.Services.AddHostedService(); // Page resolver service builder.Services.AddSingleton(); builder.Services.AddSingleton(); // Theme manipulation builder.Services.AddSingleton(); // TaskBar manipulation builder.Services.AddSingleton(); // Service containing navigation, same as INavigationWindow... but without window builder.Services.AddSingleton(); // Main window with navigation builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddHyosung(builder.Configuration); _host = builder.Build(); } /// /// Gets registered service. /// /// Type of the service to get. /// Instance of the service or . public static T GetService() where T : class { return _host.Services.GetService(typeof(T)) as T; } /// /// Occurs when the application is loading. /// private void OnStartup(object sender, StartupEventArgs e) { RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.Default; _host.Services.UseHyosung(); _host.Start(); } /// /// Occurs when the application is closing. /// private async void OnExit(object sender, ExitEventArgs e) { await _host.StopAsync(); _host.Dispose(); } /// /// Occurs when an exception is thrown by an application but not handled. /// private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { // For more info see https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?view=windowsdesktop-6.0 } } }