123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <UserControl x:Class="MV485.uc.UCDeviceConfig"
- 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:local="clr-namespace:MV485.uc"
- xmlns:zdfflatui="clr-namespace:ZdfFlatUI;assembly=WPF.UI"
- mc:Ignorable="d"
- Padding="5,2,5,5"
- Background="WhiteSmoke"
- SizeChanged="UserControl_SizeChanged"
- d:DesignHeight="800" d:DesignWidth="1024">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
- </Grid.RowDefinitions>
- <!-- 控制面板 -->
- <StackPanel Orientation="Horizontal" Margin="10 10 10 5" >
- <TextBlock Text="端口号: " VerticalAlignment="Center" FontSize="14px" Margin="0 0 0 0" />
- <ComboBox x:Name="cmbPortNames" DisplayMemberPath="ModelName" SelectedValuePath="PortName"
- SelectionChanged="CmbPortNames_SelectionChanged"
- Width="180" Padding="5 0 0 0" Margin="2" FontSize="13px" VerticalContentAlignment="Center"/>
- <zdfflatui:FlatButton x:Name="btnRefreshPorts" HorizontalAlignment="Center" Background="#2196F3"
- Foreground="White" Content="🔄" ToolTip="刷新并重新加载串口列表"
- Click="btnRefreshPorts_Click" Margin="5 0 5 0" Width="30" Height="30" FontSize="20px" />
- <TextBlock Text="设备波特率: " VerticalAlignment="Center" FontSize="14" Margin="10 0 0 0" />
- <ComboBox x:Name="cmbBaudrate"
- Width="100" Padding="5 0 0 0" Margin="2" FontSize="13px" VerticalContentAlignment="Center"/>
- <TextBlock Text="设备地址: " VerticalAlignment="Center" FontSize="14" Margin="10 0 0 0" />
- <!--<TextBox x:Name="txtDevId" Text="1" FontSize="13" Width="60" Margin="0 0 0 0"
- PreviewTextInput="TextBox_PreviewTextInput" MaxLength="3"
- TextAlignment="Left" VerticalContentAlignment="Center" Height="24" />-->
- <ComboBox x:Name="cmbDevId" Width="60" Padding="5 0 0 0" Margin="0" FontSize="14"
- PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center" Height="28" IsEditable="True"/>
- <zdfflatui:FlatButton x:Name="btnReadConfig" Background="#4CAF50" Foreground="White" Content="读取485基本参数" Width="120"
- Click="BtnReadConfig_Click" Padding="10 0 10 0" Height="28" FontSize="13" Margin="10 0 0 0" />
- <zdfflatui:FlatButton x:Name="btnClearLog" HorizontalAlignment="Center" Background="#FF4C4C" Foreground="White" Width="80"
- Content="清空日志" Click="btnClearLog_Click" Padding="10 0 10 0" Height="28" FontSize="13" Margin="10 0 0 0" />
- </StackPanel>
- <Border Grid.Row="1" Margin="10" BorderBrush="DarkGray" BorderThickness="1">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="300" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Border Grid.Column="0" BorderBrush="DarkGray" BorderThickness="0 0 1 0" Background="White" >
- <StackPanel Orientation="Vertical" Margin="10 0 0 0">
- <Grid Height="50">
- <TextBlock Text="请先读取基本参数后,才可修改。" FontSize="14" FontWeight="Bold"
- VerticalAlignment="Center" Foreground="DarkBlue" />
- </Grid>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="设备类型" Width="80" VerticalAlignment="Center" FontSize="14" />
- <TextBox IsReadOnly="True" x:Name="txtDevType" VerticalContentAlignment="Center"
- Text="0x4001" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
- <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
- VerticalAlignment="Center" />
- </StackPanel>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="设备序号" Width="80" VerticalAlignment="Center" FontSize="14" />
- <TextBox IsReadOnly="True" x:Name="txtDevSn" VerticalContentAlignment="Center"
- Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
- <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
- VerticalAlignment="Center" />
- </StackPanel>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="固件版本" Width="80" VerticalAlignment="Center" FontSize="14" />
- <TextBox IsReadOnly="True" x:Name="txtFireware" VerticalContentAlignment="Center"
- Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
- <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
- VerticalAlignment="Center" />
- </StackPanel>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="校验和" Width="80" VerticalAlignment="Center" FontSize="14" />
- <TextBox IsReadOnly="True" x:Name="txtParty" VerticalContentAlignment="Center"
- Text="None" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
- <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
- VerticalAlignment="Center" />
- </StackPanel>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="数据位" Width="80" VerticalAlignment="Center" FontSize="14" />
- <TextBox IsReadOnly="True" x:Name="txtDataBits" VerticalContentAlignment="Center"
- Text="8" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
- <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
- VerticalAlignment="Center" />
- </StackPanel>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="停止位" Width="80" VerticalAlignment="Center" FontSize="14" />
- <TextBox IsReadOnly="True" x:Name="txtStopBits" VerticalContentAlignment="Center"
- Text="1" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
- <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
- VerticalAlignment="Center" />
- </StackPanel>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="设备波特率" Width="80" VerticalAlignment="Center" FontSize="14" />
- <!--<TextBox IsEnabled="True" x:Name="txtDevBaudrate" VerticalContentAlignment="Center"
- Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />-->
- <ComboBox x:Name="cmbDevBaudrate" Width="120" Padding="5 0 0 0" Margin="0" FontSize="14"
- VerticalContentAlignment="Center" Height="28" IsEditable="False" IsEnabled="False" />
- <!--zdfflatui:FlatButton x:Name="btnSetBaudrate" Background="#2196F3" Foreground="White"
- Content="设置" Width="60" Click="BtnSetBaudrate_Click"
- Padding="10 0 10 0" Height="28" FontSize="14" Margin="10 0 0 0" /-->
- </StackPanel>
- <StackPanel Orientation="Horizontal" Height="50">
- <TextBlock Text="设备地址" Width="80" VerticalAlignment="Center" FontSize="14" />
- <!--<TextBox IsEnabled="True" x:Name="txtDevAddress" VerticalContentAlignment="Center"
- Text="1" FontSize="14" Width="40" Height="26" Padding="5 0 0 0" />-->
- <ComboBox x:Name="cmbDevAddress" Width="120" Padding="5 0 0 0" Margin="0" FontSize="14" IsEnabled="False"
- PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center" Height="28" IsEditable="True"/>
- <TextBlock Text="(1~247)" Width="60" Foreground="OrangeRed" VerticalAlignment="Center" Padding="6 0 0 0" FontSize="14" />
- <!--zdfflatui:FlatButton x:Name="btnSetDevAddress" Background="#2196F3" Foreground="White"
- Content="设置" Width="60" Click="BtnSetDevAddress_Click"
- Padding="10 0 10 0" Height="28" FontSize="14" Margin="10 0 0 0" /-->
- </StackPanel>
- <Grid Height="50" Margin="0 0 10 0">
- <zdfflatui:FlatButton x:Name="btnSetConifg" Background="#2196F3" Foreground="White"
- Content="设置485设备基本参数" Click="BtnSetConifg_Click"
- Height="28" FontSize="14" Margin="20 0 20 0" />
- </Grid>
- <Grid Height="50">
- <CheckBox Content="设置成功后自动回填读取参数" FontSize="14" VerticalAlignment="Center"
- x:Name="chkFillReadParams" IsChecked="True"/>
- </Grid>
- <Grid Height="50">
- <TextBlock x:Name="txtResult" Grid.Row="2" FontSize="14"
- VerticalAlignment="Center" FontWeight="Bold" Margin="0" Foreground="Green"/>
- </Grid>
-
- </StackPanel>
- </Border>
- <ListView x:Name="lvLogs" Grid.Column="1" Margin="0" BorderThickness="0">
- <ListView.ContextMenu>
- <ContextMenu>
- <!--<MenuItem Header="复制消息" Click="MenuItem_CopyMessage_Click"/>-->
- <MenuItem x:Name="miDeleteSlave" Header="复制消息" FontSize="13" Foreground="Blue" Click="MenuItem_CopyMessage_Click" >
- <MenuItem.Icon>
- <Image Source="pack://application:,,,/MV485;component/Assest/copy.png" Width="16" Height="16"/>
- </MenuItem.Icon>
- </MenuItem>
- </ContextMenu>
- </ListView.ContextMenu>
- <ListView.Resources>
- <!-- 设置标题字体样式 -->
- <Style TargetType="GridViewColumnHeader">
- <Setter Property="FontSize" Value="14"/>
- <Setter Property="Foreground" Value="DarkBlue"/>
- <Setter Property="Height" Value="26"/>
- <!-- 设置标题的高度 -->
- <Setter Property="VerticalAlignment" Value="Center"/>
- <!-- 设置垂直对齐方式 -->
- </Style>
- <!-- 设置内容字体样式 -->
- <Style TargetType="TextBlock">
- <Setter Property="FontSize" Value="13"/>
- <Setter Property="Foreground" Value="Black"/>
- </Style>
- </ListView.Resources>
- <ListView.View>
- <GridView>
- <GridViewColumn Header="时间" Width="120" DisplayMemberBinding="{Binding Time}"/>
- <!--<GridViewColumn Header="消息" Width="500" DisplayMemberBinding="{Binding Message}"/>-->
- <!-- "消息" 列,支持换行 -->
- <GridViewColumn Header="消息" Width="Auto">
- <GridViewColumn.CellTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Message}" TextWrapping="Wrap"/>
- </DataTemplate>
- </GridViewColumn.CellTemplate>
- </GridViewColumn>
- </GridView>
- </ListView.View>
- </ListView>
- </Grid>
- </Border>
-
-
-
- </Grid>
- </UserControl>
|