完成添加变量对话框验证
This commit is contained in:
@@ -15,8 +15,7 @@
|
||||
d:DataContext="{d:DesignInstance vmd:VariableDialogViewModel}"
|
||||
CloseButtonCommand="{Binding CancleButtonCommand}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonCommand="{Binding PrimaryButtonCommand}"
|
||||
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
|
||||
PrimaryButtonText="{Binding PrimaryButText}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -26,10 +25,34 @@
|
||||
<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}" />
|
||||
<ex:EnumBindingSource x:Key="CSharpDataType" EnumType="{x:Type enums:CSharpDataType}" />
|
||||
</ui:ContentDialog.Resources>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Margin="16">
|
||||
<!-- 错误信息显示区域 -->
|
||||
<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>
|
||||
|
||||
<!-- 基本信息 -->
|
||||
<GroupBox Margin="0,0,0,15" Header="基本信息">
|
||||
<Grid Margin="10">
|
||||
@@ -53,7 +76,7 @@
|
||||
hc:InfoElement.Title="变量名称:"
|
||||
Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<!-- S7 Address Field - Visible when Protocol is S7 -->
|
||||
<!-- S7 Address Field - Visible when Protocol is S7 -->
|
||||
<hc:TextBox
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
@@ -61,7 +84,7 @@
|
||||
hc:InfoElement.Title="S7地址:"
|
||||
Text="{Binding Variable.S7Address, UpdateSourceTrigger=PropertyChanged}">
|
||||
<hc:TextBox.Style>
|
||||
<Style TargetType="hc:TextBox" BasedOn="{StaticResource {x:Type hc:TextBox}}">
|
||||
<Style BasedOn="{StaticResource {x:Type hc:TextBox}}" TargetType="hc:TextBox">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Variable.Protocol, Converter={StaticResource EnumToStringConverter}}" Value="S7">
|
||||
@@ -72,7 +95,7 @@
|
||||
</hc:TextBox.Style>
|
||||
</hc:TextBox>
|
||||
|
||||
<!-- OPC UA Node ID Field - Visible when Protocol is OpcUa -->
|
||||
<!-- OPC UA Node ID Field - Visible when Protocol is OpcUa -->
|
||||
<hc:TextBox
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
@@ -80,7 +103,7 @@
|
||||
hc:InfoElement.Title="OpcUa节点ID:"
|
||||
Text="{Binding Variable.OpcUaNodeId, UpdateSourceTrigger=PropertyChanged}">
|
||||
<hc:TextBox.Style>
|
||||
<Style TargetType="hc:TextBox" BasedOn="{StaticResource {x:Type hc:TextBox}}">
|
||||
<Style BasedOn="{StaticResource {x:Type hc:TextBox}}" TargetType="hc:TextBox">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Variable.Protocol, Converter={StaticResource EnumToStringConverter}}" Value="OpcUa">
|
||||
@@ -133,12 +156,19 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</hc:ComboBox>
|
||||
|
||||
<hc:TextBox
|
||||
<hc:ComboBox
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Margin="0,15,0,0"
|
||||
hc:InfoElement.Title="数据类型:"
|
||||
Text="{Binding Variable.CSharpDataType, UpdateSourceTrigger=PropertyChanged}" />
|
||||
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>
|
||||
|
||||
<hc:TextBox
|
||||
Grid.Row="3"
|
||||
|
||||
@@ -9,6 +9,7 @@ public partial class VariableDialog
|
||||
{
|
||||
private const int ContentAreaMaxWidth = 1200;
|
||||
private const int ContentAreaMaxHeight = 900;
|
||||
|
||||
public VariableDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -20,7 +21,21 @@ public partial class VariableDialog
|
||||
var backgroundElementBorder = VisualTreeFinder.FindVisualChildByName<Border>(this, "BackgroundElement");
|
||||
backgroundElementBorder.MaxWidth = ContentAreaMaxWidth;
|
||||
backgroundElementBorder.MaxWidth = ContentAreaMaxHeight;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
// 获取ViewModel
|
||||
if (DataContext is VariableDialogViewModel viewModel)
|
||||
{
|
||||
// 调用ViewModel的PrimaryButtonAsync方法
|
||||
bool isValid = await viewModel.PrimaryButtonAsync();
|
||||
|
||||
// 如果验证失败,取消对话框关闭
|
||||
if (!isValid)
|
||||
{
|
||||
args.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +1,93 @@
|
||||
<UserControl x:Class="DMS.WPF.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"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:vm="clr-namespace:DMS.WPF.ViewModels"
|
||||
xmlns:controls="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
mc:Ignorable="d"
|
||||
xmlns:ex="clr-namespace:DMS.Extensions"
|
||||
xmlns:en="clr-namespace:DMS.Core.Enums"
|
||||
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
||||
xmlns:global="clr-namespace:;assembly=DMS.Core"
|
||||
xmlns:valueConverts="clr-namespace:DMS.WPF.ValueConverts"
|
||||
Loaded="VariableTableView_OnLoaded"
|
||||
d:DataContext="{d:DesignInstance vm:VariableTableViewModel}"
|
||||
d:DesignHeight="600"
|
||||
d:DesignWidth="800">
|
||||
<UserControl
|
||||
x:Class="DMS.WPF.Views.VariableTableView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
||||
xmlns:ex="clr-namespace:DMS.Extensions"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
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:vm="clr-namespace:DMS.WPF.ViewModels"
|
||||
d:DataContext="{d:DesignInstance vm:VariableTableViewModel}"
|
||||
d:DesignHeight="600"
|
||||
d:DesignWidth="800"
|
||||
Loaded="VariableTableView_OnLoaded"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<ex:BindingProxy x:Key="proxy" Data="{Binding}" />
|
||||
<ex:EnumBindingSource x:Key="signalType"
|
||||
EnumType="{x:Type enums:SignalType}" />
|
||||
<ex:EnumBindingSource x:Key="signalType" EnumType="{x:Type enums:SignalType}" />
|
||||
<valueConverts:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
||||
<ex:EnumBindingSource x:Key="pollLevelType"
|
||||
EnumType="{x:Type enums:PollLevelType}" />
|
||||
<ex:EnumBindingSource x:Key="pollLevelType" EnumType="{x:Type enums:PollLevelType}" />
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
|
||||
<!-- 标签字体的样式 -->
|
||||
<Style TargetType="TextBlock"
|
||||
x:Key="VarTableLabelStyle">
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource SecondaryTextBrush}" />
|
||||
<Setter Property="FontSize"
|
||||
Value="16" />
|
||||
<Setter Property="VerticalAlignment"
|
||||
Value="Center" />
|
||||
<!-- 标签字体的样式 -->
|
||||
<Style x:Key="VarTableLabelStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SecondaryTextBrush}" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<!-- 值字体的样式 -->
|
||||
<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" />
|
||||
<!-- 值字体的样式 -->
|
||||
<Style x:Key="VarTableValueStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="MinWidth" Value="100" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<DockPanel>
|
||||
|
||||
<ikw:SimpleStackPanel Margin="10"
|
||||
DockPanel.Dock="Top">
|
||||
<!-- 操作菜单 -->
|
||||
<controls:CommandBar x:Name="PrimaryCommandBar"
|
||||
DefaultLabelPosition="Right"
|
||||
IsOpen="False">
|
||||
<ui:AppBarButton Command="{Binding AddVariableCommand}"
|
||||
Label="添加变量">
|
||||
<ikw:SimpleStackPanel Margin="10" DockPanel.Dock="Top">
|
||||
<!-- 操作菜单 -->
|
||||
<controls:CommandBar
|
||||
x:Name="PrimaryCommandBar"
|
||||
DefaultLabelPosition="Right"
|
||||
IsOpen="False">
|
||||
<ui:AppBarButton Command="{Binding AddVariableCommand}" Label="添加变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
</ui:AppBarButton>
|
||||
|
||||
<ui:AppBarButton Command="{Binding EditVarDataCommand}"
|
||||
CommandParameter="{Binding VariableTable}"
|
||||
Label="编辑变量">
|
||||
<ui:AppBarButton
|
||||
Command="{Binding EditVarDataCommand}"
|
||||
CommandParameter="{Binding VariableTable}"
|
||||
Label="编辑变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
</ui:AppBarButton>
|
||||
|
||||
<ui:AppBarButton Label="删除变量"
|
||||
Click="DeleteVarData_Click">
|
||||
<ui:AppBarButton Click="DeleteVarData_Click" Label="删除变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
</ui:AppBarButton>
|
||||
|
||||
|
||||
<ui:AppBarButton Command="{Binding SaveModifiedVarDataCommand}"
|
||||
Label="保存变量">
|
||||
<ui:AppBarButton Command="{Binding SaveModifiedVarDataCommand}" Label="保存变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
|
||||
</ui:AppBarButton>
|
||||
<ui:AppBarButton Command="{Binding ImprotFromTiaVarTableCommand}"
|
||||
Label="从TIA变量表导入"
|
||||
Visibility="{Binding IsS7ProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<ui:AppBarButton
|
||||
Command="{Binding ImprotFromTiaVarTableCommand}"
|
||||
Label="从TIA变量表导入"
|
||||
Visibility="{Binding IsS7ProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Import}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
|
||||
</ui:AppBarButton>
|
||||
|
||||
<ui:AppBarButton Command="{Binding ImportFromOpcUaServerCommand}"
|
||||
Label="从OPC UA服务器导入"
|
||||
Visibility="{Binding IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<ui:AppBarButton
|
||||
Command="{Binding ImportFromOpcUaServerCommand}"
|
||||
Label="从OPC UA服务器导入"
|
||||
Visibility="{Binding IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Import}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
@@ -107,132 +95,133 @@
|
||||
</ui:AppBarButton>
|
||||
|
||||
|
||||
<ui:AppBarButton x:Name="ShareButton"
|
||||
Label="Share">
|
||||
<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"
|
||||
Icon="Setting"
|
||||
Label="Settings" />
|
||||
<ui:AppBarButton
|
||||
x:Name="SettingsButton"
|
||||
Icon="Setting"
|
||||
Label="Settings" />
|
||||
</ui:CommandBar.SecondaryCommands>
|
||||
|
||||
</controls:CommandBar>
|
||||
<!-- 变量表的名称描述等信息 -->
|
||||
<ikw:SimpleStackPanel Margin="5"
|
||||
Orientation="Horizontal"
|
||||
Spacing="10">
|
||||
<ui:ToggleSwitch OnContent="启用"
|
||||
OffContent="停用"
|
||||
Toggled="OnIsActiveChanged"
|
||||
FontSize="16"
|
||||
IsOn="{Binding CurrentVariableTable.IsActive}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
||||
Text="变量表名称:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
||||
Text="{Binding CurrentVariableTable.Name}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
||||
Text="变量表描述:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
||||
Text="{Binding CurrentVariableTable.Description}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
||||
Text="所属设备:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
||||
Text="{Binding CurrentVariableTable.Device.Name}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
||||
Text="协议:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}"
|
||||
Text="{Binding CurrentVariableTable.Protocol}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}"
|
||||
Text="搜索:" />
|
||||
<TextBox Width="200"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="5,0,0,0"
|
||||
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
|
||||
ui:ControlHelper.PlaceholderText="搜索变量..." />
|
||||
<!-- 变量表的名称描述等信息 -->
|
||||
<ikw:SimpleStackPanel
|
||||
Margin="5"
|
||||
Orientation="Horizontal"
|
||||
Spacing="10">
|
||||
<ui:ToggleSwitch
|
||||
FontSize="16"
|
||||
IsOn="{Binding CurrentVariableTable.IsActive}"
|
||||
OffContent="停用"
|
||||
OnContent="启用"
|
||||
Toggled="OnIsActiveChanged" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}" Text="变量表名称:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}" Text="{Binding CurrentVariableTable.Name}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}" Text="变量表描述:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}" Text="{Binding CurrentVariableTable.Description}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}" Text="所属设备:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}" Text="{Binding CurrentVariableTable.Device.Name}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}" Text="协议:" />
|
||||
<TextBlock Style="{StaticResource VarTableValueStyle}" Text="{Binding CurrentVariableTable.Protocol}" />
|
||||
<TextBlock Style="{StaticResource VarTableLabelStyle}" Text="搜索:" />
|
||||
<TextBox
|
||||
Width="200"
|
||||
Margin="5,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
ui:ControlHelper.PlaceholderText="搜索变量..."
|
||||
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
<DataGrid x:Name="BasicGridView"
|
||||
Margin="10"
|
||||
CellEditEnding="DataGrid_OnCellEditEnding"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserSortColumns="True"
|
||||
SelectionMode="Extended"
|
||||
SelectedItem="{Binding SelectedVariable}"
|
||||
ItemsSource="{Binding VariableItemListView}"
|
||||
Style="{StaticResource DataGridBaseStyle}">
|
||||
<DataGrid
|
||||
x:Name="BasicGridView"
|
||||
Margin="10"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserSortColumns="True"
|
||||
CellEditEnding="DataGrid_OnCellEditEnding"
|
||||
ItemsSource="{Binding VariableItemListView}"
|
||||
SelectedItem="{Binding SelectedVariable}"
|
||||
SelectionMode="Extended"
|
||||
Style="{StaticResource DataGridBaseStyle}">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="添加变量"
|
||||
Command="{Binding AddVarDataCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.VariableTable}">
|
||||
<MenuItem
|
||||
Command="{Binding AddVarDataCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.VariableTable}"
|
||||
Header="添加变量">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="编辑变量"
|
||||
Command="{Binding UpdateVariableCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.VariableTable}">
|
||||
<MenuItem
|
||||
Command="{Binding UpdateVariableCommand}"
|
||||
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.DataContext.VariableTable}"
|
||||
Header="编辑变量">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="删除变量"
|
||||
Click="DeleteVarData_Click">
|
||||
<MenuItem Click="DeleteVarData_Click" Header="删除变量">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="保存变量"
|
||||
Command="{Binding SaveModifiedVarDataCommand}">
|
||||
<MenuItem Command="{Binding SaveModifiedVarDataCommand}" Header="保存变量">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="从TIA变量表导入"
|
||||
Command="{Binding ImprotFromTiaVarTableCommand}"
|
||||
Visibility="{Binding IsS7ProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<MenuItem
|
||||
Command="{Binding ImprotFromTiaVarTableCommand}"
|
||||
Header="从TIA变量表导入"
|
||||
Visibility="{Binding IsS7ProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Import}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="从OPC UA服务器导入"
|
||||
Command="{Binding ImportFromOpcUaServerCommand}"
|
||||
Visibility="{Binding IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<MenuItem
|
||||
Command="{Binding ImportFromOpcUaServerCommand}"
|
||||
Header="从OPC UA服务器导入"
|
||||
Visibility="{Binding IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Import}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="修改轮询频率"
|
||||
Command="{Binding ChangePollLevelCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
|
||||
<MenuItem
|
||||
Command="{Binding ChangePollLevelCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
Header="修改轮询频率">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="修改OPC UA更新方式"
|
||||
Visibility="{Binding IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Command="{Binding ModifyOpcUaUpdateTypeCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
|
||||
<MenuItem
|
||||
Command="{Binding ModifyOpcUaUpdateTypeCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
Header="修改OPC UA更新方式"
|
||||
Visibility="{Binding IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Switch}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="修改启用状态"
|
||||
Command="{Binding ModifyIsActiveCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
|
||||
<MenuItem
|
||||
Command="{Binding ModifyIsActiveCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
Header="修改启用状态">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Switch}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="添加MQTT服务器"
|
||||
Command="{Binding AddMqttServerToVariablesCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
|
||||
<MenuItem
|
||||
Command="{Binding AddMqttServerToVariablesCommand}"
|
||||
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
Header="添加MQTT服务器">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
||||
</MenuItem.Icon>
|
||||
@@ -244,27 +233,18 @@
|
||||
<!-- <Setter Property="Background" Value="#fff"/> -->
|
||||
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsModified}"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource SecondaryRegionBrush}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="FontWeight"
|
||||
Value="Bold" />
|
||||
<DataTrigger Binding="{Binding IsModified}" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
</DataTrigger>
|
||||
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource HoverBrush}" />
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource HoverBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource PrimaryBrush}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource TextIconBrush}" />
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
@@ -272,26 +252,26 @@
|
||||
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="名称"
|
||||
Binding="{Binding Name}" />
|
||||
<DataGridTextColumn Header="描述"
|
||||
Binding="{Binding Description}" />
|
||||
<!-- <DataGridTextColumn IsReadOnly="True" -->
|
||||
<!-- Header="节点ID" -->
|
||||
<!-- Binding="{Binding NodeId}" /> -->
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="S7地址"
|
||||
Visibility="{Binding Source={StaticResource proxy}, Path=Data.IsS7ProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Binding="{Binding S7Address}" />
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="OPCUA节点ID"
|
||||
Visibility="{Binding Source={StaticResource proxy}, Path=Data.IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Binding="{Binding OpcUaNodeId}" />
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="数据类型"
|
||||
Binding="{Binding CSharpDataType}" />
|
||||
<DataGridTemplateColumn Header="信号类型"
|
||||
SortMemberPath="SignalType">
|
||||
<DataGridTextColumn Binding="{Binding Name}" Header="名称" />
|
||||
<DataGridTextColumn Binding="{Binding Description}" Header="描述" />
|
||||
<!-- <DataGridTextColumn IsReadOnly="True" -->
|
||||
<!-- Header="节点ID" -->
|
||||
<!-- Binding="{Binding NodeId}" /> -->
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding S7Address}"
|
||||
Header="S7地址"
|
||||
IsReadOnly="True"
|
||||
Visibility="{Binding Source={StaticResource proxy}, Path=Data.IsS7ProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding OpcUaNodeId}"
|
||||
Header="OPCUA节点ID"
|
||||
IsReadOnly="True"
|
||||
Visibility="{Binding Source={StaticResource proxy}, Path=Data.IsOpcUaProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding CSharpDataType}"
|
||||
Header="数据类型"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTemplateColumn Header="信号类型" SortMemberPath="SignalType">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding SignalType, Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
@@ -299,8 +279,7 @@
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource signalType}}"
|
||||
SelectedItem="{Binding SignalType}">
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource signalType}}" SelectedItem="{Binding SignalType}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
@@ -310,18 +289,15 @@
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="轮询频率"
|
||||
SortMemberPath="PollLevelType">
|
||||
<DataGridTemplateColumn Header="轮询频率" SortMemberPath="PollLevelType">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Text="{Binding PollLevel, Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
<TextBlock Text="{Binding PollLevel, Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource pollLevelType}}"
|
||||
SelectedItem="{Binding PollLevel}">
|
||||
<ComboBox ItemsSource="{Binding Source={StaticResource pollLevelType}}" SelectedItem="{Binding PollLevel}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
@@ -331,34 +307,31 @@
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="当前值"
|
||||
Binding="{Binding DataValue}" />
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="显示值"
|
||||
Binding="{Binding DisplayValue}" />
|
||||
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="创建时间"
|
||||
Binding="{Binding CreatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
|
||||
<DataGridTextColumn IsReadOnly="True"
|
||||
Header="更新时间"
|
||||
Binding="{Binding UpdatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
|
||||
<DataGridTextColumn Header="转换规则"
|
||||
Binding="{Binding ConversionFormula}" />
|
||||
<DataGridCheckBoxColumn Header="启用"
|
||||
Binding="{Binding IsActive}" />
|
||||
<DataGridCheckBoxColumn Header="保存"
|
||||
Binding="{Binding IsHistoryEnabled}" />
|
||||
<DataGridTextColumn Header="保存范围"
|
||||
Binding="{Binding HistoryDeadband}" />
|
||||
<DataGridCheckBoxColumn Header="报警"
|
||||
Binding="{Binding IsAlarmEnabled}" />
|
||||
<DataGridTextColumn Header="报警最小值"
|
||||
Binding="{Binding AlarmMinValue}" />
|
||||
<DataGridTextColumn Header="报警最大值"
|
||||
Binding="{Binding AlarmMaxValue}" />
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding DataValue}"
|
||||
Header="当前值"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding DisplayValue}"
|
||||
Header="显示值"
|
||||
IsReadOnly="True" />
|
||||
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding CreatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
|
||||
Header="创建时间"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding UpdatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
|
||||
Header="更新时间"
|
||||
IsReadOnly="True" />
|
||||
<DataGridTextColumn Binding="{Binding ConversionFormula}" Header="转换规则" />
|
||||
<DataGridCheckBoxColumn Binding="{Binding IsActive}" Header="启用" />
|
||||
<DataGridCheckBoxColumn Binding="{Binding IsHistoryEnabled}" Header="保存" />
|
||||
<DataGridTextColumn Binding="{Binding HistoryDeadband}" Header="保存范围" />
|
||||
<DataGridCheckBoxColumn Binding="{Binding IsAlarmEnabled}" Header="报警" />
|
||||
<DataGridTextColumn Binding="{Binding AlarmMinValue}" Header="报警最小值" />
|
||||
<DataGridTextColumn Binding="{Binding AlarmMaxValue}" Header="报警最大值" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
|
||||
Reference in New Issue
Block a user