| | |
| | | using HMI.UI.Util; |
| | | using HMI.Core.Setting; |
| | | using HMI.Core.Util; |
| | | using HMI.UI.Util; |
| | | using log4net; |
| | | using Panuon.WPF.UI; |
| | | using System; |
| | | using System.Threading; |
| | | using System.Windows; |
| | | using WPFProject.Utils; |
| | | |
| | | namespace WPFProject |
| | | { |
| | |
| | | { |
| | | var ex = e.ExceptionObject as Exception; |
| | | log.Error("UnhandledException.", ex); |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | MsgBoxHelper.ErrorMessage(Current.MainWindow, $"发生未知异常!程序即将关闭\r\n{ex?.Message}", |
| | | "错误", MessageBoxButton.OK, |
| | | MsgBoxHelper.ErrorMessage(Current.MainWindow, this.lang("App.AppUnhandledException",ex.Message), |
| | | this.lang("App.Error"), MessageBoxButton.OK, |
| | | MessageBoxIcon.Error, DefaultButton.YesOK, 5); |
| | | }); |
| | | } |
| | | |
| | | private static Mutex mutex; |
| | | private void Application_Startup(object sender, StartupEventArgs e) |
| | | { |
| | | LoadingWindow window = new LoadingWindow(); |
| | | window.Show(); |
| | | mutex = new System.Threading.Mutex(true, "TestPlatform_OnlyRun_CRNS"); |
| | | if (mutex.WaitOne(0, false)) |
| | | { |
| | | LangUtil.Load(); |
| | | SystemSetting.SystemSettingChanged += SystemSetting_SystemSettingChanged; |
| | | ToastHelper.Register(new MainToastHandler()); |
| | | //LoadingWindow window = new LoadingWindow(); |
| | | Login window = new Login(); |
| | | window.Show(); |
| | | } |
| | | else |
| | | { |
| | | MessageBox.Show("程序已经在运行!", "提示"); |
| | | this.Shutdown(); |
| | | } |
| | | } |
| | | |
| | | private void SystemSetting_SystemSettingChanged(object sender, SystemSetting e) |
| | | { |
| | | LangUtil.LoadLang(); |
| | | } |
| | | } |
| | | } |