Program.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using DevExpress.LookAndFeel;
  2. using DevExpress.Skins;
  3. using DevExpress.UserSkins;
  4. using DevExpress.Utils;
  5. using DevExpress.XtraSplashScreen;
  6. using FocasCncCollect.Core;
  7. using FocasCncCollect.ICore;
  8. using SiwiFms.Helper;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Configuration;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Threading;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. namespace FocasCncCollect
  18. {
  19. static class Program
  20. {
  21. /// <summary>
  22. /// 应用程序的主入口点。
  23. /// </summary>
  24. [STAThread]
  25. static void Main()
  26. {
  27. //设置应用程序处理异常方式
  28. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
  29. //全局异常
  30. Application.ThreadException += Application_ThreadException;
  31. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  32. //Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Lang);
  33. //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Lang);
  34. Application.EnableVisualStyles();
  35. Application.SetCompatibleTextRenderingDefault(false);
  36. SkinManager.EnableFormSkins();
  37. BonusSkins.Register();
  38. AppearanceObject.DefaultFont = new Font("宋体", 9);
  39. UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
  40. //显示程序加载框
  41. SplashScreenManager.ShowForm(typeof(SplashScreen1));
  42. Application.Run(new FrmEquipmentMonitor());
  43. }
  44. /// <summary>
  45. /// 窗体异常
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="e"></param>
  49. static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  50. {
  51. var ex = e.ExceptionObject as Exception;
  52. if (ex != null)
  53. {
  54. MessageBoxHelper.ShowError(ex.Message);
  55. }
  56. else
  57. {
  58. MessageBoxHelper.ShowError();
  59. }
  60. }
  61. /// <summary>
  62. /// 线程异常
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
  67. {
  68. try
  69. {
  70. SplashScreenManager.CloseForm();
  71. }
  72. catch { }
  73. if (e.Exception.GetType().Name.Equals("Exception"))
  74. {
  75. MessageBoxHelper.ShowError(e.Exception.Message);//
  76. }
  77. else
  78. {
  79. MessageBoxHelper.ShowError(e.Exception.Message);//e.Exception.Message
  80. }
  81. }
  82. private static string Lang
  83. {
  84. get
  85. {
  86. var lang = string.Empty;
  87. try
  88. {
  89. lang = ConfigurationManager.AppSettings["Lang"];
  90. }
  91. catch
  92. {
  93. lang = "zh-CN";
  94. }
  95. return lang;
  96. }
  97. }
  98. }
  99. }