|
- <UserControl
- x:Class="BPASmart.VariableManager.Views.CommunicationSetView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:con="clr-namespace:BPASmart.VariableManager.Converter"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:BPASmart.VariableManager.Views"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
- xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
- d:DesignHeight="450"
- d:DesignWidth="1000"
- mc:Ignorable="d">
-
- <UserControl.DataContext>
- <vm:CommunicationSetViewModel />
- </UserControl.DataContext>
-
- <UserControl.Resources>
- <!--<ResourceDictionary Source="../Resource/Style/BasicStyle.xaml">
- <ResourceDictionary.MergedDictionaries>-->
- <ResourceDictionary>
-
- <con:DeviceVisibleConverter x:Key="DeviceVisibleConverter" />
-
- <Style x:Key="TextBlockStyle" TargetType="TextBlock">
- <Setter Property="FontFamily" Value="楷体" />
- <Setter Property="FontSize" Value="18" />
- <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
- <Setter Property="VerticalAlignment" Value="Center" />
- <Setter Property="HorizontalAlignment" Value="Center" />
- </Style>
-
- <Style x:Key="TextBoxStyle" TargetType="TextBox">
- <Setter Property="FontFamily" Value="楷体" />
- <Setter Property="FontSize" Value="22" />
- <Setter Property="Background" Value="Transparent" />
- <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
- <Setter Property="BorderBrush" Value="#FF23CACA" />
- <Setter Property="CaretBrush" Value="Aqua" />
- <Setter Property="VerticalAlignment" Value="Center" />
- </Style>
-
-
-
- </ResourceDictionary>
- <!--</ResourceDictionary.MergedDictionaries>
- </ResourceDictionary>-->
- </UserControl.Resources>
-
- <Grid Margin="10">
- <Grid.RowDefinitions>
- <RowDefinition Height="35" />
- <RowDefinition />
- </Grid.RowDefinitions>
-
- <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
-
- <pry:IcoButton
- Grid.Column="3"
- Width="140"
- Margin="0,0,20,0"
- HorizontalAlignment="Left"
- Command="{Binding NewConnectCommand}"
- Content="新建连接"
- FontSize="16"
- Foreground="Aqua"
- IcoText=""
- Style="{StaticResource IcoButtonStyle}" />
-
- <pry:IcoButton
- Grid.Column="3"
- Width="140"
- Margin="0,0,20,0"
- HorizontalAlignment="Left"
- Command="{Binding SaveConnectSetCommand}"
- Content="保存连接"
- FontSize="17"
- Foreground="Aqua"
- IcoText=""
- IsEnabled="True"
- Style="{StaticResource IcoButtonStyle}" />
- </StackPanel>
-
- <ScrollViewer
- Name="sv"
- Grid.Row="1"
- Margin="0,10,0,0"
- HorizontalScrollBarVisibility="Hidden"
- VerticalScrollBarVisibility="Hidden">
- <ItemsControl ItemsSource="{Binding communicationDevices}">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <Grid
- Name="cy"
- Height="180"
- Margin="0,0,0,30">
- <!--<Grid.Background>
- <ImageBrush ImageSource="/Resources/Images/边框1.png" />
- </Grid.Background>-->
- <Grid.RowDefinitions>
- <RowDefinition Height="30" />
- <RowDefinition />
- </Grid.RowDefinitions>
-
- <!--#region 标题显示及操作-->
- <Grid Height="30" Margin="0,0,0,0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition Width="0.3*" />
- <ColumnDefinition />
- </Grid.ColumnDefinitions>
-
- <pry:TitleTextBlock Margin="2,2,0,0" />
-
- <StackPanel
- Margin="5"
- HorizontalAlignment="Left"
- VerticalAlignment="Center"
- Orientation="Horizontal">
- <TextBlock
- Margin="0,0,10,0"
- FontFamily="楷体"
- FontSize="20"
- Foreground="Aqua"
- Text="{Binding DeviceName}" />
-
- <TextBlock
- FontFamily="楷体"
- FontSize="20"
- Foreground="Yellow"
- Text="[" />
-
- <TextBlock
- FontFamily="楷体"
- FontSize="20"
- Foreground="Yellow"
- Text="{Binding ModelName}" />
-
- <TextBlock
- FontFamily="楷体"
- FontSize="20"
- Foreground="Yellow"
- Text="]" />
- </StackPanel>
-
- </Grid>
- <!--#endregion-->
-
- <!--#region 西门子设备-->
- <Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=Siemens}">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition Width="0.2*" />
- </Grid.ColumnDefinitions>
-
- <Grid.RowDefinitions>
- <RowDefinition />
- <RowDefinition Height="20" />
- <RowDefinition />
- </Grid.RowDefinitions>
-
- <TextBlock
- Grid.Column="0"
- Style="{StaticResource TextBlockStyle}"
- Text="IP地址:" />
- <TextBox
- Grid.Column="1"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.IP}" />
-
- <TextBlock
- Grid.Column="2"
- Style="{StaticResource TextBlockStyle}"
- Text="端口号:" />
- <TextBox
- Grid.Column="3"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.PortNum}" />
-
- <TextBlock
- Grid.Column="4"
- Style="{StaticResource TextBlockStyle}"
- Text="PLC类型:" />
- <ComboBox
- Grid.Column="5"
- Margin="0,0,20,0"
- VerticalAlignment="Center"
- BorderBrush="#FF23CACA"
- BorderThickness="1"
- FontFamily="楷体"
- FontSize="20"
- Foreground="#ff23caca"
- IsEditable="False"
- ItemsSource="{Binding DataContext.PlcTypes, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- SelectedIndex="0"
- Style="{StaticResource ComboBoxStyle}"
- Text="{Binding CommDevice.PlcType}" />
-
- <Button
- Grid.Column="7"
- Height="30"
- Margin="0,0,10,0"
- Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- CommandParameter="{Binding DeviceName}"
- Content="删除"
- FontFamily="楷体"
- FontSize="20"
- Foreground="#FFDE7889"
- Template="{StaticResource RemoveButtonTemplate}" />
-
- <TextBlock
- Grid.Row="2"
- Style="{StaticResource TextBlockStyle}"
- Text="机架号:" />
- <TextBox
- Grid.Row="2"
- Grid.Column="1"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.Rack}" />
-
- <TextBlock
- Grid.Row="2"
- Grid.Column="2"
- Style="{StaticResource TextBlockStyle}"
- Text="插槽号:" />
- <TextBox
- Grid.Row="2"
- Grid.Column="3"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.Slot}" />
-
- <CheckBox
- Grid.Row="2"
- Grid.Column="7"
- Width="100"
- Height="20"
- Margin="10"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Background="#FF2AB2E7"
- Content="IsActive"
- FontSize="16"
- Foreground="#ddd"
- IsChecked="{Binding IsActive}"
- Template="{StaticResource CbTemplate}" />
- </Grid>
- </Grid>
- <!--#endregion-->
-
- <!--#region Modbus Tcp 设备-->
- <Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusTcp}">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition Width="0.2*" />
- </Grid.ColumnDefinitions>
-
- <Grid.RowDefinitions>
- <RowDefinition />
- <RowDefinition Height="20" />
- <RowDefinition />
- </Grid.RowDefinitions>
-
-
- <TextBlock
- Grid.Column="0"
- Style="{StaticResource TextBlockStyle}"
- Text="IP地址:" />
- <TextBox
- Grid.Column="1"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.IP}" />
-
- <TextBlock
- Grid.Column="2"
- Style="{StaticResource TextBlockStyle}"
- Text="端口号:" />
- <TextBox
- Grid.Column="3"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.PortNum}" />
-
- <TextBlock
- Grid.Column="4"
- Style="{StaticResource TextBlockStyle}"
- Text="站号:" />
- <TextBox
- Grid.Column="5"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.StationNo}" />
-
- <Button
- Grid.Column="7"
- Height="30"
- Margin="0,0,10,0"
- Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- CommandParameter="{Binding DeviceName}"
- Content="删除"
- FontFamily="楷体"
- FontSize="20"
- Foreground="#FFDE7889"
- Template="{StaticResource RemoveButtonTemplate}" />
-
- <CheckBox
- Grid.Row="2"
- Grid.Column="7"
- Width="100"
- Height="20"
- Margin="10"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Background="#FF2AB2E7"
- Content="IsActive"
- FontSize="16"
- Foreground="#ddd"
- IsChecked="{Binding IsActive}"
- Template="{StaticResource CbTemplate}" />
-
- </Grid>
- </Grid>
- <!--#endregion-->
-
- <!--#region Modbus RTU 设备-->
- <Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusRtu}">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- <ColumnDefinition Width="0.2*" />
- </Grid.ColumnDefinitions>
-
- <Grid.RowDefinitions>
- <RowDefinition />
- <RowDefinition Height="20" />
- <RowDefinition />
- </Grid.RowDefinitions>
-
- <TextBlock Style="{StaticResource TextBlockStyle}" Text="端口号:" />
- <ComboBox
- Grid.Column="1"
- Margin="0,0,20,0"
- VerticalAlignment="Center"
- BorderBrush="#FF23CACA"
- BorderThickness="1"
- FontFamily="楷体"
- FontSize="20"
- Foreground="#ff23caca"
- IsEditable="True"
- ItemsSource="{Binding DataContext.Ports, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- SelectedIndex="0"
- Style="{StaticResource ComboBoxStyle}"
- Text="{Binding CommDevice.ComSerialPort}" />
-
- <TextBlock
- Grid.Column="2"
- Style="{StaticResource TextBlockStyle}"
- Text="波特率:" />
- <ComboBox
- Grid.Column="3"
- Margin="0,0,20,0"
- VerticalAlignment="Center"
- BorderBrush="#FF23CACA"
- BorderThickness="1"
- FontFamily="楷体"
- FontSize="20"
- Foreground="#ff23caca"
- IsEditable="False"
- ItemsSource="{Binding DataContext.BaudRates, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- SelectedIndex="6"
- Style="{StaticResource ComboBoxStyle}"
- Text="{Binding CommDevice.BaudRate}" />
-
-
- <TextBlock
- Grid.Column="4"
- Style="{StaticResource TextBlockStyle}"
- Text="奇偶:" />
- <ComboBox
- Grid.Column="5"
- Margin="0,0,20,0"
- VerticalAlignment="Center"
- BorderBrush="#FF23CACA"
- BorderThickness="1"
- FontFamily="楷体"
- FontSize="20"
- Foreground="#ff23caca"
- IsEditable="False"
- ItemsSource="{Binding DataContext.Paritys, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- SelectedIndex="0"
- Style="{StaticResource ComboBoxStyle}"
- Text="{Binding CommDevice.Parity}" />
-
- <TextBlock
- Grid.Row="2"
- Grid.Column="0"
- Style="{StaticResource TextBlockStyle}"
- Text="数据位:" />
- <TextBox
- Grid.Row="2"
- Grid.Column="1"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.DataBit}" />
- <TextBlock
- Grid.Row="2"
- Grid.Column="2"
- Style="{StaticResource TextBlockStyle}"
- Text="停止位:" />
- <TextBox
- Grid.Row="2"
- Grid.Column="3"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.StopBit}" />
-
- <TextBlock
- Grid.Row="2"
- Grid.Column="4"
- Style="{StaticResource TextBlockStyle}"
- Text="站号:" />
- <TextBox
- Grid.Row="2"
- Grid.Column="5"
- Margin="0,0,20,0"
- Style="{StaticResource TextBoxStyle}"
- Text="{Binding CommDevice.StationNo}" />
-
- <Button
- Grid.Column="7"
- Height="30"
- Margin="0,0,10,0"
- Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- CommandParameter="{Binding DeviceName}"
- Content="删除"
- FontFamily="楷体"
- FontSize="20"
- Foreground="#FFDE7889"
- Template="{StaticResource RemoveButtonTemplate}" />
-
- <CheckBox
- Grid.Row="2"
- Grid.Column="7"
- Width="100"
- Height="20"
- Margin="10"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- Background="#FF2AB2E7"
- Content="IsActive"
- FontSize="16"
- Foreground="#ddd"
- IsChecked="{Binding IsActive}"
- Template="{StaticResource CbTemplate}" />
- </Grid>
- </Grid>
- <!--#endregion-->
-
- </Grid>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
-
- </ScrollViewer>
- </Grid>
- </UserControl>
|