WPFProject/LoadingWindow.xaml.cs
@@ -1,11 +1,17 @@
using 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
{
@@ -51,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)
@@ -59,26 +67,30 @@
        }
        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 = 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;
                }
            });
        }
@@ -98,8 +110,10 @@
            window = new PanuonWindow();
            PluginLoader loader = PluginLoader.GetLoader();
            loader.LoadMessageAppend += Loader_LoadMessageAppend;
            AlarmUtil.LoadMessageAppend += Loader_LoadMessageAppend;
            Task.Run(() =>
            {
                AlarmUtil.Init();
                loader.LoadMenuAndPlugin(window, Dispatcher);
                //
            });
@@ -116,7 +130,7 @@
                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; ;
            }
        }
@@ -157,7 +171,6 @@
            //        _ = Console.Document.Blocks.Remove(Console.Document.Blocks.FirstBlock);
            //    }
            //}
        }
    }
}