App.xaml.cs 1.5 KB

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