App.xaml.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 Venus_MainPages.Roles;
  11. using Venus_MainPages.Views;
  12. using Venus_UI.Views;
  13. using WPF.Themes.UserControls;
  14. namespace Venus_UI
  15. {
  16. /// <summary>
  17. /// App.xaml 的交互逻辑
  18. /// </summary>
  19. public partial class App : PrismApplication
  20. {
  21. System.Threading.Mutex mutex;
  22. public static User CurrentUser=new User ("admin","admin",Role.Manager);
  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. //ShellView shellView = new ShellView();
  36. LoginView loginView = new LoginView();
  37. loginView.ShowDialog();
  38. CurrentUser = loginView.CurrentUser;
  39. if (!loginView.IsLoginSuccess)
  40. {
  41. Current.Shutdown();
  42. return;
  43. }
  44. base.OnStartup(e);
  45. }
  46. void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
  47. {
  48. //MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
  49. e.Handled = true;
  50. }
  51. protected override Window CreateShell()
  52. {
  53. return Container.Resolve<ShellView>();
  54. }
  55. protected override void RegisterTypes(IContainerRegistry containerRegistry)
  56. {
  57. }
  58. protected override IModuleCatalog CreateModuleCatalog()
  59. {
  60. return new ConfigurationModuleCatalog();
  61. }
  62. }
  63. }