2025-06-23 17:01:06 +08:00
|
|
|
<UserControl x:Class="PMSWPF.Views.VariableTableView"
|
|
|
|
|
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:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
2025-07-01 11:11:02 +08:00
|
|
|
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
2025-06-30 14:19:22 +08:00
|
|
|
xmlns:vm="clr-namespace:PMSWPF.ViewModels"
|
2025-07-01 11:11:02 +08:00
|
|
|
xmlns:controls="http://schemas.inkore.net/lib/ui/wpf/modern"
|
2025-06-23 17:01:06 +08:00
|
|
|
mc:Ignorable="d"
|
2025-07-03 20:12:07 +08:00
|
|
|
xmlns:vc="clr-namespace:PMSWPF.ValueConverts"
|
|
|
|
|
xmlns:ex="clr-namespace:PMSWPF.Extensions"
|
|
|
|
|
xmlns:en="clr-namespace:PMSWPF.Enums"
|
2025-07-02 18:33:08 +08:00
|
|
|
Loaded="VariableTableView_OnLoaded"
|
2025-06-30 14:19:22 +08:00
|
|
|
d:DataContext="{d:DesignInstance vm:VariableTableViewModel}"
|
2025-07-02 18:33:08 +08:00
|
|
|
d:DesignHeight="600"
|
|
|
|
|
d:DesignWidth="800">
|
2025-07-01 11:11:02 +08:00
|
|
|
<UserControl.Resources>
|
2025-07-03 20:12:07 +08:00
|
|
|
<ex:EnumBindingSource x:Key="signalType"
|
|
|
|
|
EnumType="{x:Type en:SignalType}" />
|
|
|
|
|
<ex:EnumBindingSource x:Key="protocolType"
|
|
|
|
|
EnumType="{x:Type en:ProtocolType}" />
|
|
|
|
|
<vc:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
|
|
|
|
|
2025-07-01 11:11:02 +08:00
|
|
|
<!-- 标签字体的样式 -->
|
2025-07-02 18:33:08 +08:00
|
|
|
<Style TargetType="TextBlock"
|
|
|
|
|
x:Key="VarTableLabelStyle">
|
|
|
|
|
<Setter Property="Foreground"
|
|
|
|
|
Value="#555" />
|
|
|
|
|
<Setter Property="FontSize"
|
|
|
|
|
Value="16" />
|
|
|
|
|
<Setter Property="VerticalAlignment"
|
|
|
|
|
Value="Center" />
|
2025-07-01 11:11:02 +08:00
|
|
|
</Style>
|
|
|
|
|
<!-- 值字体的样式 -->
|
2025-07-02 18:33:08 +08:00
|
|
|
<Style TargetType="TextBlock"
|
|
|
|
|
x:Key="VarTableValueStyle">
|
|
|
|
|
<Setter Property="FontWeight"
|
|
|
|
|
Value="Bold" />
|
|
|
|
|
<Setter Property="FontSize"
|
|
|
|
|
Value="16" />
|
|
|
|
|
<Setter Property="MinWidth"
|
|
|
|
|
Value="100" />
|
|
|
|
|
<Setter Property="VerticalAlignment"
|
|
|
|
|
Value="Center" />
|
2025-07-01 11:11:02 +08:00
|
|
|
</Style>
|
|
|
|
|
</UserControl.Resources>
|
|
|
|
|
|
2025-07-02 18:33:08 +08:00
|
|
|
<DockPanel>
|
|
|
|
|
|
|
|
|
|
<ikw:SimpleStackPanel Margin="10"
|
|
|
|
|
DockPanel.Dock="Top">
|
2025-07-01 11:11:02 +08:00
|
|
|
<!-- 操作菜单 -->
|
|
|
|
|
<controls:CommandBar x:Name="PrimaryCommandBar"
|
2025-07-02 18:33:08 +08:00
|
|
|
DefaultLabelPosition="Right"
|
|
|
|
|
IsOpen="False">
|
2025-07-03 15:03:36 +08:00
|
|
|
<ui:AppBarButton Command="{Binding AddVarDataCommand}"
|
2025-07-03 12:55:00 +08:00
|
|
|
CommandParameter="{Binding VariableTable}"
|
|
|
|
|
Label="添加变量">
|
2025-07-01 11:11:02 +08:00
|
|
|
<ui:AppBarButton.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
|
|
|
|
</ui:AppBarButton.Icon>
|
|
|
|
|
</ui:AppBarButton>
|
2025-07-04 13:40:14 +08:00
|
|
|
|
2025-07-03 15:29:07 +08:00
|
|
|
<ui:AppBarButton Command="{Binding EditVarDataCommand}"
|
|
|
|
|
CommandParameter="{Binding VariableTable}"
|
|
|
|
|
Label="编辑变量">
|
2025-07-01 11:11:02 +08:00
|
|
|
<ui:AppBarButton.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
|
|
|
|
|
</ui:AppBarButton.Icon>
|
2025-07-03 22:16:47 +08:00
|
|
|
</ui:AppBarButton>
|
2025-07-05 00:04:00 +08:00
|
|
|
|
2025-07-05 00:18:59 +08:00
|
|
|
<ui:AppBarButton Label="删除变量"
|
|
|
|
|
Click="DeleteVarData_Click">
|
2025-07-05 00:04:00 +08:00
|
|
|
<ui:AppBarButton.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
|
|
|
|
|
</ui:AppBarButton.Icon>
|
|
|
|
|
</ui:AppBarButton>
|
2025-07-04 14:42:28 +08:00
|
|
|
|
|
|
|
|
|
2025-07-04 13:40:14 +08:00
|
|
|
<ui:AppBarButton Command="{Binding SaveModifiedVarDataCommand}"
|
2025-07-03 22:16:47 +08:00
|
|
|
Label="保存变量">
|
|
|
|
|
<ui:AppBarButton.Icon>
|
2025-07-04 13:40:14 +08:00
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}" />
|
|
|
|
|
</ui:AppBarButton.Icon>
|
|
|
|
|
|
|
|
|
|
</ui:AppBarButton>
|
|
|
|
|
<ui:AppBarButton
|
|
|
|
|
Command="{Binding ImprotFromTiaVarTableCommand}"
|
|
|
|
|
Label="从TIA变量表导入">
|
|
|
|
|
<ui:AppBarButton.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Import}" />
|
2025-07-03 22:16:47 +08:00
|
|
|
</ui:AppBarButton.Icon>
|
|
|
|
|
|
2025-07-01 11:11:02 +08:00
|
|
|
</ui:AppBarButton>
|
2025-07-04 13:40:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-01 11:11:02 +08:00
|
|
|
<ui:AppBarButton x:Name="ShareButton"
|
|
|
|
|
Label="Share">
|
|
|
|
|
<ui:AppBarButton.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Share}" />
|
|
|
|
|
</ui:AppBarButton.Icon>
|
|
|
|
|
</ui:AppBarButton>
|
|
|
|
|
<ui:CommandBar.SecondaryCommands>
|
|
|
|
|
<ui:AppBarButton x:Name="SettingsButton"
|
2025-07-02 18:33:08 +08:00
|
|
|
Icon="Setting"
|
|
|
|
|
Label="Settings" />
|
2025-07-01 11:11:02 +08:00
|
|
|
</ui:CommandBar.SecondaryCommands>
|
2025-07-04 13:40:14 +08:00
|
|
|
|
2025-07-01 11:11:02 +08:00
|
|
|
</controls:CommandBar>
|
|
|
|
|
<!-- 变量表的名称描述等信息 -->
|
2025-07-02 18:33:08 +08:00
|
|
|
<ikw:SimpleStackPanel Margin="5"
|
|
|
|
|
Orientation="Horizontal"
|
|
|
|
|
Spacing="10">
|
2025-07-03 15:03:36 +08:00
|
|
|
<ui:ToggleSwitch OnContent="启用"
|
|
|
|
|
OffContent="停用"
|
|
|
|
|
Toggled="OnIsActiveChanged"
|
|
|
|
|
FontSize="16"
|
|
|
|
|
IsOn="{Binding VariableTable.IsActive}" />
|
2025-07-02 18:33:08 +08:00
|
|
|
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
|
|
|
|
Text="变量表名称:" />
|
|
|
|
|
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
|
|
|
|
Text="{Binding VariableTable.Name}" />
|
|
|
|
|
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
|
|
|
|
Text="变量表描述:" />
|
|
|
|
|
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
|
|
|
|
Text="{Binding VariableTable.Description}" />
|
|
|
|
|
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
|
|
|
|
Text="所属设备:" />
|
|
|
|
|
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
|
|
|
|
Text="{Binding VariableTable.Device.Name}" />
|
2025-07-04 13:40:14 +08:00
|
|
|
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
|
|
|
|
Text="协议:" />
|
|
|
|
|
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
|
|
|
|
Text="{Binding VariableTable.ProtocolType}" />
|
2025-07-03 15:03:36 +08:00
|
|
|
|
|
|
|
|
|
2025-07-01 11:11:02 +08:00
|
|
|
</ikw:SimpleStackPanel>
|
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
|
|
|
</ikw:SimpleStackPanel>
|
|
|
|
|
|
2025-07-05 00:18:59 +08:00
|
|
|
<DataGrid x:Name="BasicGridView"
|
|
|
|
|
Margin="10"
|
2025-07-03 20:12:07 +08:00
|
|
|
CellEditEnding="DataGrid_OnCellEditEnding"
|
2025-07-03 15:03:36 +08:00
|
|
|
AutoGenerateColumns="False"
|
|
|
|
|
CanUserSortColumns="True"
|
2025-07-05 00:18:59 +08:00
|
|
|
SelectionMode="Extended"
|
2025-07-03 15:29:07 +08:00
|
|
|
SelectedItem="{Binding SelectedVariableData}"
|
2025-07-03 15:03:36 +08:00
|
|
|
ItemsSource="{Binding DataVariables}">
|
2025-07-05 00:25:10 +08:00
|
|
|
<DataGrid.ContextMenu>
|
|
|
|
|
<ContextMenu>
|
|
|
|
|
<MenuItem Header="添加变量"
|
|
|
|
|
Command="{Binding AddVarDataCommand}"
|
|
|
|
|
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.VariableTable}">
|
|
|
|
|
<MenuItem.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
|
|
|
|
</MenuItem.Icon>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
<MenuItem Header="编辑变量"
|
|
|
|
|
Command="{Binding EditVarDataCommand}"
|
|
|
|
|
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.VariableTable}">
|
|
|
|
|
<MenuItem.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
|
|
|
|
|
</MenuItem.Icon>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
<MenuItem Header="删除变量"
|
|
|
|
|
Click="DeleteVarData_Click">
|
|
|
|
|
<MenuItem.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
|
|
|
|
|
</MenuItem.Icon>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
<MenuItem Header="保存变量"
|
|
|
|
|
Command="{Binding SaveModifiedVarDataCommand}">
|
|
|
|
|
<MenuItem.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}" />
|
|
|
|
|
</MenuItem.Icon>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
<MenuItem Header="从TIA变量表导入"
|
|
|
|
|
Command="{Binding ImprotFromTiaVarTableCommand}">
|
|
|
|
|
<MenuItem.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Import}" />
|
|
|
|
|
</MenuItem.Icon>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
</ContextMenu>
|
|
|
|
|
</DataGrid.ContextMenu>
|
2025-07-03 20:12:07 +08:00
|
|
|
<DataGrid.RowStyle>
|
|
|
|
|
<Style TargetType="DataGridRow">
|
|
|
|
|
<!-- <Setter Property="Background" Value="#fff"/> -->
|
|
|
|
|
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<DataTrigger Binding="{Binding IsModified}"
|
|
|
|
|
Value="True">
|
|
|
|
|
<Setter Property="Background"
|
|
|
|
|
Value="Pink" />
|
|
|
|
|
<Setter Property="Foreground"
|
|
|
|
|
Value="#000" />
|
|
|
|
|
<Setter Property="FontWeight"
|
|
|
|
|
Value="Bold" />
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
|
|
|
|
|
<Trigger Property="IsMouseOver"
|
|
|
|
|
Value="True">
|
|
|
|
|
<Setter Property="Background"
|
|
|
|
|
Value="LightBlue" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<Trigger Property="IsSelected"
|
|
|
|
|
Value="True">
|
|
|
|
|
<Setter Property="Background"
|
|
|
|
|
Value="DodgerBlue" />
|
|
|
|
|
<Setter Property="Foreground"
|
|
|
|
|
Value="White" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</DataGrid.RowStyle>
|
|
|
|
|
|
|
|
|
|
|
2025-07-03 15:03:36 +08:00
|
|
|
<DataGrid.Columns>
|
2025-07-03 20:12:07 +08:00
|
|
|
<DataGridTextColumn Header="名称"
|
|
|
|
|
Binding="{Binding Name}" />
|
|
|
|
|
<DataGridTextColumn Header="描述"
|
|
|
|
|
Binding="{Binding Description}" />
|
|
|
|
|
<DataGridTextColumn IsReadOnly="True"
|
|
|
|
|
Header="节点ID"
|
|
|
|
|
Binding="{Binding NodeId}" />
|
2025-07-04 13:40:14 +08:00
|
|
|
<!-- <DataGridTextColumn IsReadOnly="True" -->
|
|
|
|
|
<!-- Header="协议类型" -->
|
|
|
|
|
<!-- Binding="{Binding ProtocolType}" /> -->
|
2025-07-03 20:12:07 +08:00
|
|
|
<DataGridTextColumn IsReadOnly="True"
|
|
|
|
|
Header="数据类型"
|
|
|
|
|
Binding="{Binding DataType}" />
|
|
|
|
|
<DataGridTemplateColumn Header="信号类型">
|
|
|
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<TextBlock Text="{Binding SignalType, Converter={StaticResource EnumDescriptionConverter}}" />
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
|
|
|
<DataGridTemplateColumn.CellEditingTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<ComboBox ItemsSource="{Binding Source={StaticResource signalType}}"
|
2025-07-03 20:17:28 +08:00
|
|
|
SelectedItem="{Binding SignalType}">
|
|
|
|
|
<ComboBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
2025-07-04 13:40:14 +08:00
|
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
2025-07-03 20:17:28 +08:00
|
|
|
</DataTemplate>
|
|
|
|
|
</ComboBox.ItemTemplate>
|
|
|
|
|
</ComboBox>
|
2025-07-03 20:12:07 +08:00
|
|
|
</DataTemplate>
|
|
|
|
|
</DataGridTemplateColumn.CellEditingTemplate>
|
|
|
|
|
</DataGridTemplateColumn>
|
2025-07-04 13:40:14 +08:00
|
|
|
<DataGridTextColumn IsReadOnly="True"
|
|
|
|
|
Header="S7地址"
|
|
|
|
|
Binding="{Binding S7Address}" />
|
2025-07-03 20:12:07 +08:00
|
|
|
<DataGridTextColumn IsReadOnly="True"
|
|
|
|
|
Header="当前值"
|
|
|
|
|
Binding="{Binding DataValue}" />
|
|
|
|
|
<DataGridTextColumn IsReadOnly="True"
|
|
|
|
|
Header="显示值"
|
|
|
|
|
Binding="{Binding DisplayValue}" />
|
2025-07-04 13:40:14 +08:00
|
|
|
|
|
|
|
|
<DataGridTextColumn IsReadOnly="True"
|
|
|
|
|
Header="创建时间"
|
|
|
|
|
Binding="{Binding CreateTime}" />
|
2025-07-03 20:12:07 +08:00
|
|
|
<DataGridTextColumn IsReadOnly="True"
|
|
|
|
|
Header="更新时间"
|
|
|
|
|
Binding="{Binding UpdateTime}" />
|
|
|
|
|
<DataGridTextColumn Header="转换规则"
|
|
|
|
|
Binding="{Binding Converstion}" />
|
|
|
|
|
<DataGridCheckBoxColumn Header="启用"
|
|
|
|
|
Binding="{Binding IsActive}" />
|
|
|
|
|
<DataGridCheckBoxColumn Header="保存"
|
|
|
|
|
Binding="{Binding IsSave}" />
|
|
|
|
|
<DataGridTextColumn Header="保存范围"
|
|
|
|
|
Binding="{Binding SaveRange}" />
|
|
|
|
|
<DataGridCheckBoxColumn Header="报警"
|
|
|
|
|
Binding="{Binding IsAlarm}" />
|
|
|
|
|
<DataGridTextColumn Header="报警最小值"
|
|
|
|
|
Binding="{Binding AlarmMin}" />
|
|
|
|
|
<DataGridTextColumn Header="报警最大值"
|
|
|
|
|
Binding="{Binding AlarmMax}" />
|
2025-07-03 15:03:36 +08:00
|
|
|
</DataGrid.Columns>
|
|
|
|
|
</DataGrid>
|
2025-07-02 18:33:08 +08:00
|
|
|
</DockPanel>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
|
|
|
</UserControl>
|