From c401a2f2fd1a509cdeb33e850bb5c2827074af48 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期一, 17 三月 2025 08:44:51 +0800
Subject: [PATCH] 完善框架,新增两个close方法;

---
 WPFProject/App.xaml.cs |   46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/WPFProject/App.xaml.cs b/WPFProject/App.xaml.cs
index 2715cec..cfb8c29 100644
--- a/WPFProject/App.xaml.cs
+++ b/WPFProject/App.xaml.cs
@@ -1,14 +1,12 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
+锘縰sing HMI.Core.Setting;
+using HMI.Core.Util;
 using HMI.UI.Util;
-using System.Windows.Markup;
 using log4net;
 using Panuon.WPF.UI;
+using System;
+using System.Threading;
+using System.Windows;
+using WPFProject.Utils;
 
 namespace WPFProject
 {
@@ -26,18 +24,36 @@
 
         private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
         {
-            log.Error("鏈煡寮傚父", e.ExceptionObject as Exception);
-            Dispatcher.Invoke(() =>
-            {
-                MsgBoxHelper.ErrorMessage(Current.MainWindow, $"鍙戠敓鏈煡寮傚父锛佺▼搴忓嵆灏嗗叧闂�", "閿欒", MessageBoxButton.OK,
+            var ex = e.ExceptionObject as Exception;
+            log.Error("UnhandledException.", ex);
+            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();
         }
     }
 }

--
Gitblit v1.9.1