App.xaml.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Aitex.Core.RT.Log;
  2. using Aitex.Core.Util;
  3. using Prism.Ioc;
  4. using Prism.Modularity;
  5. using Prism.Unity;
  6. using System;
  7. using System.Threading;
  8. using System.Windows;
  9. using Venus_MainPages.Views;
  10. using Venus_UI.Views;
  11. using WPF.Themes.UserControls;
  12. namespace Venus_UI
  13. {
  14. /// <summary>
  15. /// App.xaml 的交互逻辑
  16. /// </summary>
  17. public partial class App : PrismApplication
  18. {
  19. System.Threading.Mutex mutex;
  20. protected override void OnStartup(StartupEventArgs e)
  21. {
  22. bool ret;
  23. mutex = new System.Threading.Mutex(true, "Venus_UI", out ret);
  24. if (!ret)
  25. {
  26. WPFMessageBox.ShowError("Only One Venus_UI is allowed");
  27. Environment.Exit(0);
  28. }
  29. FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false;
  30. DispatcherUnhandledException += App_DispatcherUnhandledException;
  31. Singleton<LogManager>.Instance.Initialize();
  32. base.OnStartup(e);
  33. }
  34. void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
  35. {
  36. //MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
  37. e.Handled = true;
  38. }
  39. protected override Window CreateShell()
  40. {
  41. return Container.Resolve<ShellView>();
  42. }
  43. protected override void RegisterTypes(IContainerRegistry containerRegistry)
  44. {
  45. }
  46. protected override IModuleCatalog CreateModuleCatalog()
  47. {
  48. return new ConfigurationModuleCatalog();
  49. }
  50. }
  51. }