App.xaml.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 System.Windows.Media.Animation;
  10. using Venus_UI.Views;
  11. using WPF.Themes.UserControls;
  12. using System.Configuration;
  13. namespace Venus_UI
  14. {
  15. /// <summary>
  16. /// App.xaml 的交互逻辑
  17. /// </summary>
  18. public partial class App : PrismApplication
  19. {
  20. protected override void OnStartup(StartupEventArgs e)
  21. {
  22. Mutex mutex;
  23. bool ret;
  24. mutex = new Mutex(true, "Venus_UI", out ret);
  25. if (!ret)
  26. {
  27. WPFMessageBox.ShowError("Only One Venus_UI is allowed");
  28. Environment.Exit(0);
  29. }
  30. FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false;
  31. DispatcherUnhandledException += App_DispatcherUnhandledException;
  32. Singleton<LogManager>.Instance.Initialize();
  33. var TimelineDesiredFrameRate =Convert.ToInt32( ConfigurationManager.AppSettings["TimelineDesiredFrameRate"]);
  34. Timeline.DesiredFrameRateProperty.OverrideMetadata(
  35. typeof(Timeline),
  36. new FrameworkPropertyMetadata { DefaultValue = TimelineDesiredFrameRate }
  37. );
  38. base.OnStartup(e);
  39. }
  40. void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
  41. {
  42. LOG.Info("UI程序异常." + e.Exception.Message);
  43. e.Handled = true;
  44. }
  45. protected override Window CreateShell()
  46. {
  47. return Container.Resolve<ShellView>();
  48. }
  49. protected override void RegisterTypes(IContainerRegistry containerRegistry)
  50. {
  51. }
  52. protected override IModuleCatalog CreateModuleCatalog()
  53. {
  54. return new ConfigurationModuleCatalog();
  55. }
  56. }
  57. }