diff --git a/DMS.WPF/App.xaml b/DMS.WPF/App.xaml
index da96fa7..b87ada4 100644
--- a/DMS.WPF/App.xaml
+++ b/DMS.WPF/App.xaml
@@ -26,6 +26,13 @@
+
+
+
+
+
+
+
diff --git a/DMS.WPF/App.xaml.cs b/DMS.WPF/App.xaml.cs
index 0dbae03..1a66eb0 100644
--- a/DMS.WPF/App.xaml.cs
+++ b/DMS.WPF/App.xaml.cs
@@ -275,6 +275,10 @@ public partial class App : System.Windows.Application
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
// 注册事件服务
services.AddSingleton();
diff --git a/DMS.WPF/Converters/BoolToColorConverter.cs b/DMS.WPF/Converters/BoolToColorConverter.cs
new file mode 100644
index 0000000..841304e
--- /dev/null
+++ b/DMS.WPF/Converters/BoolToColorConverter.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace DMS.WPF.Converters
+{
+ ///
+ /// 布尔值到颜色转换器。根据布尔值返回不同的颜色。
+ /// 参数格式: "TrueColor;FalseColor"
+ ///
+ public class BoolToColorConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is bool boolValue)
+ {
+ string param = parameter as string;
+ if (!string.IsNullOrEmpty(param))
+ {
+ string[] colors = param.Split(';');
+ if (colors.Length == 2)
+ {
+ try
+ {
+ string colorString = boolValue ? colors[0] : colors[1];
+ Color color = (Color)ColorConverter.ConvertFromString(colorString);
+ return new SolidColorBrush(color);
+ }
+ catch (FormatException)
+ {
+ // 如果颜色格式无效,返回默认颜色
+ }
+ }
+ }
+
+ // 默认颜色
+ Color defaultColor = boolValue ? Colors.Green : Colors.Red;
+ return new SolidColorBrush(defaultColor);
+ }
+
+ // 如果值不是布尔值,返回红色
+ return new SolidColorBrush(Colors.Red);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/DMS.WPF/Converters/BoolToStringConverter.cs b/DMS.WPF/Converters/BoolToStringConverter.cs
new file mode 100644
index 0000000..d729617
--- /dev/null
+++ b/DMS.WPF/Converters/BoolToStringConverter.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace DMS.WPF.Converters
+{
+ ///
+ /// 布尔值到字符串转换器。根据布尔值返回不同的字符串。
+ /// 参数格式: "TrueString;FalseString"
+ ///
+ public class BoolToStringConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is bool boolValue)
+ {
+ string param = parameter as string;
+ if (!string.IsNullOrEmpty(param))
+ {
+ string[] strings = param.Split(';');
+ if (strings.Length == 2)
+ {
+ return boolValue ? strings[0] : strings[1];
+ }
+ }
+
+ // 默认返回
+ return boolValue ? "是" : "否";
+ }
+
+ return "未知";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/DMS.WPF/Converters/BoolToVisibilityConverter.cs b/DMS.WPF/Converters/BoolToVisibilityConverter.cs
new file mode 100644
index 0000000..95e2cb2
--- /dev/null
+++ b/DMS.WPF/Converters/BoolToVisibilityConverter.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace DMS.WPF.Converters
+{
+ ///
+ /// 布尔值到可见性转换器。当绑定的布尔值为true时,返回Visible,否则返回Collapsed。
+ ///
+ public class BoolToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is bool boolValue)
+ {
+ return boolValue ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ return Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is Visibility visibility)
+ {
+ return visibility == Visibility.Visible;
+ }
+
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/DMS.WPF/Converters/CountToVisibilityConverter.cs b/DMS.WPF/Converters/CountToVisibilityConverter.cs
new file mode 100644
index 0000000..3383a12
--- /dev/null
+++ b/DMS.WPF/Converters/CountToVisibilityConverter.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace DMS.WPF.Converters
+{
+ ///
+ /// 计数到可见性转换器。当集合为空时,返回Visible,否则返回Collapsed。
+ ///
+ public class CountToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is ICollection collection)
+ {
+ return collection.Count == 0 ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ return Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs b/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs
index c8557f2..9651ff9 100644
--- a/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs
+++ b/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs
@@ -97,5 +97,11 @@ public partial class DeviceItemViewModel : ObservableObject
}
public ObservableCollection VariableTables { get; set; } = new();
+
+ [ObservableProperty]
+ private bool _isConnected;
+
+ [ObservableProperty]
+ private string _connectionStatus = "未连接";
}
diff --git a/DMS.WPF/ViewModels/VariableTableViewModel.cs b/DMS.WPF/ViewModels/VariableTableViewModel.cs
index 234ddb4..02d25c1 100644
--- a/DMS.WPF/ViewModels/VariableTableViewModel.cs
+++ b/DMS.WPF/ViewModels/VariableTableViewModel.cs
@@ -519,40 +519,7 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
}
}
- ///
- /// 修改选定变量的OPC UA更新方式(轮询或订阅)。
- ///
- /// 要修改更新方式的变量数据列表。
- [RelayCommand]
- public async Task ModifyOpcUaUpdateType(IList