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.StdControl/StdSettingCheckBox.xaml.cs | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 155 insertions(+), 0 deletions(-)
diff --git a/HMI.StdControl/StdSettingCheckBox.xaml.cs b/HMI.StdControl/StdSettingCheckBox.xaml.cs
new file mode 100644
index 0000000..9450c9c
--- /dev/null
+++ b/HMI.StdControl/StdSettingCheckBox.xaml.cs
@@ -0,0 +1,155 @@
+锘縰sing HMI.Core.Manager;
+using System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace HMI.StdControl
+{
+ /// <summary>
+ /// StdEnableMes.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class StdSettingCheckBox : UserControl, INotifyPropertyChanged
+ {
+
+ #region ...
+ public virtual event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void Set([CallerMemberName] string name = null)
+ {
+
+ 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
+
+ private event EventHandler<StdUIEventArg> valueChanged;
+ public event EventHandler<StdUIEventArg> ValueChanged
+ {
+ add
+ {
+ valueChanged += value;
+ }
+ remove
+ {
+ valueChanged -= value;
+ }
+ }
+
+ public static DependencyProperty IsCheckedProperty = DependencyProperty.Register(
+ "IsChecked",
+ typeof(bool),
+ typeof(StdSettingCheckBox),
+ new FrameworkPropertyMetadata(false));
+
+ public static DependencyProperty ValueProperty = DependencyProperty.Register(
+ "Value",
+ typeof(string),
+ typeof(StdSettingCheckBox),
+ new FrameworkPropertyMetadata(null));
+
+ public static DependencyProperty CbEnabledProperty = DependencyProperty.Register(
+ "CbEnabled",
+ typeof(bool),
+ typeof(StdSettingCheckBox),
+ new FrameworkPropertyMetadata(true));
+
+ public static DependencyProperty TextProperty = DependencyProperty.Register(
+ "Text",
+ typeof(string),
+ typeof(StdSettingCheckBox),
+ new FrameworkPropertyMetadata(null));
+
+
+ public bool CbEnabled
+ {
+ get => (bool)GetValue(CbEnabledProperty);
+ set
+ {
+ SetValue(CbEnabledProperty, value);
+ }
+ }
+
+ public string Value
+ {
+ get => (string)GetValue(ValueProperty);
+ set
+ {
+ SetValue(ValueProperty, value);
+ }
+ }
+
+ public string Text
+ {
+ get => (string)GetValue(TextProperty);
+ set
+ {
+ SetValue(TextProperty, value);
+ }
+ }
+
+ public bool IsChecked
+ {
+ get => (bool)GetValue(IsCheckedProperty);
+ set
+ {
+ if (WriteConfig(Value, value))
+ {
+ SetValue(IsCheckedProperty, value);
+ }
+ }
+ }
+
+ public StdSettingCheckBox()
+ {
+ InitializeComponent();
+ this.Loaded += StdSettingCheckBox_Loaded;
+ }
+
+ private void StdSettingCheckBox_Loaded(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ var value = ParameterManager.GetCommonParameterByName(Value);
+ if (value == null)
+ {
+ this.Visibility = System.Windows.Visibility.Collapsed;
+ }
+ else
+ {
+ IsChecked = bool.Parse(value.Value);
+ }
+ }
+ catch
+ {
+ IsChecked = false;
+ }
+ }
+
+ private bool WriteConfig(string name, bool value)
+ {
+ try
+ {
+ valueChanged?.Invoke(this, new StdUIEventArg()
+ {
+ StringValue = name,
+ BoolValue = value
+ });
+ return ParameterManager.UpdateCommonParameter(name, value, out string errMsg);
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+ }
+}
--
Gitblit v1.9.1