From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点

---
 WPFProject/LoadingWindow.xaml.cs |  159 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 147 insertions(+), 12 deletions(-)

diff --git a/WPFProject/LoadingWindow.xaml.cs b/WPFProject/LoadingWindow.xaml.cs
index 49b44ce..3ef9eb7 100644
--- a/WPFProject/LoadingWindow.xaml.cs
+++ b/WPFProject/LoadingWindow.xaml.cs
@@ -1,41 +1,176 @@
-锘縰sing System;
+锘縰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 HMI.Base;
+using System.Windows.Documents;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
 
 namespace WPFProject
 {
     /// <summary>
     /// LoadingWindow.xaml 鐨勪氦浜掗�昏緫
     /// </summary>
-    public partial class LoadingWindow : Window
+    public partial class LoadingWindow : WindowX
     {
+
+        private string message = "";
+
+        public string Message
+        {
+            get { return message; }
+            set { Set(ref message, value); }
+        }
+
+        private bool HasErr = false;
+
+        private bool showConsole = false;
+        public bool ShowConsole
+        {
+            get => showConsole;
+            set
+            {
+                Set(ref showConsole, value);
+                NotifyOfPropertyChange("ConsoleVisiable");
+                NotifyOfPropertyChange("BarVisiable");
+            }
+        }
+
+        public Visibility ConsoleVisiable
+        {
+            get => showConsole ? Visibility.Visible : Visibility.Collapsed;
+        }
+
+        public Visibility BarVisiable
+        {
+            get => showConsole ? Visibility.Collapsed : Visibility.Visible;
+        }
+
         public LoadingWindow()
         {
+            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)
         {
-            PluginLoader loader = PluginLoader.GetLoader();
-            loader.LoadMessageAppend += Loader_LoadMessageAppend;
-            loader.LoadMenuAndPlugin();
-            Button_Click(null,null);
-        }
 
-        private void Loader_LoadMessageAppend(object sender, string e)
+        }
+        private void Loader_LoadMessageAppend(object sender, LoadMsg msg)
         {
-            this.Dispatcher.BeginInvoke((Action)delegate ()
+            Dispatcher.BeginInvoke(() =>
             {
-                Console.Text = Console.Text + $"{e}\r\n";
+                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(() =>
+            {
+                AlarmUtil.Init();
+                loader.LoadMenuAndPlugin(window, Dispatcher);
+                //
+            });
+        }
+
+        private void LoadFinished()
+        {
+            if (!HasErr)
+            {
+                Button_Click(null, null);
+            }
+            else
+            {
+                WindowXCaption.SetButtons(this, CaptionButtons.Close);
+                ShowConsole = true;
+                BtnNext.Visibility = Visibility.Visible;
+                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)
+        {
+            Message = text;
+            string time = string.Format("{0:G}", DateTime.Now);
+            Run run = new Run();
+            string type = result != false ? "Info" : "Warn";
+            run.Text = $"{time} {type} {text}";
+            run.Foreground = result == null ? Brushes.Black : (result == true ? Brushes.Green : Brushes.Red);
+
+            Paragraph paragraph = new Paragraph(run)
+            {
+                LineHeight = 1
+            };
+            //涔熷彲浠ユ彃鍏ュ埌鏈�鍚庨潰
+            Console.Document.Blocks.InsertAfter(Console.Document.Blocks.LastBlock, paragraph);
+
+            //鎻掑叆鍒版渶鍓嶉潰
+            //rtxtLog.Document.Blocks.Add(paragraph);
+
+            // 婊氬姩鑷虫渶鍚庤
+            //rtxtLog.ScrollToEnd();
+            //Console.ScrollToHome();
+            Console.ScrollToEnd();
+            // 鍒犻櫎
+            //if (Console.Document.Blocks.Count > 10000)
+            //{
+            //    for (int i = 1000; i < Console.Document.Blocks.Count; i++)
+            //    {
+            //        _ = Console.Document.Blocks.Remove(Console.Document.Blocks.FirstBlock);
+            //    }
+            //}
+        }
     }
 }

--
Gitblit v1.9.1