App.xaml.cs 1.7 KB

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