2025-08-24 12:25:44 +08:00
|
|
|
<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"
|
|
|
|
|
xmlns:en="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
|
|
|
|
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
|
|
|
|
xmlns:ex="clr-namespace:DMS.Extensions"
|
|
|
|
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
|
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
|
|
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
|
|
|
|
xmlns:valueConverts="clr-namespace:DMS.WPF.ValueConverts"
|
|
|
|
|
xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
|
|
|
|
|
Title="{Binding Title}"
|
|
|
|
|
d:DataContext="{d:DesignInstance vmd:VariableDialogViewModel}"
|
|
|
|
|
CloseButtonCommand="{Binding CancleButtonCommand}"
|
|
|
|
|
CloseButtonText="取消"
|
2025-08-24 14:42:31 +08:00
|
|
|
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
|
2025-08-24 12:25:44 +08:00
|
|
|
PrimaryButtonText="{Binding PrimaryButText}"
|
|
|
|
|
mc:Ignorable="d">
|
|
|
|
|
|
2025-07-03 12:55:00 +08:00
|
|
|
<ui:ContentDialog.Resources>
|
2025-07-27 22:35:07 +08:00
|
|
|
<valueConverts:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
2025-08-24 12:33:05 +08:00
|
|
|
<valueConverts:EnumToStringConverter x:Key="EnumToStringConverter" />
|
2025-08-24 12:25:44 +08:00
|
|
|
<ex:EnumBindingSource x:Key="ProtocolType" EnumType="{x:Type en:ProtocolType}" />
|
|
|
|
|
<ex:EnumBindingSource x:Key="SignalType" EnumType="{x:Type enums:SignalType}" />
|
|
|
|
|
<ex:EnumBindingSource x:Key="PollLevelType" EnumType="{x:Type enums:PollLevelType}" />
|
2025-08-24 14:42:31 +08:00
|
|
|
<ex:EnumBindingSource x:Key="CSharpDataType" EnumType="{x:Type enums:CSharpDataType}" />
|
2025-07-03 12:55:00 +08:00
|
|
|
</ui:ContentDialog.Resources>
|
|
|
|
|
|
2025-08-24 12:25:44 +08:00
|
|
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
|
|
|
|
<StackPanel Margin="16">
|
2025-08-24 14:42:31 +08:00
|
|
|
<!-- 错误信息显示区域 -->
|
|
|
|
|
<Border
|
|
|
|
|
Margin="0,0,0,15"
|
|
|
|
|
Padding="10"
|
|
|
|
|
Background="#FFF0F0"
|
|
|
|
|
BorderBrush="#FF8080"
|
|
|
|
|
BorderThickness="1"
|
|
|
|
|
CornerRadius="4"
|
|
|
|
|
Visibility="{Binding HasError, Converter={StaticResource BooleanToVisibilityConverter}}">
|
|
|
|
|
<StackPanel Orientation="Horizontal">
|
|
|
|
|
<ui:FontIcon
|
|
|
|
|
Margin="0,0,10,0"
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
Foreground="#C50500"
|
|
|
|
|
Glyph="" />
|
|
|
|
|
<TextBlock
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
Foreground="#C50500"
|
|
|
|
|
Text="{Binding ErrorMessage}"
|
|
|
|
|
TextWrapping="Wrap" />
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Border>
|
|
|
|
|
|
2025-08-24 12:25:44 +08:00
|
|
|
<!-- 基本信息 -->
|
|
|
|
|
<GroupBox Margin="0,0,0,15" Header="基本信息">
|
|
|
|
|
<Grid Margin="10">
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
<ColumnDefinition Width="20" />
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
|
|
|
|
|
<hc:TextBox
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
MinWidth="150"
|
|
|
|
|
hc:InfoElement.Title="变量名称:"
|
|
|
|
|
Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
2025-08-24 14:42:31 +08:00
|
|
|
<!-- S7 Address Field - Visible when Protocol is S7 -->
|
2025-08-24 12:25:44 +08:00
|
|
|
<hc:TextBox
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Grid.Column="2"
|
|
|
|
|
MinWidth="150"
|
2025-08-24 12:33:05 +08:00
|
|
|
hc:InfoElement.Title="S7地址:"
|
2025-08-24 17:01:33 +08:00
|
|
|
IsEnabled="{Binding IsAddModel}"
|
2025-08-24 12:33:05 +08:00
|
|
|
Text="{Binding Variable.S7Address, UpdateSourceTrigger=PropertyChanged}">
|
|
|
|
|
<hc:TextBox.Style>
|
2025-08-24 14:42:31 +08:00
|
|
|
<Style BasedOn="{StaticResource {x:Type hc:TextBox}}" TargetType="hc:TextBox">
|
2025-08-24 12:33:05 +08:00
|
|
|
<Setter Property="Visibility" Value="Collapsed" />
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<DataTrigger Binding="{Binding Variable.Protocol, Converter={StaticResource EnumToStringConverter}}" Value="S7">
|
|
|
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</hc:TextBox.Style>
|
|
|
|
|
</hc:TextBox>
|
|
|
|
|
|
2025-08-24 14:42:31 +08:00
|
|
|
<!-- OPC UA Node ID Field - Visible when Protocol is OpcUa -->
|
2025-08-24 12:33:05 +08:00
|
|
|
<hc:TextBox
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Grid.Column="2"
|
|
|
|
|
MinWidth="150"
|
|
|
|
|
hc:InfoElement.Title="OpcUa节点ID:"
|
2025-08-24 17:01:33 +08:00
|
|
|
IsEnabled="{Binding IsAddModel}"
|
2025-08-24 12:33:05 +08:00
|
|
|
Text="{Binding Variable.OpcUaNodeId, UpdateSourceTrigger=PropertyChanged}">
|
|
|
|
|
<hc:TextBox.Style>
|
2025-08-24 14:42:31 +08:00
|
|
|
<Style BasedOn="{StaticResource {x:Type hc:TextBox}}" TargetType="hc:TextBox">
|
2025-08-24 12:33:05 +08:00
|
|
|
<Setter Property="Visibility" Value="Collapsed" />
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<DataTrigger Binding="{Binding Variable.Protocol, Converter={StaticResource EnumToStringConverter}}" Value="OpcUa">
|
|
|
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</hc:TextBox.Style>
|
|
|
|
|
</hc:TextBox>
|
2025-08-24 12:25:44 +08:00
|
|
|
|
|
|
|
|
<hc:ComboBox
|
|
|
|
|
Grid.Row="1"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
Margin="0,15,0,0"
|
|
|
|
|
hc:InfoElement.Title="协议类型:"
|
2025-08-24 15:08:13 +08:00
|
|
|
IsEnabled="False"
|
2025-08-24 12:25:44 +08:00
|
|
|
ItemsSource="{Binding Source={StaticResource ProtocolType}}"
|
|
|
|
|
SelectedItem="{Binding Variable.Protocol, UpdateSourceTrigger=PropertyChanged}">
|
|
|
|
|
<ComboBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ComboBox.ItemTemplate>
|
|
|
|
|
</hc:ComboBox>
|
|
|
|
|
|
|
|
|
|
<hc:ComboBox
|
|
|
|
|
Grid.Row="1"
|
|
|
|
|
Grid.Column="2"
|
|
|
|
|
Margin="0,15,0,0"
|
|
|
|
|
hc:InfoElement.Title="信号类型:"
|
|
|
|
|
ItemsSource="{Binding Source={StaticResource SignalType}}"
|
|
|
|
|
SelectedItem="{Binding Variable.SignalType, UpdateSourceTrigger=PropertyChanged}">
|
|
|
|
|
<ComboBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ComboBox.ItemTemplate>
|
|
|
|
|
</hc:ComboBox>
|
|
|
|
|
|
|
|
|
|
<hc:ComboBox
|
|
|
|
|
Grid.Row="2"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
Margin="0,15,0,0"
|
|
|
|
|
hc:InfoElement.Title="轮询级别:"
|
|
|
|
|
ItemsSource="{Binding Source={StaticResource PollLevelType}}"
|
|
|
|
|
SelectedItem="{Binding Variable.PollLevel, UpdateSourceTrigger=PropertyChanged}">
|
|
|
|
|
<ComboBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ComboBox.ItemTemplate>
|
|
|
|
|
</hc:ComboBox>
|
|
|
|
|
|
2025-08-24 14:42:31 +08:00
|
|
|
<hc:ComboBox
|
2025-08-24 12:25:44 +08:00
|
|
|
Grid.Row="2"
|
|
|
|
|
Grid.Column="2"
|
|
|
|
|
Margin="0,15,0,0"
|
|
|
|
|
hc:InfoElement.Title="数据类型:"
|
2025-08-24 17:01:33 +08:00
|
|
|
IsEnabled="{Binding IsAddModel}"
|
2025-08-24 14:42:31 +08:00
|
|
|
ItemsSource="{Binding Source={StaticResource CSharpDataType}}"
|
|
|
|
|
SelectedItem="{Binding Variable.CSharpDataType, UpdateSourceTrigger=PropertyChanged}">
|
|
|
|
|
<ComboBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ComboBox.ItemTemplate>
|
|
|
|
|
</hc:ComboBox>
|
2025-08-24 12:25:44 +08:00
|
|
|
|
|
|
|
|
<hc:TextBox
|
|
|
|
|
Grid.Row="3"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
Grid.ColumnSpan="3"
|
|
|
|
|
Height="60"
|
|
|
|
|
Margin="0,15,0,0"
|
|
|
|
|
hc:InfoElement.Title="变量描述:"
|
|
|
|
|
Text="{Binding Variable.Description, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
TextWrapping="Wrap"
|
|
|
|
|
VerticalScrollBarVisibility="Auto" />
|
|
|
|
|
</Grid>
|
2025-07-03 12:55:00 +08:00
|
|
|
</GroupBox>
|
|
|
|
|
|
2025-08-24 12:25:44 +08:00
|
|
|
<!-- 保存设置 -->
|
|
|
|
|
<GroupBox Margin="0,0,0,15" Header="保存设置">
|
|
|
|
|
<Grid Margin="10">
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
<ColumnDefinition Width="20" />
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
|
|
|
|
|
<hc:TextBox
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
hc:InfoElement.Title="保存范围:"
|
|
|
|
|
Text="{Binding Variable.HistoryDeadband, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
|
|
|
|
<StackPanel
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Grid.Column="2"
|
|
|
|
|
VerticalAlignment="Bottom"
|
|
|
|
|
Orientation="Horizontal">
|
|
|
|
|
<CheckBox
|
|
|
|
|
Margin="0,0,20,0"
|
|
|
|
|
Content="是否激活"
|
|
|
|
|
IsChecked="{Binding Variable.IsActive, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
<CheckBox Content="是否保存" IsChecked="{Binding Variable.IsHistoryEnabled, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Grid>
|
2025-07-03 12:55:00 +08:00
|
|
|
</GroupBox>
|
2025-08-23 16:01:30 +08:00
|
|
|
|
2025-08-24 12:25:44 +08:00
|
|
|
<!-- 报警设置 -->
|
|
|
|
|
<GroupBox Header="报警设置">
|
|
|
|
|
<Grid Margin="10">
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
<ColumnDefinition Width="20" />
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
|
|
|
|
|
<hc:TextBox
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
hc:InfoElement.Title="报警最小值:"
|
|
|
|
|
Text="{Binding Variable.AlarmMinValue, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
|
|
|
|
<hc:TextBox
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Grid.Column="2"
|
|
|
|
|
hc:InfoElement.Title="报警最大值:"
|
|
|
|
|
Text="{Binding Variable.AlarmMaxValue, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
|
|
|
|
<CheckBox
|
|
|
|
|
Grid.Row="1"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
Grid.ColumnSpan="3"
|
|
|
|
|
Margin="0,15,0,0"
|
|
|
|
|
Content="是否报警"
|
|
|
|
|
IsChecked="{Binding Variable.IsAlarmEnabled, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
</Grid>
|
|
|
|
|
</GroupBox>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</ScrollViewer>
|
2025-07-03 12:55:00 +08:00
|
|
|
</ui:ContentDialog>
|