178 lines
8.4 KiB
XML
178 lines
8.4 KiB
XML
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.DeviceDialog"
|
|
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
|
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
|
xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
|
|
xmlns:ex="clr-namespace:DMS.Extensions"
|
|
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
|
xmlns:vc="clr-namespace:DMS.WPF.ValueConverts"
|
|
Title="{Binding Title}"
|
|
CloseButtonText="取消"
|
|
DefaultButton="Primary"
|
|
PrimaryButtonText="{Binding PrimaryButContent}"
|
|
d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}"
|
|
mc:Ignorable="d">
|
|
|
|
<i:Interaction.Triggers>
|
|
<i:EventTrigger EventName="PrimaryButtonClick">
|
|
<i:InvokeCommandAction Command="{Binding SaveCommand}" />
|
|
</i:EventTrigger>
|
|
<i:EventTrigger EventName="CloseButtonClick">
|
|
<i:InvokeCommandAction Command="{Binding CancelCommand}" />
|
|
</i:EventTrigger>
|
|
</i:Interaction.Triggers>
|
|
|
|
<ui:ContentDialog.Resources>
|
|
<ex:EnumBindingSource x:Key="deviceType"
|
|
EnumType="{x:Type enums:DeviceType}" />
|
|
<ex:EnumBindingSource x:Key="protocolType"
|
|
EnumType="{x:Type enums:ProtocolType}" />
|
|
<ex:EnumBindingSource x:Key="cpuType"
|
|
EnumType="{x:Type enums:CpuType}" />
|
|
<vc:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
|
<vc:EnumToStringConverter x:Key="EnumToStringConverter" />
|
|
|
|
|
|
</ui:ContentDialog.Resources>
|
|
|
|
<Grid Width="480"
|
|
Margin="10">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="1*" />
|
|
<ColumnDefinition Width="1*" />
|
|
</Grid.ColumnDefinitions>
|
|
<!-- 左边列 -->
|
|
<ikw:SimpleStackPanel Grid.Column="0"
|
|
Margin="10 10 20 10 "
|
|
Spacing="12">
|
|
<!-- 设备名称 -->
|
|
<TextBlock Text="设备名称"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<TextBox Text="{Binding Device.Name, UpdateSourceTrigger=PropertyChanged}" />
|
|
<!-- 设备IP地址 -->
|
|
<TextBlock Text="设备IP地址"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<TextBox AcceptsReturn="True"
|
|
Text="{Binding Device.IpAddress, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
<!-- 设备类型 -->
|
|
<TextBlock Text="设备类型"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<ComboBox
|
|
IsEnabled="{Binding IsAddMode}"
|
|
SelectedItem="{Binding Device.DeviceType}"
|
|
ItemsSource="{Binding Source={StaticResource deviceType} }">
|
|
<ComboBox.ItemTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
</DataTemplate>
|
|
</ComboBox.ItemTemplate>
|
|
</ComboBox>
|
|
|
|
<CheckBox FontSize="16"
|
|
Content="是否添加默认变量表"
|
|
Margin="0 30 0 0"
|
|
IsChecked="{Binding Device.IsAddDefVarTable}" />
|
|
|
|
</ikw:SimpleStackPanel>
|
|
<!-- 右边列 -->
|
|
<ikw:SimpleStackPanel Margin="10"
|
|
Grid.Column="1"
|
|
Spacing="12">
|
|
|
|
<!-- 设备描述 -->
|
|
<TextBlock Text="设备描述"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<TextBox Text="{Binding Device.Description, UpdateSourceTrigger=PropertyChanged}" />
|
|
<!-- 设备IP地址 -->
|
|
<TextBlock Text="设备端口"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<TextBox AcceptsReturn="True"
|
|
Text="{Binding Device.Port, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
<!-- 通讯协议-->
|
|
<TextBlock Text="设备通信协议"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<ComboBox x:Name="ProtocolComboBox"
|
|
IsEnabled="{Binding IsAddMode}"
|
|
SelectedItem="{Binding Device.Protocol}"
|
|
ItemsSource="{Binding Source={StaticResource protocolType} }">
|
|
<ComboBox.ItemTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
</DataTemplate>
|
|
</ComboBox.ItemTemplate>
|
|
</ComboBox>
|
|
|
|
<StackPanel Background="LightGray">
|
|
<StackPanel.Style>
|
|
<Style TargetType="StackPanel">
|
|
<Setter Property="Visibility" Value="Collapsed" />
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding ElementName=ProtocolComboBox, Path=SelectedItem, Converter={StaticResource EnumToStringConverter}}"
|
|
Value="OpcUa">
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</StackPanel.Style>
|
|
<TextBlock Text="OpcUa服务器地址"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<TextBox Text="{Binding Device.OpcUaServerUrl}"/>
|
|
</StackPanel>
|
|
|
|
|
|
<!-- S7 Specific Properties -->
|
|
<StackPanel x:Name="S7PropertiesPanel" Background="LightGray">
|
|
<StackPanel.Style>
|
|
<Style TargetType="StackPanel">
|
|
<Setter Property="Visibility" Value="Collapsed" />
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding ElementName=ProtocolComboBox, Path=SelectedItem, Converter={StaticResource EnumToStringConverter}}"
|
|
Value="S7">
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</StackPanel.Style>
|
|
<!-- CpuType -->
|
|
<TextBlock Text="CPU 类型"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<ComboBox SelectedItem="{Binding Device.CpuType}"
|
|
ItemsSource="{Binding Source={StaticResource cpuType}}" />
|
|
|
|
<!-- Rack -->
|
|
<TextBlock Text="机架号"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<TextBox Text="{Binding Device.Rack, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
<!-- Slot -->
|
|
<TextBlock Text="槽号"
|
|
HorizontalAlignment="Left"
|
|
Style="{StaticResource TextBlockSubTitle}" />
|
|
<TextBox Text="{Binding Device.Slot, UpdateSourceTrigger=PropertyChanged}" />
|
|
</StackPanel>
|
|
|
|
<CheckBox FontSize="16"
|
|
Content="是否启用"
|
|
Margin="0 30 0 0"
|
|
IsChecked="{Binding Device.IsActive}" />
|
|
|
|
</ikw:SimpleStackPanel>
|
|
</Grid>
|
|
|
|
</ui:ContentDialog> |