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.SettingControl/SettingControl.xaml.cs |  126 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 126 insertions(+), 0 deletions(-)

diff --git a/HMI.SettingControl/SettingControl.xaml.cs b/HMI.SettingControl/SettingControl.xaml.cs
new file mode 100644
index 0000000..322c614
--- /dev/null
+++ b/HMI.SettingControl/SettingControl.xaml.cs
@@ -0,0 +1,126 @@
+锘縰sing HMI.Base;
+using HMI.Core.Api;
+using HMI.Core.Util;
+using HMI.UI.Util;
+using System;
+using System.Collections.ObjectModel;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace HMI.SettingControl
+{
+    /// <summary>
+    /// UserControl1.xaml 鐨勪氦浜掗�昏緫
+    /// </summary>
+    public partial class SettingControl : PluginControl
+    {
+        #region 灞炴��
+        private ObservableCollection<TabItem> tabItems;
+
+        public ObservableCollection<TabItem> TabItems
+        {
+            get { return tabItems; }
+            set { Set(ref tabItems, value); }
+        }
+        #endregion
+
+        public SettingControl()
+        {
+            DataContext = this;
+            InitializeComponent();
+        }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            var item = new TabItem
+            {
+                Content = new SystemConfig()
+            };
+            item.SetValue(TabItem.HeaderProperty, new DynamicResourceExtension("Setting.SystemSetting").ProvideValue(null));
+
+            TabItems = new ObservableCollection<TabItem>() {
+               item
+            };
+            foreach (var d in PluginLoader.Instance.Plugins)
+            {
+                if (d.SettingControl == null) continue;
+                TabItems.Add(new TabItem
+                {
+                    Header = d.Name,
+                    Tag = d,
+                    Content = d.SettingControl
+                });
+            }
+            tabControl.SelectedIndex = 0;
+            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();
+                        this.Success(this.lang("App.SaveSuccess"));
+                    }
+                    catch (Exception ex)
+                    {
+                        MsgBoxHelper.Error(this, $"{tabItem.Header}{this.lang("App.SaveFailed")}: {ex.Message}");
+                    }
+                }
+            }
+        }
+
+        private void SaveCurrentConfig()
+        {
+            var content = tabControl.SelectedItem as TabItem;
+            if (content is IConfigManager manager)
+            {
+                try
+                {
+                    manager.SaveConfig();
+                }
+                catch (Exception ex)
+                {
+                    MsgBoxHelper.Error(this, $"{this.lang("App.SaveFailed")}: {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, $"{this.lang("App.SaveFailed")}: {ex.Message}");
+                }
+            }
+        }
+    }
+}

--
Gitblit v1.9.1