临时提交
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
<XamlRuntime>Wpf</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Views\Dialogs\VarDataDialog.xaml">
|
||||
<Page Update="Views\Dialogs\VariableDialog.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<XamlRuntime>Wpf</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -139,6 +139,11 @@
|
||||
<XamlRuntime>Wpf</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Views\HandyDialogs\VariableEditorDialog.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<XamlRuntime>Wpf</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -4,6 +4,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using DMS.WPF.Views;
|
||||
using DMS.WPF.Views.HandyDialogs;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace DMS.WPF.Services
|
||||
@@ -17,6 +19,7 @@ namespace DMS.WPF.Services
|
||||
{ typeof(ConfrimDialogViewModel), typeof(ConfirmDialog) },
|
||||
{ typeof(VariableTableDialogViewModel), typeof(VariableTableDialog) },
|
||||
{ typeof(ImportExcelDialogViewModel), typeof(ImportExcelDialog) },
|
||||
{ typeof(VariableDialogViewModel), typeof(VariableEditorDialog) },
|
||||
// { typeof(MqttDialogViewModel), typeof(MqttDialog) }, // Add other mappings here
|
||||
// ... other dialogs
|
||||
};
|
||||
|
||||
@@ -44,7 +44,7 @@ public partial class DeviceDetailViewModel : ViewModelBase, INavigatable
|
||||
{
|
||||
VariableTableDialogViewModel variableTableDialogViewModel = new VariableTableDialogViewModel()
|
||||
{
|
||||
PrimaryButContent = "添加变量表"
|
||||
PrimaryButText = "添加变量表"
|
||||
};
|
||||
// 1. 显示添加设备对话框
|
||||
var variableTableItemViewModel = await _dialogService.ShowDialogAsync(variableTableDialogViewModel);
|
||||
@@ -86,7 +86,7 @@ public partial class DeviceDetailViewModel : ViewModelBase, INavigatable
|
||||
|
||||
VariableTableDialogViewModel variableTableDialogViewModel = new VariableTableDialogViewModel(SelectedVariableTable)
|
||||
{
|
||||
PrimaryButContent = "编辑变量表"
|
||||
PrimaryButText = "编辑变量表"
|
||||
};
|
||||
// 1. 显示变量表对话框
|
||||
VariableTableItemViewModel variableTable = await _dialogService.ShowDialogAsync(variableTableDialogViewModel);
|
||||
|
||||
@@ -87,7 +87,7 @@ public partial class DevicesViewModel : ViewModelBase, INavigatable
|
||||
{
|
||||
DeviceDialogViewModel deviceDialogViewModel = new DeviceDialogViewModel()
|
||||
{
|
||||
PrimaryButContent = "添加设备"
|
||||
PrimaryButText = "添加设备"
|
||||
};
|
||||
// 1. 显示添加设备对话框
|
||||
DeviceItemViewModel device = await _dialogService.ShowDialogAsync(deviceDialogViewModel);
|
||||
@@ -190,7 +190,7 @@ public partial class DevicesViewModel : ViewModelBase, INavigatable
|
||||
|
||||
DeviceDialogViewModel deviceDialogViewModel = new DeviceDialogViewModel(SelectedDevice)
|
||||
{
|
||||
PrimaryButContent = "编辑设备"
|
||||
PrimaryButText = "编辑设备"
|
||||
};
|
||||
// 1. 显示设备对话框
|
||||
DeviceItemViewModel device = await _dialogService.ShowDialogAsync(deviceDialogViewModel);
|
||||
|
||||
@@ -13,7 +13,7 @@ public partial class ConfrimDialogViewModel : DialogViewModelBase<Boolean>
|
||||
{
|
||||
Message = message;
|
||||
Title = title;
|
||||
PrimaryButContent = primaryButText;
|
||||
PrimaryButText = primaryButText;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace DMS.WPF.ViewModels.Dialogs
|
||||
private string _title;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _primaryButContent;
|
||||
private string _primaryButText;
|
||||
|
||||
public event Func<TResult, Task> CloseRequested;
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using DMS.WPF.ViewModels.Items;
|
||||
|
||||
namespace DMS.WPF.ViewModels.Dialogs;
|
||||
|
||||
public partial class VarDataDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private VariableItemViewModel _variable;
|
||||
[ObservableProperty]
|
||||
private string title;
|
||||
[ObservableProperty]
|
||||
private string primaryButtonText;
|
||||
}
|
||||
37
DMS.WPF/ViewModels/Dialogs/VariableDialogViewModel.cs
Normal file
37
DMS.WPF/ViewModels/Dialogs/VariableDialogViewModel.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using DMS.WPF.ViewModels.Items;
|
||||
|
||||
namespace DMS.WPF.ViewModels.Dialogs;
|
||||
|
||||
public partial class VariableDialogViewModel : DialogViewModelBase<VariableItemViewModel>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private VariableItemViewModel _variable;
|
||||
|
||||
public VariableDialogViewModel(string title,string primaryButText,VariableItemViewModel variable=null)
|
||||
{
|
||||
if (variable==null)
|
||||
{
|
||||
Variable=new VariableItemViewModel();
|
||||
}
|
||||
else
|
||||
{
|
||||
Variable=variable;
|
||||
}
|
||||
|
||||
Title=title;
|
||||
PrimaryButText=primaryButText;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void PrimaryButton()
|
||||
{
|
||||
Close(Variable);
|
||||
}
|
||||
[RelayCommand]
|
||||
private void CancleButton()
|
||||
{
|
||||
Close(null);
|
||||
}
|
||||
}
|
||||
@@ -6,88 +6,190 @@ using System.Collections.Generic;
|
||||
|
||||
namespace DMS.WPF.ViewModels.Items;
|
||||
|
||||
/// <summary>
|
||||
/// 表示单个变量项的视图模型。
|
||||
/// 此类用于UI层的数据绑定,封装了变量数据以及与UI相关的状态和逻辑。
|
||||
/// 它继承自 ObservableObject,以便于实现 INotifyPropertyChanged 接口,从而支持WPF的双向绑定。
|
||||
/// </summary>
|
||||
public partial class VariableItemViewModel : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置变量的唯一标识符 (ID)。
|
||||
/// 通常对应数据库中的主键。
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量的名称。
|
||||
/// 这个名称会显示在UI界面上,例如在列表或标签中。
|
||||
/// [ObservableProperty] 特性会自动生成支持变更通知的属性。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _name;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量的S7通信地址。
|
||||
/// 例如:"DB1.DBD0"。仅在协议为S7时有效。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string? _s7Address;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置从设备读取到的原始数据值。
|
||||
/// 这通常是未经转换的字符串形式的值。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string? _dataValue;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用于在界面上显示的值。
|
||||
/// 这可能是经过公式转换、格式化或添加了单位后的值。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string? _displayValue;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置此变量所属的变量表 (VariableTable) 的数据传输对象 (DTO)。
|
||||
/// 用于在界面上显示变量表的关联信息。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private VariableTableDto? _variableTable;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置与此变量关联的MQTT别名列表。
|
||||
/// 一个变量可以有多个MQTT别名。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private List<VariableMqttAliasDto>? _mqttAliases;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量的信号类型 (如:AI, DI, AO, DO)。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private SignalType _signalType ;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量的轮询等级。
|
||||
/// 用于决定数据采集的频率(如:高、中、低)。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private PollLevelType _pollLevel;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示此变量是否被激活。
|
||||
/// 未激活的变量将不会被后台服务轮询。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _isActive;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量所属的变量表的ID。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _variableTableId;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量的OPC UA节点ID。
|
||||
/// 例如:"ns=2;s=MyDevice.MyVariable"。仅在协议为OpcUa时有效。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _opcUaNodeId;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否为此变量启用历史记录。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _isHistoryEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置历史记录的死区值。
|
||||
/// 当值的变化超过此死区值时,才会记录历史数据,用于减少不必要的数据存储。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private double _historyDeadband;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否为此变量启用报警功能。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _isAlarmEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置报警的下限值。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private double _alarmMinValue;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置报警的上限值。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private double _alarmMaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置报警的死区值。
|
||||
/// 用于防止在临界点附近频繁触发或解除报警。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private double _alarmDeadband;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量使用的通信协议(如:S7, OpcUa, Modbus)。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ProtocolType _protocol;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量在C#中对应的数据类型。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private CSharpDataType _cSharpDataType;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置值的转换公式。
|
||||
/// 例如:"x * 10" 或 "(x / 100) + 5"。'x' 代表原始值。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _conversionFormula;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置记录的创建时间。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private DateTime _createdAt;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置记录的最后更新时间。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private DateTime _updatedAt;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置最后更新此记录的用户或进程。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _updatedBy;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示此视图模型中的数据是否已被修改。
|
||||
/// 用于跟踪UI上的更改,以便提示用户保存。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _isModified;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置变量的描述信息。
|
||||
/// 提供关于该变量的更多上下文或备注。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _description;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置OPC UA值的更新方式(轮询或订阅)。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private OpcUaUpdateType _opcUaUpdateType;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,17 @@ using DMS.WPF.ViewModels.Dialogs;
|
||||
using DMS.WPF.ViewModels.Items;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using DMS.Application.DTOs;
|
||||
using DMS.Application.Interfaces;
|
||||
using DMS.Application.Services;
|
||||
using DMS.Helper;
|
||||
using DMS.WPF.Views;
|
||||
using DMS.WPF.Views.HandyDialogs;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ObservableCollections;
|
||||
|
||||
@@ -482,78 +488,88 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
|
||||
/// </summary>
|
||||
/// <param name="variableTable">当前操作的变量表,用于设置新变量的所属ID。</param>
|
||||
[RelayCommand]
|
||||
private async void AddVarData(VariableTable variableTable)
|
||||
private async void AddVariable(VariableTable variableTable)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// // 显示添加变量数据的对话框
|
||||
// var varData = await _dialogService.ShowAddVarDataDialog();
|
||||
//
|
||||
// // 如果用户取消或对话框未返回数据,则直接返回
|
||||
// if (varData == null)
|
||||
// return;
|
||||
//
|
||||
// // 设置新变量的所属变量表ID
|
||||
// varData.VariableTableId = variableTable.Id;
|
||||
//
|
||||
// // --- 重复性检查逻辑开始 ---
|
||||
// bool isDuplicate = false;
|
||||
// string duplicateReason = string.Empty;
|
||||
//
|
||||
// // 检查名称是否重复
|
||||
// if (Variables.Any(v => v.Name == varData.Name))
|
||||
// {
|
||||
// isDuplicate = true;
|
||||
// duplicateReason = $"名称 '{varData.Name}' 已存在。";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 根据协议类型检查S7地址或NodeId是否重复
|
||||
// if (variableTable.ProtocolType == ProtocolType.S7)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(varData.S7Address) &&
|
||||
// Variables.Any(v => v.S7Address == varData.S7Address))
|
||||
// {
|
||||
// isDuplicate = true;
|
||||
// duplicateReason = $"S7地址 '{varData.S7Address}' 已存在。";
|
||||
// }
|
||||
// }
|
||||
// else if (variableTable.ProtocolType == ProtocolType.OpcUA)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(varData.NodeId) && Variables.Any(v => v.NodeId == varData.NodeId))
|
||||
// {
|
||||
// isDuplicate = true;
|
||||
// duplicateReason = $"OPC UA NodeId '{varData.NodeId}' 已存在。";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (isDuplicate)
|
||||
// {
|
||||
// NotificationHelper.ShowError($"添加变量失败:{duplicateReason}");
|
||||
// return;
|
||||
// }
|
||||
// // --- 重复性检查逻辑结束 ---
|
||||
//
|
||||
// // 添加变量数据到数据库
|
||||
// var resVarData = await _varDataRepository.AddAsync(varData);
|
||||
// if (resVarData == null)
|
||||
// {
|
||||
// NotificationHelper.ShowError($"添加变量失败了:{varData?.Name}");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 更新当前页面显示的数据:将新变量添加到集合中
|
||||
// Variables.Add(resVarData);
|
||||
//
|
||||
// // 显示成功通知
|
||||
// NotificationHelper.ShowSuccess($"添加变量成功:{varData?.Name}");
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// // 捕获并显示错误通知
|
||||
// NotificationHelper.ShowError($"添加变量的过程中发生了不可预期的错误:{e.Message}", e);
|
||||
// }
|
||||
try
|
||||
{
|
||||
// 显示添加变量数据的对话框
|
||||
VariableDialogViewModel variableDialogViewModel=new VariableDialogViewModel("添加变量","添加变量");
|
||||
|
||||
VariableEditorDialog editorDialog = new VariableEditorDialog() { DataContext = variableDialogViewModel };
|
||||
|
||||
Dialog.Show(new MessageBoxInfo()
|
||||
{
|
||||
Message = "操作成功",
|
||||
Caption = "提示",
|
||||
Button = MessageBoxButton.OKCancel,
|
||||
});
|
||||
// var variableItemViewModel = await _dialogService.ShowDialogAsync(variableDialogViewModel);
|
||||
|
||||
// 如果用户取消或对话框未返回数据,则直接返回
|
||||
// if (res == null)
|
||||
// return;
|
||||
|
||||
// // 设置新变量的所属变量表ID
|
||||
// varData.VariableTableId = variableTable.Id;
|
||||
//
|
||||
// // --- 重复性检查逻辑开始 ---
|
||||
// bool isDuplicate = false;
|
||||
// string duplicateReason = string.Empty;
|
||||
//
|
||||
// // 检查名称是否重复
|
||||
// if (Variables.Any(v => v.Name == varData.Name))
|
||||
// {
|
||||
// isDuplicate = true;
|
||||
// duplicateReason = $"名称 '{varData.Name}' 已存在。";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 根据协议类型检查S7地址或NodeId是否重复
|
||||
// if (variableTable.ProtocolType == ProtocolType.S7)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(varData.S7Address) &&
|
||||
// Variables.Any(v => v.S7Address == varData.S7Address))
|
||||
// {
|
||||
// isDuplicate = true;
|
||||
// duplicateReason = $"S7地址 '{varData.S7Address}' 已存在。";
|
||||
// }
|
||||
// }
|
||||
// else if (variableTable.ProtocolType == ProtocolType.OpcUA)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(varData.NodeId) && Variables.Any(v => v.NodeId == varData.NodeId))
|
||||
// {
|
||||
// isDuplicate = true;
|
||||
// duplicateReason = $"OPC UA NodeId '{varData.NodeId}' 已存在。";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (isDuplicate)
|
||||
// {
|
||||
// NotificationHelper.ShowError($"添加变量失败:{duplicateReason}");
|
||||
// return;
|
||||
// }
|
||||
// // --- 重复性检查逻辑结束 ---
|
||||
//
|
||||
// // 添加变量数据到数据库
|
||||
// var resVarData = await _varDataRepository.AddAsync(varData);
|
||||
// if (resVarData == null)
|
||||
// {
|
||||
// NotificationHelper.ShowError($"添加变量失败了:{varData?.Name}");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 更新当前页面显示的数据:将新变量添加到集合中
|
||||
// Variables.Add(resVarData);
|
||||
//
|
||||
// // 显示成功通知
|
||||
// NotificationHelper.ShowSuccess($"添加变量成功:{varData?.Name}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// 捕获并显示错误通知
|
||||
NotificationHelper.ShowError($"添加变量的过程中发生了不可预期的错误:{e.Message}", e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
Title="{Binding Title}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonText="{Binding PrimaryButContent}"
|
||||
PrimaryButtonText="{Binding PrimaryButText}"
|
||||
Background="#fff"
|
||||
d:DataContext="{d:DesignInstance vmd:ConfrimDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
Title="{Binding Title}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonText="{Binding PrimaryButContent}"
|
||||
PrimaryButtonText="{Binding PrimaryButText}"
|
||||
d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
Title="{Binding Title}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonText="{Binding PrimaryButContent}"
|
||||
PrimaryButtonText="{Binding PrimaryButText}"
|
||||
Background="#fff"
|
||||
d:DataContext="{d:DesignInstance vmd:MqttDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using DMS.WPF.ViewModels.Dialogs;
|
||||
|
||||
namespace DMS.WPF.Views.Dialogs;
|
||||
|
||||
public partial class VarDataDialog
|
||||
{
|
||||
public VarDataDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public VarDataDialog(VarDataDialogViewModel viewModel) : this()
|
||||
{
|
||||
DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.VarDataDialog"
|
||||
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.VariableDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@@ -11,34 +11,42 @@
|
||||
xmlns:sockets="clr-namespace:System.Net.Sockets;assembly=System.Net.Sockets"
|
||||
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
||||
xmlns:valueConverts="clr-namespace:DMS.WPF.ValueConverts"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
Title="{Binding Title}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonText="{Binding PrimaryButtonText}"
|
||||
PrimaryButtonText="{Binding PrimaryButText}"
|
||||
Background="#fff"
|
||||
d:DataContext="{d:DesignInstance vmd:VarDataDialogViewModel}"
|
||||
|
||||
d:DataContext="{d:DesignInstance vmd:VariableDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="PrimaryButtonClick">
|
||||
<i:InvokeCommandAction Command="{Binding PrimaryButtonCommand}" />
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="CloseButtonClick">
|
||||
<i:InvokeCommandAction Command="{Binding CancleButtonCommand}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ui:ContentDialog.Resources>
|
||||
<valueConverts:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
||||
</ui:ContentDialog.Resources>
|
||||
|
||||
<Grid Margin="10" Width="480">
|
||||
<Grid >
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- <Grid.RowDefinitions> -->
|
||||
<!-- <RowDefinition Height="Auto" /> -->
|
||||
<!-- <RowDefinition Height="Auto" /> -->
|
||||
<!-- </Grid.RowDefinitions> -->
|
||||
|
||||
<!-- 基本信息 -->
|
||||
<GroupBox Header="基本信息" Grid.Row="0" Grid.Column="0" Margin="0 0 10 10">
|
||||
<ikw:SimpleStackPanel Margin="10" Spacing="12">
|
||||
<TextBlock Text="变量名称"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBox Width="200" Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="变量描述"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
@@ -47,11 +55,11 @@
|
||||
|
||||
<TextBlock Text="节点ID"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding Variable.NodeId, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBox Text="{Binding Variable.OpcUaNodeId, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="协议类型"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<ComboBox SelectedValue="{Binding Variable.ProtocolType, UpdateSourceTrigger=PropertyChanged}"
|
||||
<ComboBox SelectedValue="{Binding Variable.Protocol, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Tag"
|
||||
ItemsSource="{ex:EnumBindingSource {x:Type sockets:ProtocolType}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
@@ -63,7 +71,7 @@
|
||||
|
||||
<TextBlock Text="数据类型"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding Variable.DataType, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBox Text="{Binding Variable.CSharpDataType, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="信号类型"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
@@ -79,7 +87,7 @@
|
||||
|
||||
<TextBlock Text="轮询级别"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<ComboBox SelectedValue="{Binding Variable.PollLevelType, UpdateSourceTrigger=PropertyChanged}"
|
||||
<ComboBox SelectedValue="{Binding Variable.PollLevel, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Tag"
|
||||
ItemsSource="{ex:EnumBindingSource {x:Type enums:PollLevelType}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
@@ -91,13 +99,13 @@
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<ikw:SimpleStackPanel Grid.Row="0" Grid.Column="1">
|
||||
<ikw:SimpleStackPanel Grid.Row="0" Grid.Column="1" >
|
||||
<!-- 保存设置 -->
|
||||
<GroupBox Header="保存设置" Margin="10 0 0 10">
|
||||
<ikw:SimpleStackPanel Spacing="12" Margin="10">
|
||||
<TextBlock Text="保存范围"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding Variable.SaveRange, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBox Width="200" Text="{Binding Variable.HistoryDeadband, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<CheckBox Content="是否激活"
|
||||
FontSize="16"
|
||||
Margin="0 10 0 0 "
|
||||
@@ -105,7 +113,7 @@
|
||||
<CheckBox Content="是否保存"
|
||||
FontSize="16"
|
||||
Margin="0 10 0 0 "
|
||||
IsChecked="{Binding Variable.IsSave, UpdateSourceTrigger=PropertyChanged}" />
|
||||
IsChecked="{Binding Variable.IsHistoryEnabled, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
@@ -116,18 +124,22 @@
|
||||
|
||||
<TextBlock Text="报警最小值"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding Variable.AlarmMin, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBox Text="{Binding Variable.AlarmMinValue, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Text="报警最大值"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding Variable.AlarmMax, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBox Text="{Binding Variable.AlarmMaxValue, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<CheckBox Content="是否报警"
|
||||
FontSize="16"
|
||||
Margin="0 5"
|
||||
IsChecked="{Binding Variable.IsAlarm, UpdateSourceTrigger=PropertyChanged}" />
|
||||
IsChecked="{Binding Variable.IsAlarmEnabled, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
|
||||
<ikw:SimpleStackPanel Grid.Row="0" Grid.Column="2" Width="100">
|
||||
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
</Grid>
|
||||
</ui:ContentDialog>
|
||||
14
DMS.WPF/Views/Dialogs/VariableDialog.xaml.cs
Normal file
14
DMS.WPF/Views/Dialogs/VariableDialog.xaml.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using DMS.WPF.ViewModels.Dialogs;
|
||||
|
||||
namespace DMS.WPF.Views.Dialogs;
|
||||
|
||||
public partial class VariableDialog
|
||||
{
|
||||
public VariableDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
Title="{Binding Title}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonText="{Binding PrimaryButContent}"
|
||||
PrimaryButtonText="{Binding PrimaryButText}"
|
||||
Background="#fff"
|
||||
d:DataContext="{d:DesignInstance vmd:VariableTableDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
87
DMS.WPF/Views/HandyDialogs/VariableEditorDialog.xaml
Normal file
87
DMS.WPF/Views/HandyDialogs/VariableEditorDialog.xaml
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
<UserControl x:Class="DMS.WPF.Views.HandyDialogs.VariableEditorDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DMS.WPF.Views"
|
||||
xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=vmd:VariableDialogViewModel}"
|
||||
Background="#fff"
|
||||
Width="1000">
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Text="{Binding Title}" Style="{StaticResource TextBlockTitle}" Margin="0,0,0,16"/>
|
||||
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="名称:" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||
<hc:TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" Margin="0,5"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="地址:" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||
<hc:TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Variable.S7Address, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" Margin="0,5"/>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="描述:" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||
<hc:TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Variable.Description, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" AcceptsReturn="True" MinHeight="60" Style="{StaticResource TextBoxExtend}" Margin="0,5"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="数据类型:" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||
<hc:ComboBox Grid.Row="3" Grid.Column="1" ItemsSource="{Binding CSharpDataTypes}" SelectedItem="{Binding Variable.CSharpDataType}" Style="{StaticResource ComboBoxExtend}" Margin="0,5"/>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Text="协议:" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||
<hc:ComboBox Grid.Row="4" Grid.Column="1" ItemsSource="{Binding ProtocolTypes}" SelectedItem="{Binding Variable.Protocol}" Style="{StaticResource ComboBoxExtend}" Margin="0,5"/>
|
||||
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" Text="轮询频率:" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||
<hc:ComboBox Grid.Row="5" Grid.Column="1" ItemsSource="{Binding PollLevelTypes}" SelectedItem="{Binding Variable.PollLevel}" Style="{StaticResource ComboBoxExtend}" Margin="0,5"/>
|
||||
|
||||
<hc:Divider Grid.Row="6" Grid.ColumnSpan="2" Margin="0,10"/>
|
||||
|
||||
<StackPanel Grid.Row="7" Grid.ColumnSpan="2" Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding Variable.IsActive}" Content="启用变量" Margin="0,5,20,5"/>
|
||||
<CheckBox IsChecked="{Binding Variable.IsHistoryEnabled}" Content="启用历史记录" Margin="0,5,20,5"/>
|
||||
<CheckBox IsChecked="{Binding Variable.IsAlarmEnabled}" Content="启用报警" Margin="0,5,20,5"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="8" Grid.ColumnSpan="2" IsEnabled="{Binding Variable.IsAlarmEnabled}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:NumericUpDown Grid.Column="0" Minimum="-999999" Maximum="999999" Value="{Binding Variable.AlarmMinValue}" hc:InfoElement.Title="报警下限" Margin="0,5,5,5"/>
|
||||
<hc:NumericUpDown Grid.Column="1" Minimum="-999999" Maximum="999999" Value="{Binding Variable.AlarmMaxValue}" hc:InfoElement.Title="报警上限" Margin="5,5"/>
|
||||
<hc:NumericUpDown Grid.Column="2" Minimum="0" Maximum="999999" Value="{Binding Variable.AlarmDeadband}" hc:InfoElement.Title="报警死区" Margin="5,5,0,5"/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,16,0,0">
|
||||
<Button Command="{Binding SaveCommand}" Content="保存" Style="{StaticResource ButtonPrimary}" IsDefault="True"/>
|
||||
<Button Command="{Binding CancelCommand}" Content="取消" Margin="10,0,0,0" IsCancel="True"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
16
DMS.WPF/Views/HandyDialogs/VariableEditorDialog.xaml.cs
Normal file
16
DMS.WPF/Views/HandyDialogs/VariableEditorDialog.xaml.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DMS.WPF.Views.HandyDialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for VariableEditorDialog.xaml
|
||||
/// </summary>
|
||||
public partial class VariableEditorDialog : UserControl
|
||||
{
|
||||
public VariableEditorDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,8 +58,7 @@
|
||||
<controls:CommandBar x:Name="PrimaryCommandBar"
|
||||
DefaultLabelPosition="Right"
|
||||
IsOpen="False">
|
||||
<ui:AppBarButton Command="{Binding AddVarDataCommand}"
|
||||
CommandParameter="{Binding VariableTable}"
|
||||
<ui:AppBarButton Command="{Binding AddVariableCommand}"
|
||||
Label="添加变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
||||
@@ -312,18 +311,17 @@
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="轮询频率"
|
||||
|
||||
SortMemberPath="PollLevelType">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Text="{Binding PollLevelType, Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
Text="{Binding PollLevel, Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource pollLevelType}}"
|
||||
SelectedItem="{Binding PollLevelType}">
|
||||
SelectedItem="{Binding PollLevel}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
@@ -343,24 +341,24 @@
|
||||
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="创建时间"
|
||||
Binding="{Binding CreateTime, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
|
||||
Binding="{Binding CreatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="更新时间"
|
||||
Binding="{Binding UpdateTime, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
|
||||
Binding="{Binding UpdatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
|
||||
<DataGridTextColumn Header="转换规则"
|
||||
Binding="{Binding Converstion}" />
|
||||
Binding="{Binding ConversionFormula}" />
|
||||
<DataGridCheckBoxColumn Header="启用"
|
||||
Binding="{Binding IsActive}" />
|
||||
<DataGridCheckBoxColumn Header="保存"
|
||||
Binding="{Binding IsSave}" />
|
||||
Binding="{Binding IsHistoryEnabled}" />
|
||||
<DataGridTextColumn Header="保存范围"
|
||||
Binding="{Binding SaveRange}" />
|
||||
Binding="{Binding HistoryDeadband}" />
|
||||
<DataGridCheckBoxColumn Header="报警"
|
||||
Binding="{Binding IsAlarm}" />
|
||||
Binding="{Binding IsAlarmEnabled}" />
|
||||
<DataGridTextColumn Header="报警最小值"
|
||||
Binding="{Binding AlarmMin}" />
|
||||
Binding="{Binding AlarmMinValue}" />
|
||||
<DataGridTextColumn Header="报警最大值"
|
||||
Binding="{Binding AlarmMax}" />
|
||||
Binding="{Binding AlarmMaxValue}" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
|
||||
Reference in New Issue
Block a user