UCDeviceConfig.xaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <UserControl x:Class="MV485.uc.UCDeviceConfig"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:MV485.uc"
  7. xmlns:zdfflatui="clr-namespace:ZdfFlatUI;assembly=WPF.UI"
  8. mc:Ignorable="d"
  9. Padding="5,2,5,5"
  10. Background="WhiteSmoke"
  11. SizeChanged="UserControl_SizeChanged"
  12. d:DesignHeight="800" d:DesignWidth="1024">
  13. <Grid>
  14. <Grid.RowDefinitions>
  15. <RowDefinition Height="Auto" />
  16. <RowDefinition Height="*" />
  17. </Grid.RowDefinitions>
  18. <!-- 控制面板 -->
  19. <StackPanel Orientation="Horizontal" Margin="10 10 10 5" >
  20. <TextBlock Text="端口号: " VerticalAlignment="Center" FontSize="14px" Margin="0 0 0 0" />
  21. <ComboBox x:Name="cmbPortNames" DisplayMemberPath="ModelName" SelectedValuePath="PortName"
  22. SelectionChanged="CmbPortNames_SelectionChanged"
  23. Width="180" Padding="5 0 0 0" Margin="2" FontSize="13px" VerticalContentAlignment="Center"/>
  24. <zdfflatui:FlatButton x:Name="btnRefreshPorts" HorizontalAlignment="Center" Background="#2196F3"
  25. Foreground="White" Content="🔄" ToolTip="刷新并重新加载串口列表"
  26. Click="btnRefreshPorts_Click" Margin="5 0 5 0" Width="30" Height="30" FontSize="20px" />
  27. <TextBlock Text="设备波特率: " VerticalAlignment="Center" FontSize="14" Margin="10 0 0 0" />
  28. <ComboBox x:Name="cmbBaudrate"
  29. Width="100" Padding="5 0 0 0" Margin="2" FontSize="13px" VerticalContentAlignment="Center"/>
  30. <TextBlock Text="设备地址: " VerticalAlignment="Center" FontSize="14" Margin="10 0 0 0" />
  31. <!--<TextBox x:Name="txtDevId" Text="1" FontSize="13" Width="60" Margin="0 0 0 0"
  32. PreviewTextInput="TextBox_PreviewTextInput" MaxLength="3"
  33. TextAlignment="Left" VerticalContentAlignment="Center" Height="24" />-->
  34. <ComboBox x:Name="cmbDevId" Width="60" Padding="5 0 0 0" Margin="0" FontSize="14"
  35. PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center" Height="28" IsEditable="True"/>
  36. <zdfflatui:FlatButton x:Name="btnReadConfig" Background="#4CAF50" Foreground="White" Content="读取485基本参数" Width="120"
  37. Click="BtnReadConfig_Click" Padding="10 0 10 0" Height="28" FontSize="13" Margin="10 0 0 0" />
  38. <zdfflatui:FlatButton x:Name="btnClearLog" HorizontalAlignment="Center" Background="#FF4C4C" Foreground="White" Width="80"
  39. Content="清空日志" Click="btnClearLog_Click" Padding="10 0 10 0" Height="28" FontSize="13" Margin="10 0 0 0" />
  40. </StackPanel>
  41. <Border Grid.Row="1" Margin="10" BorderBrush="DarkGray" BorderThickness="1">
  42. <Grid>
  43. <Grid.ColumnDefinitions>
  44. <ColumnDefinition Width="300" />
  45. <ColumnDefinition Width="*" />
  46. </Grid.ColumnDefinitions>
  47. <Border Grid.Column="0" BorderBrush="DarkGray" BorderThickness="0 0 1 0" Background="White" >
  48. <StackPanel Orientation="Vertical" Margin="10 0 0 0">
  49. <Grid Height="50">
  50. <TextBlock Text="请先读取基本参数后,才可修改。" FontSize="14" FontWeight="Bold"
  51. VerticalAlignment="Center" Foreground="DarkBlue" />
  52. </Grid>
  53. <StackPanel Orientation="Horizontal" Height="50">
  54. <TextBlock Text="设备类型" Width="80" VerticalAlignment="Center" FontSize="14" />
  55. <TextBox IsReadOnly="True" x:Name="txtDevType" VerticalContentAlignment="Center"
  56. Text="0x4001" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
  57. <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
  58. VerticalAlignment="Center" />
  59. </StackPanel>
  60. <StackPanel Orientation="Horizontal" Height="50">
  61. <TextBlock Text="设备序号" Width="80" VerticalAlignment="Center" FontSize="14" />
  62. <TextBox IsReadOnly="True" x:Name="txtDevSn" VerticalContentAlignment="Center"
  63. Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
  64. <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
  65. VerticalAlignment="Center" />
  66. </StackPanel>
  67. <StackPanel Orientation="Horizontal" Height="50">
  68. <TextBlock Text="固件版本" Width="80" VerticalAlignment="Center" FontSize="14" />
  69. <TextBox IsReadOnly="True" x:Name="txtFireware" VerticalContentAlignment="Center"
  70. Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
  71. <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
  72. VerticalAlignment="Center" />
  73. </StackPanel>
  74. <StackPanel Orientation="Horizontal" Height="50">
  75. <TextBlock Text="校验和" Width="80" VerticalAlignment="Center" FontSize="14" />
  76. <TextBox IsReadOnly="True" x:Name="txtParty" VerticalContentAlignment="Center"
  77. Text="None" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
  78. <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
  79. VerticalAlignment="Center" />
  80. </StackPanel>
  81. <StackPanel Orientation="Horizontal" Height="50">
  82. <TextBlock Text="数据位" Width="80" VerticalAlignment="Center" FontSize="14" />
  83. <TextBox IsReadOnly="True" x:Name="txtDataBits" VerticalContentAlignment="Center"
  84. Text="8" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
  85. <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
  86. VerticalAlignment="Center" />
  87. </StackPanel>
  88. <StackPanel Orientation="Horizontal" Height="50">
  89. <TextBlock Text="停止位" Width="80" VerticalAlignment="Center" FontSize="14" />
  90. <TextBox IsReadOnly="True" x:Name="txtStopBits" VerticalContentAlignment="Center"
  91. Text="1" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />
  92. <TextBlock Text="只读" FontSize="14" Foreground="Gray" Margin="20 0 0 0"
  93. VerticalAlignment="Center" />
  94. </StackPanel>
  95. <StackPanel Orientation="Horizontal" Height="50">
  96. <TextBlock Text="设备波特率" Width="80" VerticalAlignment="Center" FontSize="14" />
  97. <!--<TextBox IsEnabled="True" x:Name="txtDevBaudrate" VerticalContentAlignment="Center"
  98. Text="240505102203" FontSize="14" Width="120" Height="26" Padding="5 0 0 0" />-->
  99. <ComboBox x:Name="cmbDevBaudrate" Width="120" Padding="5 0 0 0" Margin="0" FontSize="14"
  100. VerticalContentAlignment="Center" Height="28" IsEditable="False" IsEnabled="False" />
  101. <!--zdfflatui:FlatButton x:Name="btnSetBaudrate" Background="#2196F3" Foreground="White"
  102. Content="设置" Width="60" Click="BtnSetBaudrate_Click"
  103. Padding="10 0 10 0" Height="28" FontSize="14" Margin="10 0 0 0" /-->
  104. </StackPanel>
  105. <StackPanel Orientation="Horizontal" Height="50">
  106. <TextBlock Text="设备地址" Width="80" VerticalAlignment="Center" FontSize="14" />
  107. <!--<TextBox IsEnabled="True" x:Name="txtDevAddress" VerticalContentAlignment="Center"
  108. Text="1" FontSize="14" Width="40" Height="26" Padding="5 0 0 0" />-->
  109. <ComboBox x:Name="cmbDevAddress" Width="120" Padding="5 0 0 0" Margin="0" FontSize="14" IsEnabled="False"
  110. PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center" Height="28" IsEditable="True"/>
  111. <TextBlock Text="(1~247)" Width="60" Foreground="OrangeRed" VerticalAlignment="Center" Padding="6 0 0 0" FontSize="14" />
  112. <!--zdfflatui:FlatButton x:Name="btnSetDevAddress" Background="#2196F3" Foreground="White"
  113. Content="设置" Width="60" Click="BtnSetDevAddress_Click"
  114. Padding="10 0 10 0" Height="28" FontSize="14" Margin="10 0 0 0" /-->
  115. </StackPanel>
  116. <Grid Height="50" Margin="0 0 10 0">
  117. <zdfflatui:FlatButton x:Name="btnSetConifg" Background="#2196F3" Foreground="White"
  118. Content="设置485设备基本参数" Click="BtnSetConifg_Click"
  119. Height="28" FontSize="14" Margin="20 0 20 0" />
  120. </Grid>
  121. <Grid Height="50">
  122. <CheckBox Content="设置成功后自动回填读取参数" FontSize="14" VerticalAlignment="Center"
  123. x:Name="chkFillReadParams" IsChecked="True"/>
  124. </Grid>
  125. <Grid Height="50">
  126. <TextBlock x:Name="txtResult" Grid.Row="2" FontSize="14"
  127. VerticalAlignment="Center" FontWeight="Bold" Margin="0" Foreground="Green"/>
  128. </Grid>
  129. </StackPanel>
  130. </Border>
  131. <ListView x:Name="lvLogs" Grid.Column="1" Margin="0" BorderThickness="0">
  132. <ListView.ContextMenu>
  133. <ContextMenu>
  134. <!--<MenuItem Header="复制消息" Click="MenuItem_CopyMessage_Click"/>-->
  135. <MenuItem x:Name="miDeleteSlave" Header="复制消息" FontSize="13" Foreground="Blue" Click="MenuItem_CopyMessage_Click" >
  136. <MenuItem.Icon>
  137. <Image Source="pack://application:,,,/MV485;component/Assest/copy.png" Width="16" Height="16"/>
  138. </MenuItem.Icon>
  139. </MenuItem>
  140. </ContextMenu>
  141. </ListView.ContextMenu>
  142. <ListView.Resources>
  143. <!-- 设置标题字体样式 -->
  144. <Style TargetType="GridViewColumnHeader">
  145. <Setter Property="FontSize" Value="14"/>
  146. <Setter Property="Foreground" Value="DarkBlue"/>
  147. <Setter Property="Height" Value="26"/>
  148. <!-- 设置标题的高度 -->
  149. <Setter Property="VerticalAlignment" Value="Center"/>
  150. <!-- 设置垂直对齐方式 -->
  151. </Style>
  152. <!-- 设置内容字体样式 -->
  153. <Style TargetType="TextBlock">
  154. <Setter Property="FontSize" Value="13"/>
  155. <Setter Property="Foreground" Value="Black"/>
  156. </Style>
  157. </ListView.Resources>
  158. <ListView.View>
  159. <GridView>
  160. <GridViewColumn Header="时间" Width="120" DisplayMemberBinding="{Binding Time}"/>
  161. <!--<GridViewColumn Header="消息" Width="500" DisplayMemberBinding="{Binding Message}"/>-->
  162. <!-- "消息" 列,支持换行 -->
  163. <GridViewColumn Header="消息" Width="Auto">
  164. <GridViewColumn.CellTemplate>
  165. <DataTemplate>
  166. <TextBlock Text="{Binding Message}" TextWrapping="Wrap"/>
  167. </DataTemplate>
  168. </GridViewColumn.CellTemplate>
  169. </GridViewColumn>
  170. </GridView>
  171. </ListView.View>
  172. </ListView>
  173. </Grid>
  174. </Border>
  175. </Grid>
  176. </UserControl>