2025-04-07 23:25:45 +08:00
|
|
|
|
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;
|
2025-04-10 16:20:00 +08:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Animation;
|
2025-04-07 23:25:45 +08:00
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for App.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
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<PrintTemp>(builder.Configuration.GetSection("Print"));
|
|
|
|
|
builder.Services.AddHostedService<ApplicationHostService>();
|
|
|
|
|
|
|
|
|
|
// Page resolver service
|
|
|
|
|
builder.Services.AddSingleton<IPageService, PageService>();
|
|
|
|
|
builder.Services.AddSingleton<ISnackbarService, SnackbarService>();
|
|
|
|
|
// Theme manipulation
|
|
|
|
|
builder.Services.AddSingleton<IThemeService, ThemeService>();
|
|
|
|
|
|
|
|
|
|
// TaskBar manipulation
|
|
|
|
|
builder.Services.AddSingleton<ITaskBarService, TaskBarService>();
|
|
|
|
|
|
|
|
|
|
// Service containing navigation, same as INavigationWindow... but without window
|
|
|
|
|
builder.Services.AddSingleton<INavigationService, NavigationService>();
|
|
|
|
|
|
|
|
|
|
// Main window with navigation
|
|
|
|
|
builder.Services.AddSingleton<INavigationWindow, MainWindow>();
|
|
|
|
|
builder.Services.AddSingleton<MainWindowViewModel>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddSingleton<DashboardPage>();
|
|
|
|
|
builder.Services.AddSingleton<DashboardViewModel>();
|
|
|
|
|
builder.Services.AddSingleton<DataPage>();
|
|
|
|
|
builder.Services.AddSingleton<DataViewModel>();
|
|
|
|
|
builder.Services.AddSingleton<SettingsPage>();
|
|
|
|
|
builder.Services.AddSingleton<SettingsViewModel>();
|
|
|
|
|
builder.Services.AddSingleton<PalletManagementPage>();
|
|
|
|
|
builder.Services.AddSingleton<PalletManagementViewModel>();
|
2025-04-10 16:20:00 +08:00
|
|
|
|
builder.Services.AddSingleton<AgvBinPage>();
|
|
|
|
|
builder.Services.AddSingleton<AgvBinViewModel>();
|
2025-04-07 23:25:45 +08:00
|
|
|
|
builder.Services.AddHyosung(builder.Configuration);
|
|
|
|
|
_host = builder.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets registered service.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">Type of the service to get.</typeparam>
|
|
|
|
|
/// <returns>Instance of the service or <see langword="null"/>.</returns>
|
|
|
|
|
public static T GetService<T>()
|
|
|
|
|
where T : class
|
|
|
|
|
{
|
|
|
|
|
return _host.Services.GetService(typeof(T)) as T;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when the application is loading.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void OnStartup(object sender, StartupEventArgs e)
|
|
|
|
|
{
|
2025-04-10 16:20:00 +08:00
|
|
|
|
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.Default;
|
2025-04-07 23:25:45 +08:00
|
|
|
|
_host.Services.UseHyosung();
|
|
|
|
|
_host.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when the application is closing.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void OnExit(object sender, ExitEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
await _host.StopAsync();
|
|
|
|
|
|
|
|
|
|
_host.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when an exception is thrown by an application but not handled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|