2025-08-23 21:30:04 +08:00
|
|
|
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.DeviceDialog"
|
2025-07-01 21:34:20 +08:00
|
|
|
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:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
2025-08-23 21:30:04 +08:00
|
|
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
2025-07-26 10:05:43 +08:00
|
|
|
xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
|
2025-07-18 19:56:00 +08:00
|
|
|
xmlns:ex="clr-namespace:DMS.Extensions"
|
2025-07-26 10:05:43 +08:00
|
|
|
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
2025-07-27 22:35:07 +08:00
|
|
|
xmlns:vc="clr-namespace:DMS.WPF.ValueConverts"
|
2025-07-01 21:34:20 +08:00
|
|
|
Title="{Binding Title}"
|
|
|
|
|
CloseButtonText="取消"
|
|
|
|
|
DefaultButton="Primary"
|
2025-08-23 16:01:30 +08:00
|
|
|
PrimaryButtonText="{Binding PrimaryButText}"
|
2025-08-23 20:58:48 +08:00
|
|
|
PrimaryButtonCommand="{Binding PrimaryButtonCommand}"
|
2025-08-23 21:30:04 +08:00
|
|
|
CloseButtonCommand="{Binding CancleButtonCommand}"
|
2025-07-01 21:34:20 +08:00
|
|
|
d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}"
|
2025-08-23 21:30:04 +08:00
|
|
|
mc:Ignorable="d"
|
|
|
|
|
>
|
2025-07-27 21:08:58 +08:00
|
|
|
|
2025-06-20 18:53:29 +08:00
|
|
|
<ui:ContentDialog.Resources>
|
2025-08-23 21:30:04 +08:00
|
|
|
<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}" />
|
2025-06-23 17:01:06 +08:00
|
|
|
<vc:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
2025-07-27 22:35:07 +08:00
|
|
|
<vc:EnumToStringConverter x:Key="EnumToStringConverter" />
|
2025-07-01 21:34:20 +08:00
|
|
|
|
2025-08-23 21:30:04 +08:00
|
|
|
<!-- 统一定义输入控件的下边距 -->
|
|
|
|
|
<Style TargetType="hc:TextBox" BasedOn="{StaticResource {x:Type hc:TextBox}}">
|
|
|
|
|
<Setter Property="Margin" Value="0,0,0,15"/>
|
|
|
|
|
</Style>
|
|
|
|
|
<Style TargetType="hc:ComboBox" BasedOn="{StaticResource {x:Type hc:ComboBox}}">
|
|
|
|
|
<Setter Property="Margin" Value="0,0,0,15"/>
|
|
|
|
|
</Style>
|
|
|
|
|
<Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
|
|
|
|
|
<Setter Property="Margin" Value="0,10,0,0"/>
|
|
|
|
|
</Style>
|
|
|
|
|
<Style x:Key="ConditionalPanelStyle" TargetType="Border">
|
|
|
|
|
<Setter Property="Padding" Value="10"/>
|
|
|
|
|
<Setter Property="Margin" Value="0,0,0,15"/>
|
|
|
|
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
|
|
|
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
|
|
|
|
<Setter Property="BorderThickness" Value="1"/>
|
|
|
|
|
<Setter Property="CornerRadius" Value="4"/>
|
|
|
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
|
|
|
</Style>
|
2025-06-20 18:53:29 +08:00
|
|
|
</ui:ContentDialog.Resources>
|
2025-07-01 21:34:20 +08:00
|
|
|
|
2025-08-23 21:30:04 +08:00
|
|
|
<Grid Margin="10">
|
2025-07-01 11:11:02 +08:00
|
|
|
<Grid.ColumnDefinitions>
|
2025-07-01 21:34:20 +08:00
|
|
|
<ColumnDefinition Width="1*" />
|
|
|
|
|
<ColumnDefinition Width="1*" />
|
2025-07-01 11:11:02 +08:00
|
|
|
</Grid.ColumnDefinitions>
|
2025-08-23 21:30:04 +08:00
|
|
|
|
2025-07-01 11:11:02 +08:00
|
|
|
<!-- 左边列 -->
|
2025-08-23 21:30:04 +08:00
|
|
|
<StackPanel Grid.Column="0" MinWidth="220" Margin="0,0,10,0">
|
|
|
|
|
<hc:TextBox hc:InfoElement.Title="设备名称"
|
|
|
|
|
Text="{Binding Device.Name, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
|
|
|
|
<hc:TextBox hc:InfoElement.Title="设备IP地址"
|
|
|
|
|
Text="{Binding Device.IpAddress, UpdateSourceTrigger=PropertyChanged}" />
|
2025-07-01 11:11:02 +08:00
|
|
|
|
2025-08-23 21:30:04 +08:00
|
|
|
<hc:ComboBox hc:InfoElement.Title="设备类型"
|
|
|
|
|
IsEnabled="{Binding IsAddMode}"
|
|
|
|
|
ItemsSource="{Binding Source={StaticResource DeviceType}}"
|
|
|
|
|
SelectedItem="{Binding Device.DeviceType}">
|
2025-07-27 22:35:07 +08:00
|
|
|
<ComboBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ComboBox.ItemTemplate>
|
2025-08-23 21:30:04 +08:00
|
|
|
</hc:ComboBox>
|
2025-07-01 11:11:02 +08:00
|
|
|
|
2025-08-23 21:30:04 +08:00
|
|
|
<CheckBox Content="是否添加默认变量表"
|
|
|
|
|
IsChecked="{Binding Device.IsAddDefVarTable}" />
|
|
|
|
|
</StackPanel>
|
2025-07-01 21:34:20 +08:00
|
|
|
|
2025-07-01 11:11:02 +08:00
|
|
|
<!-- 右边列 -->
|
2025-08-23 21:30:04 +08:00
|
|
|
<StackPanel Grid.Column="1" MinWidth="220" Margin="10,0,0,0">
|
|
|
|
|
<hc:TextBox hc:InfoElement.Title="设备描述"
|
|
|
|
|
Text="{Binding Device.Description, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
|
|
|
|
<TextBlock Margin="8,0,0,5" Text="设备端口"/>
|
|
|
|
|
<hc:NumericUpDown
|
|
|
|
|
Value="{Binding Device.Port, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
|
|
|
|
|
<hc:ComboBox x:Name="ProtocolComboBox"
|
|
|
|
|
hc:InfoElement.Title="设备通信协议"
|
|
|
|
|
IsEnabled="{Binding IsAddMode}"
|
|
|
|
|
ItemsSource="{Binding Source={StaticResource ProtocolType}}"
|
|
|
|
|
SelectedItem="{Binding Device.Protocol}">
|
2025-07-01 11:11:02 +08:00
|
|
|
<ComboBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ComboBox.ItemTemplate>
|
2025-08-23 21:30:04 +08:00
|
|
|
</hc:ComboBox>
|
2025-08-23 20:58:48 +08:00
|
|
|
|
2025-08-23 21:30:04 +08:00
|
|
|
<!-- OpcUa Specific Properties -->
|
|
|
|
|
<Border x:Name="OpcUaPanel">
|
|
|
|
|
<Border.Style>
|
|
|
|
|
<Style TargetType="Border" BasedOn="{StaticResource ConditionalPanelStyle}">
|
2025-07-28 11:08:56 +08:00
|
|
|
<Style.Triggers>
|
2025-08-23 21:30:04 +08:00
|
|
|
<DataTrigger Binding="{Binding ElementName=ProtocolComboBox, Path=SelectedItem, Converter={StaticResource EnumToStringConverter}}" Value="OpcUa">
|
2025-07-28 11:08:56 +08:00
|
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
2025-08-23 21:30:04 +08:00
|
|
|
</Border.Style>
|
|
|
|
|
<StackPanel>
|
|
|
|
|
<hc:TextBox hc:InfoElement.Title="OpcUa服务器地址"
|
|
|
|
|
Text="{Binding Device.OpcUaServerUrl}"/>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Border>
|
2025-08-23 20:58:48 +08:00
|
|
|
|
2025-07-05 01:31:44 +08:00
|
|
|
<!-- S7 Specific Properties -->
|
2025-08-23 21:30:04 +08:00
|
|
|
<Border x:Name="S7PropertiesPanel">
|
|
|
|
|
<Border.Style>
|
|
|
|
|
<Style TargetType="Border" BasedOn="{StaticResource ConditionalPanelStyle}">
|
2025-07-05 01:31:44 +08:00
|
|
|
<Style.Triggers>
|
2025-08-23 21:30:04 +08:00
|
|
|
<DataTrigger Binding="{Binding ElementName=ProtocolComboBox, Path=SelectedItem, Converter={StaticResource EnumToStringConverter}}" Value="S7">
|
2025-07-05 01:31:44 +08:00
|
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
2025-08-23 21:30:04 +08:00
|
|
|
</Border.Style>
|
|
|
|
|
<StackPanel>
|
|
|
|
|
<hc:ComboBox hc:InfoElement.Title="CPU 类型"
|
|
|
|
|
ItemsSource="{Binding Source={StaticResource CpuType}}"
|
|
|
|
|
SelectedItem="{Binding Device.CpuType}" />
|
|
|
|
|
<TextBlock Margin="8,0,0,5" Text="机架号"/>
|
|
|
|
|
<hc:NumericUpDown
|
|
|
|
|
Value="{Binding Device.Rack, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
<TextBlock Margin="8,0,0,5" Text="槽号"/>
|
|
|
|
|
<hc:NumericUpDown
|
|
|
|
|
Value="{Binding Device.Slot, UpdateSourceTrigger=PropertyChanged}" />
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Border>
|
|
|
|
|
|
|
|
|
|
<CheckBox Content="是否启用"
|
|
|
|
|
IsChecked="{Binding Device.IsActive}" />
|
|
|
|
|
</StackPanel>
|
2025-07-01 11:11:02 +08:00
|
|
|
</Grid>
|
2025-07-01 21:34:20 +08:00
|
|
|
|
2025-06-12 13:15:55 +08:00
|
|
|
</ui:ContentDialog>
|