123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using DevExpress.LookAndFeel;
- using DevExpress.Skins;
- using DevExpress.UserSkins;
- using DevExpress.Utils;
- using DevExpress.XtraSplashScreen;
- using FocasCncCollect.Core;
- using FocasCncCollect.ICore;
- using SiwiFms.Helper;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Drawing;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace FocasCncCollect
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- //设置应用程序处理异常方式
- Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
- //全局异常
- Application.ThreadException += Application_ThreadException;
- AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
- //Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Lang);
- //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Lang);
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- SkinManager.EnableFormSkins();
- BonusSkins.Register();
- AppearanceObject.DefaultFont = new Font("宋体", 9);
- UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
- //显示程序加载框
- SplashScreenManager.ShowForm(typeof(SplashScreen1));
- Application.Run(new FrmEquipmentMonitor());
- }
- /// <summary>
- /// 窗体异常
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- var ex = e.ExceptionObject as Exception;
- if (ex != null)
- {
- MessageBoxHelper.ShowError(ex.Message);
- }
- else
- {
- MessageBoxHelper.ShowError();
- }
- }
- /// <summary>
- /// 线程异常
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- {
- try
- {
- SplashScreenManager.CloseForm();
- }
- catch { }
- if (e.Exception.GetType().Name.Equals("Exception"))
- {
- MessageBoxHelper.ShowError(e.Exception.Message);//
- }
- else
- {
- MessageBoxHelper.ShowError(e.Exception.Message);//e.Exception.Message
- }
- }
- private static string Lang
- {
- get
- {
- var lang = string.Empty;
- try
- {
- lang = ConfigurationManager.AppSettings["Lang"];
- }
- catch
- {
- lang = "zh-CN";
- }
- return lang;
- }
- }
- }
- }
|