From 4c3eb7f334abb8129b57e86f2935d75d0b3070b4 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期一, 03 三月 2025 18:55:31 +0800
Subject: [PATCH] 完善UI;新增TestResult;

---
 HMI.SettingControl/SettingControl.xaml.cs |  121 +++++++++++++++++++++++----------------
 1 files changed, 71 insertions(+), 50 deletions(-)

diff --git a/HMI.SettingControl/SettingControl.xaml.cs b/HMI.SettingControl/SettingControl.xaml.cs
index 6390b40..fceb973 100644
--- a/HMI.SettingControl/SettingControl.xaml.cs
+++ b/HMI.SettingControl/SettingControl.xaml.cs
@@ -1,10 +1,12 @@
-锘縰sing System.Collections.ObjectModel;
+锘縰sing System;
+using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows.Controls;
 using HMI.Base;
 using HMI.Core.Api;
+using HMI.UI.Util;
 using log4net;
 
 namespace HMI.SettingControl
@@ -14,62 +16,13 @@
     /// </summary>
     public partial class SettingControl : PluginControl
     {
-        #region ...
-        public virtual event PropertyChangedEventHandler PropertyChanged;
-
-        protected virtual void Set(string name)
-        {
-
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
-        }
-
-        protected void Set<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
-        {
-            old = @new;
-            if (propertyName != null)
-            {
-                Set(propertyName);
-            }
-        }
-        #endregion
-
         #region 灞炴��
-        private ILog log;
         private ObservableCollection<TabItem> tabItems;
 
         public ObservableCollection<TabItem> TabItems
         {
             get { return tabItems; }
             set { Set(ref tabItems, value); }
-        }
-
-        #endregion
-
-        #region PluginApi
-
-        public object Init()
-        {
-            return null;
-        }
-
-        public object Active()
-        {
-            return null;
-        }
-
-        public object DeActive()
-        {
-            return null;
-        }
-
-        public void OnTabChange(object sender, object args)
-        {
-
-        }
-
-        public void SetLogger(ILog logger)
-        {
-            log = logger;
         }
         #endregion
 
@@ -100,5 +53,73 @@
             }
             Loaded -= UserControl_Loaded;
         }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            Button btn = sender as Button;
+            switch (btn.Name)
+            {
+                case "resetBtn":
+                    ResetCurrentConfig();
+                    break;
+                case "saveBtn":
+                    SaveAllConfig();
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void SaveAllConfig()
+        {
+            foreach (var d in tabControl.ItemsSource)
+            {
+                if (!(d is TabItem tabItem)) continue;
+                if (tabItem.Content is IConfigManager manager)
+                {
+                    try
+                    {
+                        manager.SaveConfig();
+                    }
+                    catch (Exception ex)
+                    {
+                        MsgBoxHelper.Error(this, $"淇濆瓨{tabItem.Header}閰嶇疆澶辫触锛亄ex.Message}");
+                    }
+                }
+            }
+            this.Success("淇濆瓨鎴愬姛");
+        }
+
+        private void SaveCurrentConfig()
+        {
+            var content = tabControl.SelectedItem as TabItem;
+            if (content is IConfigManager manager)
+            {
+                try
+                {
+                    manager.SaveConfig();
+                }
+                catch (Exception ex)
+                {
+                    MsgBoxHelper.Error(this, $"淇濆瓨閰嶇疆澶辫触锛亄ex.Message}");
+                }
+            }
+        }
+
+        private void ResetCurrentConfig()
+        {
+            var tabItem = tabControl.SelectedItem as TabItem;
+            if (tabItem.Content is IConfigManager manager)
+            {
+                try
+                {
+                    manager.ResetConfig();
+                }
+                catch (Exception ex)
+                {
+                    MsgBoxHelper.Error(this, $"淇濆瓨閰嶇疆澶辫触锛亄ex.Message}");
+                }
+            }
+        }
     }
 }

--
Gitblit v1.9.1