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 作为历史根节点

---
 Plugin.CurrentSensorControl/DataModal.xaml.cs |  128 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/Plugin.CurrentSensorControl/DataModal.xaml.cs b/Plugin.CurrentSensorControl/DataModal.xaml.cs
new file mode 100644
index 0000000..82d32cd
--- /dev/null
+++ b/Plugin.CurrentSensorControl/DataModal.xaml.cs
@@ -0,0 +1,128 @@
+锘縰sing HMI.UI.DpUtil;
+using HMI.UI.Util;
+using Panuon.WPF.UI;
+using Plugin.CurrentSensorControl.Entity;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+
+namespace Plugin.CurrentSensorControl
+{
+    /// <summary>
+    /// ModalWindow.xaml 鐨勪氦浜掗�昏緫
+    /// </summary>
+    public partial class DataModal : WindowX
+    {
+        public DataModal()
+        {
+            this.DataContext = this;
+            InitializeComponent();
+        }
+
+        public SensorData data { get; private set; }
+        public ObservableCollection<SensorData> 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)
+                {
+                    ToastHelper.Error(this, $"Error锛亄ex.Message}");
+                    e.Cancel = true;
+                    return;
+                }
+                finally
+                {
+                    _isProcessing = false;
+                    ButtonHelper.SetIsPending(okButton, false);
+                }
+            }
+            base.OnClosing(e);
+        }
+
+        private bool ValidateName(object value, out string err)
+        {
+            err = null;
+            //string group = TbGroup.Text;
+            //var temp = Datasource.FirstOrDefault(d => d.Group == group && d.Name == value.ToString());
+            //if (temp != null && temp != Data)
+            //{
+            //    err = this.lang("App.MustBeUnique", $"{this.lang("doc.group")},{this.lang("doc.name")}");
+            //    return false;
+            //}
+            return true;
+        }
+
+        private bool ValidateAddress(object value, out string err)
+        {
+            err = null;
+            //string group = TbGroup.Text;
+            //var temp = Datasource.FirstOrDefault(d => d.Address == value.ToString());
+            //if (temp != null && temp != Data)
+            //{
+            //    err = this.lang("App.MustBeUnique", this.lang("doc.Address"));
+            //    return false;
+            //}
+            return true;
+        }
+
+        private bool ValidateForm()
+        {
+            bool flag = FormGroupHelper.ValidateForm(formPanel);
+            if (flag)
+            {
+                data.Name = TbName.Text;
+                data.Ip = TbIP.Text;
+                data.Port = ((int?)NiPort.Value) ?? 0;
+                //data.Address = ((int?)NiAddress.Value) ?? 0;
+                data.Channel = ((int?)NiChannel.Value) ?? 0;
+            }
+            return flag;
+        }
+
+        private void SaveOrUpdateData()
+        {
+            var index = datasource.IndexOf(data);
+            if (index > -1)
+            {
+                datasource[index] = data;
+            }
+            else
+            {
+                datasource.Add(data);
+            }
+        }
+
+        public bool? Open(SensorData data, ObservableCollection<SensorData> datasource)
+        {
+            this.data = data;
+            this.datasource = datasource;
+            TbName.Text = data.Name;
+            TbIP.Text = data.Ip;
+            NiPort.Value = data.Port;
+            //NiAddress.Value = data.Address;
+            NiChannel.Value = data.Channel;
+            return this.ShowDialog();
+        }
+    }
+}

--
Gitblit v1.9.1