From b544d5cccd76735e034c8055918a50927b437474 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期二, 10 十一月 2026 08:29:04 +0800
Subject: [PATCH] fix: 维护模式重复进入失败与按钮灰死 + Broker 并发验证用例
---
WPFProject/PanuonWindow.xaml.cs | 147 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 120 insertions(+), 27 deletions(-)
diff --git a/WPFProject/PanuonWindow.xaml.cs b/WPFProject/PanuonWindow.xaml.cs
index 494eb98..7dceeff 100644
--- a/WPFProject/PanuonWindow.xaml.cs
+++ b/WPFProject/PanuonWindow.xaml.cs
@@ -4,22 +4,24 @@
using HMI.Core.Setting;
using HMI.Core.Util;
using HMI.UI.Util;
+using HMI.Util.Alarm;
+using log4net;
using Panuon.WPF.UI;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
+using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
-using HMI.Util.Base;
-using System.Windows.Interop;
namespace WPFProject
{
public class SimpleAlarm
{
+ public string Id { get; set; }
public string Time { get; set; }
public string Message { get; set; }
public override string ToString()
@@ -31,11 +33,13 @@
/// <summary>
/// PanuonWindow.xaml 鐨勪氦浜掗�昏緫
/// </summary>
- public partial class PanuonWindow : WindowX, IPluginContainer,IAlarmShow, AlarmBase
+ public partial class PanuonWindow : WindowX, IPluginContainer, IAlarmShow
{
+ private ILog log = LogManager.GetLogger("MainWindow");
public PanuonWindow()
{
this.Loaded += PanuonWindow_Loaded;
+ SoftwareVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
private UserInfo currentUser;
@@ -73,23 +77,58 @@
get => Alarms?.Count ?? 0;
}
- public ListBox sb {
- get;set;
+ private string softwareVersion;
+ public string SoftwareVersion
+ {
+ get => softwareVersion;
+ set
+ {
+ Set(ref softwareVersion, value);
+ }
+ }
+
+ private string pluginVersion;
+ public string PluginVersion
+ {
+ get => pluginVersion;
+ set
+ {
+ Set(ref pluginVersion, value);
+ }
+ }
+
+ public ListBox sb
+ {
+ get; set;
}
private void PanuonWindow_Loaded(object sender, RoutedEventArgs e)
{
- DataContext = this;
- RefrshConfig();
- InitializeComponent();
- AlarmShowHelper.Register(this);
- var sb = WindowXCaption.GetHeaderTemplate(this);
- //sb.FindName("list",this.Con);
-
- WelcomeTitle = this.lang("App.Welcome", UserInfo.User.Name);
- ShowMenu = false;
- Application.Current.MainWindow = this;
- SystemSetting.SystemSettingChanged += SystemSetting_SystemSettingChanged;
+ try
+ {
+ DataContext = this;
+ RefrshConfig();
+ InitializeComponent();
+ AlarmShowHelper.Register(this);
+
+ WelcomeTitle = this.lang("App.Welcome", UserInfo.User.Name);
+ ShowMenu = false;
+ Application.Current.MainWindow = this;
+ SystemSetting.SystemSettingChanged += SystemSetting_SystemSettingChanged;
+
+ if (Environment.Is64BitProcess)
+ {
+ Task.Run(() =>
+ {
+ ResourceListener.Instance.RefreshEvent += this.resourceUI.Refresh;
+ ResourceListener.Instance.Start();
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+ log.Error("Window Loaded Error.", ex);
+ }
}
private void RefrshConfig()
@@ -171,6 +210,8 @@
}
}
+ private bool logoutAdded = false;
+
private void Logout()
{
if (MsgBoxHelper.WarnMessage(this, this.lang("App.MakeSureLogout")) == MessageBoxResult.OK)
@@ -181,11 +222,25 @@
File.Delete(path);
}
this.Closed -= window_Closed;
+ if (!logoutAdded)
+ {
+ this.Closed += Logout_PanuonWindow_Closed;
+ logoutAdded = true;
+ }
this.Close();
- PluginLoader.Reset();
- Login login = new Login();
- login.Show();
}
+ }
+
+ private void Logout_PanuonWindow_Closed(object sender, EventArgs e)
+ {
+ AlarmUtil.Release();
+ PluginLoader.Reset();
+ UserInfo.Logout();
+ AlarmShowHelper.UnRegister(this);
+ Login login = new Login();
+ login.Show();
+ this.Closed -= Logout_PanuonWindow_Closed;
+ logoutAdded = false;
}
private void RestartApp()
@@ -204,7 +259,19 @@
private void window_Closed(object sender, EventArgs e)
{
- Application.Current.Shutdown();
+ try
+ {
+ ResourceListener.Instance.Stop();
+ AlarmUtil.Release();
+ PluginLoader.Reset();
+ UserInfo.Logout();
+ AlarmShowHelper.UnRegister(this);
+ }
+ catch (Exception ex)
+ {
+
+ }
+ Application.Current.Shutdown(0);
}
private void Button_Click(object sender, RoutedEventArgs e)
@@ -216,9 +283,19 @@
this.Minimize();
break;
case "maxBtn":
- this.Maximize();
+ //var state = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
+ //SetCurrentValue(Window.WindowStateProperty, state);
+ if (this.WindowState == WindowState.Maximized)
+ {
+ this.Normalmize();
+ }
+ else
+ {
+ this.Maximize();
+ }
break;
case "closeBtn":
+ this.Closed -= Logout_PanuonWindow_Closed;
this.Close();
break;
case "BtnSwitchTheme":
@@ -235,17 +312,18 @@
}
}
- public bool ShowAlarm(string message)
+ public bool ShowAlarm(AlarmText alarm)
{
bool res = false;
Dispatcher.Invoke(() =>
{
- if (Alarms.FirstOrDefault(e => e.Message == message) == null)
+ if (Alarms.FirstOrDefault(e => e.Id == alarm.VirtualId) == null)
{
var data = new SimpleAlarm
{
- Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- Message = message
+ Id = alarm.VirtualId,
+ Time = alarm.Time,
+ Message = alarm.AlarmInfo
};
Alarms.Add(data);
sb?.ScrollIntoView(data);
@@ -261,9 +339,24 @@
sb.Loaded -= list_Loaded;
}
- public bool? Alarm(string message)
+ private void Clear_AllAlarm_Click(object sender, RoutedEventArgs e)
{
- return true;
+ Alarms?.Clear();
+ }
+
+ private void menuTab_TabChanged(object sender, Controls.TabChangedEventArg e)
+ {
+ Dispatcher.BeginInvoke(() =>
+ {
+ if (e.newValue == null)
+ {
+ PluginVersion = string.Empty;
+ }
+ else
+ {
+ PluginVersion = e.newValue.GetType().Assembly.GetName().Version.ToString();
+ }
+ }, System.Windows.Threading.DispatcherPriority.Normal);
}
//private void BaseWindow_Loaded(object sender, RoutedEventArgs e)
--
Gitblit v1.9.1