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 并发验证用例
---
HMI.ParameterManage/ParameterModal.xaml.cs | 100 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 93 insertions(+), 7 deletions(-)
diff --git a/HMI.ParameterManage/ParameterModal.xaml.cs b/HMI.ParameterManage/ParameterModal.xaml.cs
index 4c19c35..c89f0ea 100644
--- a/HMI.ParameterManage/ParameterModal.xaml.cs
+++ b/HMI.ParameterManage/ParameterModal.xaml.cs
@@ -2,9 +2,12 @@
using HMI.ParameterManage.Model;
using HMI.UI.DpUtil;
using HMI.UI.Util;
+using Microsoft.Win32;
using Panuon.WPF.UI;
using System;
+using System.Collections.Generic;
using System.ComponentModel;
+using System.Windows.Controls;
namespace HMI.ParameterManage
{
@@ -70,29 +73,112 @@
private bool ValidateForm()
{
- bool flag = FormGroupHelper.ValidateForm(formPanel);
+ var cache = new Dictionary<string, object> {
+ { "FgValue",GetTargetValue()}
+ };
+ bool flag = FormGroupHelper.ValidateForm(formPanel, cache);
if (flag)
{
Data.Name = TbName.Text;
- Data.Value = TbValue.Text;
+ Data.Type = CbType.Text;
+ Data.IsArray = CbIsArray.IsChecked == true;
+ Data.Value = GetTargetValue();
Data.Unit = TbUnit.Text;
Data.Description = TbDescription.Text;
Data.ProductName = TbProductName.Text;
- Data.PGroup = TbPGroup.Text;
+ Data.PGroup = CbGroup.Text;
}
return flag;
}
- public bool? Open(ParameterData data)
+ public bool? Open(string productName, ParameterData data, List<string> groups)
{
Data = data;
TbName.Text = Data.Name;
- TbValue.Text = Data.Value;
+ CbType.SelectedValue = Data.Type;
+ CbIsArray.IsChecked = Data.IsArray;
+ CbGroup.ItemsSource = groups;
+ UpdateWindow(Data.Type);
+ UpdateForm(Data);
TbUnit.Text = Data.Unit;
- TbProductName.Text = Data.ProductName;
+ TbProductName.Text = productName;
TbDescription.Text = Data.Description;
- TbPGroup.Text = Data.PGroup;
+ CbGroup.Text = Data.PGroup;
return this.ShowDialog();
}
+
+ private string GetTargetValue()
+ {
+ var type = CbType.Text;
+ if (type == "Int" || type == "Double")
+ {
+ return NiNumberValue.Text;
+ }
+ else if (type == "Bool")
+ {
+ return CbBoolValue.Text;
+ }
+ else
+ {
+ return TbStringValue.Text;
+ }
+ }
+
+ private void UpdateForm(ParameterData data)
+ {
+ if (Data.Type == "Int" || Data.Type == "Int")
+ {
+ NiNumberValue.Text = Data.Value;
+ }
+ else if (Data.Type == "Bool")
+ {
+ CbBoolValue.SelectedValue = Data.Value;
+ }
+ else
+ {
+ TbStringValue.Text = Data.Value;
+ }
+ }
+
+ private void UpdateWindow(string type)
+ {
+ if (type == "Int" || type == "Double")
+ {
+ NiNumberValue.Visibility = System.Windows.Visibility.Visible;
+ StringValueGrid.Visibility = System.Windows.Visibility.Collapsed;
+ CbBoolValue.Visibility = System.Windows.Visibility.Collapsed;
+ }
+ else if (type == "Bool")
+ {
+ NiNumberValue.Visibility = System.Windows.Visibility.Collapsed;
+ StringValueGrid.Visibility = System.Windows.Visibility.Collapsed;
+ CbBoolValue.Visibility = System.Windows.Visibility.Visible;
+ }
+ else
+ {
+ NiNumberValue.Visibility = System.Windows.Visibility.Collapsed;
+ StringValueGrid.Visibility = System.Windows.Visibility.Visible;
+ CbBoolValue.Visibility = System.Windows.Visibility.Collapsed;
+ }
+ }
+
+ private void CbType_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
+ {
+ string val = null;
+ if (e.AddedItems != null && e.AddedItems.Count > 0)
+ {
+ val = ((ComboBoxItem)e.AddedItems[0]).Content.ToString();
+ }
+ UpdateWindow(val);
+ }
+
+ private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ OpenFileDialog ofd = new OpenFileDialog();
+ if (ofd.ShowDialog() == true)
+ {
+ TbStringValue.Text = ofd.FileName;
+ }
+ }
}
}
--
Gitblit v1.9.1