From ef52fd6fd07508883dce4eb002acda59f0169e59 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 23 四月 2026 10:19:33 +0800
Subject: [PATCH] 优化;
---
WPFProject/LoadingWindow.xaml.cs | 72 +++++++++++++++++++++++------------
1 files changed, 47 insertions(+), 25 deletions(-)
diff --git a/WPFProject/LoadingWindow.xaml.cs b/WPFProject/LoadingWindow.xaml.cs
index e9d50a4..3ef9eb7 100644
--- a/WPFProject/LoadingWindow.xaml.cs
+++ b/WPFProject/LoadingWindow.xaml.cs
@@ -1,11 +1,17 @@
锘縰sing HMI.Base;
+using HMI.Core.Entity;
+using HMI.Core.Setting;
+using HMI.Core.Util;
using HMI.UI.Util;
+using HMI.Util.Alarm;
using Panuon.WPF.UI;
using System;
+using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
+using System.Windows.Media.Imaging;
namespace WPFProject
{
@@ -37,7 +43,8 @@
}
}
- public Visibility ConsoleVisiable {
+ public Visibility ConsoleVisiable
+ {
get => showConsole ? Visibility.Visible : Visibility.Collapsed;
}
@@ -50,6 +57,8 @@
{
DataContext = this;
InitializeComponent();
+ logo.Source = new BitmapImage(new Uri(Path.Combine(PathHelper.IconFolder,
+ SystemSetting.Instance.LoginLogoPath ?? "LoginLogo.png")));
}
private void Window_Loaded(object sender, RoutedEventArgs e)
@@ -58,46 +67,54 @@
}
private void Loader_LoadMessageAppend(object sender, LoadMsg msg)
{
- switch (msg.Type)
+ Dispatcher.BeginInvoke(() =>
{
- case LoadMsgType.INIT:
- total = msg.NumData;
- Add(msg.Message, null);
- break;
- case LoadMsgType.LOADING:
- HasErr = msg.Result == false;
- if (msg.Result != null)
- {
- processBar.Value = ++finished / total * 100;
- }
- Add(msg.Message, msg.Result);
- break;
- case LoadMsgType.FINISHED:
- LoadFinished();
- break;
- default:
- break;
- }
+ switch (msg.Type)
+ {
+ case LoadMsgType.INIT:
+ total = msg.NumData;
+ Add(msg.Message, msg.Result);
+ break;
+ case LoadMsgType.LOADING:
+ HasErr = HasErr || msg.Result == false;
+ if (msg.Result != null)
+ {
+ processBar.Value = ++finished / total * 100;
+ }
+ Add(msg.Message, msg.Result);
+ break;
+ case LoadMsgType.FINISHED:
+ LoadFinished();
+ break;
+ default:
+ break;
+ }
+
+ });
}
private void Button_Click(object sender, RoutedEventArgs e)
{
- PanuonWindow window = new PanuonWindow();
+ this.Closed -= ShutDownWhen_Closed;
window.Show();
this.Close();
}
+ private PanuonWindow window;
private double total;
private double finished;
private void WindowX_ContentRendered(object sender, System.EventArgs e)
{
+ window = new PanuonWindow();
PluginLoader loader = PluginLoader.GetLoader();
loader.LoadMessageAppend += Loader_LoadMessageAppend;
+ AlarmUtil.LoadMessageAppend += Loader_LoadMessageAppend;
Task.Run(() =>
{
- loader.LoadMenuAndPlugin(Dispatcher);
+ AlarmUtil.Init();
+ loader.LoadMenuAndPlugin(window, Dispatcher);
//
});
}
@@ -113,8 +130,14 @@
WindowXCaption.SetButtons(this, CaptionButtons.Close);
ShowConsole = true;
BtnNext.Visibility = Visibility.Visible;
- MsgBoxHelper.Error(this, "鍔犺浇鍑洪敊锛岃纭");
+ MsgBoxHelper.Error(this, this.lang("App.LoadPluginError"));
+ this.Closed += ShutDownWhen_Closed; ;
}
+ }
+
+ private void ShutDownWhen_Closed(object sender, EventArgs e)
+ {
+ Application.Current.Shutdown();
}
public void Add(string text, bool? result)
@@ -132,7 +155,7 @@
};
//涔熷彲浠ユ彃鍏ュ埌鏈�鍚庨潰
Console.Document.Blocks.InsertAfter(Console.Document.Blocks.LastBlock, paragraph);
-
+
//鎻掑叆鍒版渶鍓嶉潰
//rtxtLog.Document.Blocks.Add(paragraph);
@@ -148,7 +171,6 @@
// _ = Console.Document.Blocks.Remove(Console.Document.Blocks.FirstBlock);
// }
//}
-
}
}
}
--
Gitblit v1.9.1