| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- using System;
- using System.Threading;
- using System.Windows;
- using CommonServiceLocator;
- using GSG.NET.Logging;
- using GSG.NET.Quartz;
- using GSG.NET.Utils;
- using OHV.Common.Events;
- using OHV.Common.Interfaces;
- using OHV.SqliteDAL;
- using OHV.Vehicle.Concept;
- using Prism.Events;
- using Prism.Ioc;
- using Prism.Modularity;
- using Prism.Mvvm;
- using Prism.Unity;
- using VehicleControlSystem;
- namespace OHV.Vehicle
- {
- /// <summary>
- /// App.xaml에 대한 상호 작용 논리
- /// </summary>
- public partial class App : PrismApplication
- {
- static Logger logger = Logger.GetLogger();
- public static ISplashScreen splashScreen;
- private ManualResetEvent resetSplashCreated;
- private Thread splashThread;
- private void Application_Startup(object sender, StartupEventArgs e)
- {
- LogUtils.Configure("CONFIG/log4net.xml");
- AppUtils.LogGlobalException();
- if (!ProcessUtils.IsOnlyOneInstance)
- {
- MessageBox.Show("Program is already running.");
- this.Shutdown();
- return;
- }
- try
- {
- QuartzUtils.Init(10);
- logger.I(string.Format(string.Empty.PadRight(40, '+') + $" Ver. {AssemblyUtils.GetVersion()} " + string.Empty.PadRight(40, '+')));
- //var mainView = new MainWindow();
- //mainView.Show();
- //this.MainWindow = mainView;
- //this.ShutdownMode = ShutdownMode.OnMainWindowClose;
- #region Splash
- resetSplashCreated = new ManualResetEvent( false );
- splashThread = new Thread( ShowSplash );
- splashThread.SetApartmentState( ApartmentState.STA );
- splashThread.IsBackground = true;
- splashThread.Name = "Splash Screen";
- splashThread.Start();
- resetSplashCreated.WaitOne();
- #endregion
- }
- catch (Exception ex)
- {
- logger.E(ex);
- this.Shutdown();
- }
- }
- private void ShowSplash( )
- {
- // Create the window
- AnimatedSplashScreenWindow animatedSplashScreenWindow = new AnimatedSplashScreenWindow();
- splashScreen = animatedSplashScreenWindow;
- // Show it
- animatedSplashScreenWindow.Show();
- // Now that the window is created, allow the rest of the startup to run
- resetSplashCreated.Set();
- System.Windows.Threading.Dispatcher.Run();
- }
- private void Application_Exit(object sender, ExitEventArgs e)
- {
- var ea = Container.Resolve<IEventAggregator>();
- if (ea != null) ea.GetEvent<ApplicationExitEvent>().Publish("");
- logger.I(string.Empty.PadRight(100, '-'));
- }
- protected override Window CreateShell()
- {
- //return Container.Resolve<MainWindow>();
- return Container.Resolve<D_MainWindow>();
- //return ServiceLocator.Current.GetInstance<MainWindow>();
- }
- protected override void RegisterTypes(IContainerRegistry containerRegistry)
- {
- if ( !containerRegistry.IsRegistered<VCSystem>() )
- containerRegistry.RegisterSingleton<VCSystem>();
- if (!containerRegistry.IsRegistered<SqliteManager>())
- containerRegistry.RegisterSingleton<SqliteManager>();
- }
- protected override void ConfigureViewModelLocator()
- {
- base.ConfigureViewModelLocator();
- //ViewModelLocationProvider.Register<MainWindow, MainWindowViewModel>();
- }
- protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
- {
- base.ConfigureModuleCatalog(moduleCatalog);
- moduleCatalog.AddModule(typeof(VCSystem));
- moduleCatalog.AddModule(typeof(SqliteManager));
- moduleCatalog.AddModule(typeof(OHV.Module.Monitoring.MonitoringModules));
- moduleCatalog.AddModule(typeof(OHV.Module.MainViews.MainViewModules));
- moduleCatalog.AddModule(typeof(OHV.Module.Interactivity.MessageController));
- moduleCatalog.AddModule(typeof(OHV.Module.ListViews.ListViewController));
- moduleCatalog.AddModule( typeof( OHV.Module.Status.StatusViewModules ) );
- }
- }
- }
|