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 作为历史根节点
---
HMI.AlermInfoManage/Modal/AlarmSettingModal.xaml.cs | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 156 insertions(+), 0 deletions(-)
diff --git a/HMI.AlermInfoManage/Modal/AlarmSettingModal.xaml.cs b/HMI.AlermInfoManage/Modal/AlarmSettingModal.xaml.cs
new file mode 100644
index 0000000..8668aee
--- /dev/null
+++ b/HMI.AlermInfoManage/Modal/AlarmSettingModal.xaml.cs
@@ -0,0 +1,156 @@
+锘縰sing HMI.Core.Entity;
+using HMI.Core.Util;
+using HMI.UI.DpUtil;
+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.Linq;
+using System.Windows;
+
+namespace HMI.AlarmInfoManage
+{
+ /// <summary>
+ /// ModalWindow.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class AlarmSettingModal : WindowX
+ {
+ public AlarmSettingModal(ILog log)
+ {
+ this.log = log;
+ this.DataContext = this;
+ InitializeComponent();
+ }
+ private ILog log;
+ private bool isBlock;
+ public int DataIndex { get; private set; }
+ public AlarmSetting Data { get; private set; }
+ public ObservableCollection<AlarmSetting> Datasource { get; private set; }
+
+ private bool _isProcessing;
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ //Press Continue Button
+ if (DialogResult == true)
+ {
+ if (_isProcessing)
+ {
+ e.Cancel = true;
+ return;
+ }
+ var okButton = WindowXModalDialog.GetOKButton(this);
+ try
+ {
+ _isProcessing = true;
+ ButtonHelper.SetIsPending(okButton, true);
+ if (!ValidateForm())
+ {
+ e.Cancel = true;
+ return;
+ }
+
+ SaveOrUpdateData();
+ }
+ catch (Exception ex)
+ {
+ log.Error("AlarmSetting Form Submit Failed.", ex);
+ ToastHelper.Error(this, $"Error: {ex.Message}");
+ e.Cancel = true;
+ return;
+ }
+ finally
+ {
+ _isProcessing = false;
+ ButtonHelper.SetIsPending(okButton, false);
+ }
+ }
+ base.OnClosing(e);
+ }
+
+ public bool ValidateDBAddress(object value, out string err)
+ {
+ err = null;
+ var target = Datasource?.FirstOrDefault(e => e.DBAddress == value);
+ if (target != null && target != Data)
+ {
+ err = this.lang("App.MustBeUnique", this.lang("Alm.DbAddress"));
+ return false;
+ }
+ return true;
+ }
+
+ private bool ValidateForm()
+ {
+ bool flag = FormGroupHelper.ValidateForm(formPanel);
+ if (flag)
+ {
+ Data.DBAddress = dbAddress.Text;
+ Data.StartAddress = startAddress.Text;
+ Data.Length = Convert.ToInt32(length.Value);
+ Data.AlarmCode = TbCode.Text;
+ Data.Level = NiLevel.Value ?? 0d;
+ Data.Description = TbDesc.Text;
+ }
+ return flag;
+ }
+
+ public bool? Open(int index, AlarmSetting data,
+ ObservableCollection<AlarmSetting> dataSource, bool isBlock)
+ {
+ this.isBlock = isBlock;
+ FgCode.Visibility = isBlock ? Visibility.Visible : Visibility.Collapsed;
+ DataIndex = index;
+ Data = data;
+ Datasource = dataSource;
+ dbAddress.Text = Data.DBAddress;
+ startAddress.Text = Data.StartAddress;
+ length.Value = Data.Length;
+ TbCode.Text = Data.AlarmCode;
+ NiLevel.Value = Data.Level;
+ TbDesc.Text = Data.Description;
+ return this.ShowDialog();
+ }
+
+ private void SaveOrUpdateData()
+ {
+ if (DataIndex == -1)
+ {
+ InsertData(Data);
+ }
+ else
+ {
+ UpdateData(DataIndex, Data);
+ }
+ }
+
+ public void InsertData(AlarmSetting data)
+ {
+ Datasource.Add(data);
+ if (this.isBlock)
+ {
+ AlarmUtil.UpdateBlockSettings(Datasource);
+ }
+ else
+ {
+ AlarmUtil.UpdateMarkSettings(Datasource);
+ }
+ }
+
+ public void UpdateData(int index, AlarmSetting data)
+ {
+ Datasource[index] = data;
+ if (this.isBlock)
+ {
+ AlarmUtil.UpdateBlockSettings(Datasource);
+ }
+ else
+ {
+ AlarmUtil.UpdateMarkSettings(Datasource);
+ }
+ }
+ }
+}
--
Gitblit v1.9.1