终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommunicationSetView.xaml 26 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <UserControl
  2. x:Class="BPASmart.VariableManager.Views.CommunicationSetView"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:con="clr-namespace:BPASmart.VariableManager.Converter"
  6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7. xmlns:local="clr-namespace:BPASmart.VariableManager.Views"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
  10. xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
  11. d:DesignHeight="450"
  12. d:DesignWidth="1000"
  13. mc:Ignorable="d">
  14. <UserControl.DataContext>
  15. <vm:CommunicationSetViewModel />
  16. </UserControl.DataContext>
  17. <UserControl.Resources>
  18. <!--<ResourceDictionary Source="../Resource/Style/BasicStyle.xaml">
  19. <ResourceDictionary.MergedDictionaries>-->
  20. <ResourceDictionary>
  21. <con:DeviceVisibleConverter x:Key="DeviceVisibleConverter" />
  22. <Style x:Key="TextBlockStyle" TargetType="TextBlock">
  23. <Setter Property="FontFamily" Value="楷体" />
  24. <Setter Property="FontSize" Value="18" />
  25. <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
  26. <Setter Property="VerticalAlignment" Value="Center" />
  27. <Setter Property="HorizontalAlignment" Value="Center" />
  28. </Style>
  29. <Style x:Key="TextBoxStyle" TargetType="TextBox">
  30. <Setter Property="FontFamily" Value="楷体" />
  31. <Setter Property="FontSize" Value="22" />
  32. <Setter Property="Background" Value="Transparent" />
  33. <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
  34. <Setter Property="BorderBrush" Value="#FF23CACA" />
  35. <Setter Property="CaretBrush" Value="Aqua" />
  36. <Setter Property="VerticalAlignment" Value="Center" />
  37. </Style>
  38. </ResourceDictionary>
  39. <!--</ResourceDictionary.MergedDictionaries>
  40. </ResourceDictionary>-->
  41. </UserControl.Resources>
  42. <Grid Margin="10">
  43. <Grid.RowDefinitions>
  44. <RowDefinition Height="35" />
  45. <RowDefinition />
  46. </Grid.RowDefinitions>
  47. <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
  48. <pry:IcoButton
  49. Grid.Column="3"
  50. Width="140"
  51. Margin="0,0,20,0"
  52. HorizontalAlignment="Left"
  53. Command="{Binding NewConnectCommand}"
  54. Content="新建连接"
  55. FontSize="16"
  56. Foreground="Aqua"
  57. IcoText="&#xe626;"
  58. Style="{StaticResource IcoButtonStyle}" />
  59. <pry:IcoButton
  60. Grid.Column="3"
  61. Width="140"
  62. Margin="0,0,20,0"
  63. HorizontalAlignment="Left"
  64. Command="{Binding SaveConnectSetCommand}"
  65. Content="保存连接"
  66. FontSize="17"
  67. Foreground="Aqua"
  68. IcoText="&#xe635;"
  69. IsEnabled="True"
  70. Style="{StaticResource IcoButtonStyle}" />
  71. </StackPanel>
  72. <ScrollViewer
  73. Name="sv"
  74. Grid.Row="1"
  75. Margin="0,10,0,0"
  76. HorizontalScrollBarVisibility="Hidden"
  77. VerticalScrollBarVisibility="Hidden">
  78. <ItemsControl ItemsSource="{Binding communicationDevices}">
  79. <ItemsControl.ItemTemplate>
  80. <DataTemplate>
  81. <Grid
  82. Name="cy"
  83. Height="180"
  84. Margin="0,0,0,30">
  85. <!--<Grid.Background>
  86. <ImageBrush ImageSource="/Resources/Images/边框1.png" />
  87. </Grid.Background>-->
  88. <Grid.RowDefinitions>
  89. <RowDefinition Height="30" />
  90. <RowDefinition />
  91. </Grid.RowDefinitions>
  92. <!--#region 标题显示及操作-->
  93. <Grid Height="30" Margin="0,0,0,0">
  94. <Grid.ColumnDefinitions>
  95. <ColumnDefinition Width="0.5*" />
  96. <ColumnDefinition Width="0.3*" />
  97. <ColumnDefinition />
  98. </Grid.ColumnDefinitions>
  99. <pry:TitleTextBlock Margin="2,2,0,0" />
  100. <StackPanel
  101. Margin="5"
  102. HorizontalAlignment="Left"
  103. VerticalAlignment="Center"
  104. Orientation="Horizontal">
  105. <TextBlock
  106. Margin="0,0,10,0"
  107. FontFamily="楷体"
  108. FontSize="20"
  109. Foreground="Aqua"
  110. Text="{Binding DeviceName}" />
  111. <TextBlock
  112. FontFamily="楷体"
  113. FontSize="20"
  114. Foreground="Yellow"
  115. Text="[" />
  116. <TextBlock
  117. FontFamily="楷体"
  118. FontSize="20"
  119. Foreground="Yellow"
  120. Text="{Binding ModelName}" />
  121. <TextBlock
  122. FontFamily="楷体"
  123. FontSize="20"
  124. Foreground="Yellow"
  125. Text="]" />
  126. </StackPanel>
  127. </Grid>
  128. <!--#endregion-->
  129. <!--#region 西门子设备-->
  130. <Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=Siemens}">
  131. <Grid>
  132. <Grid.ColumnDefinitions>
  133. <ColumnDefinition Width="0.5*" />
  134. <ColumnDefinition />
  135. <ColumnDefinition Width="0.5*" />
  136. <ColumnDefinition />
  137. <ColumnDefinition Width="0.5*" />
  138. <ColumnDefinition />
  139. <ColumnDefinition Width="0.5*" />
  140. <ColumnDefinition Width="0.2*" />
  141. </Grid.ColumnDefinitions>
  142. <Grid.RowDefinitions>
  143. <RowDefinition />
  144. <RowDefinition Height="20" />
  145. <RowDefinition />
  146. </Grid.RowDefinitions>
  147. <TextBlock
  148. Grid.Column="0"
  149. Style="{StaticResource TextBlockStyle}"
  150. Text="IP地址:" />
  151. <TextBox
  152. Grid.Column="1"
  153. Margin="0,0,20,0"
  154. Style="{StaticResource TextBoxStyle}"
  155. Text="{Binding CommDevice.IP}" />
  156. <TextBlock
  157. Grid.Column="2"
  158. Style="{StaticResource TextBlockStyle}"
  159. Text="端口号:" />
  160. <TextBox
  161. Grid.Column="3"
  162. Margin="0,0,20,0"
  163. Style="{StaticResource TextBoxStyle}"
  164. Text="{Binding CommDevice.PortNum}" />
  165. <TextBlock
  166. Grid.Column="4"
  167. Style="{StaticResource TextBlockStyle}"
  168. Text="PLC类型:" />
  169. <ComboBox
  170. Grid.Column="5"
  171. Margin="0,0,20,0"
  172. VerticalAlignment="Center"
  173. BorderBrush="#FF23CACA"
  174. BorderThickness="1"
  175. FontFamily="楷体"
  176. FontSize="20"
  177. Foreground="#ff23caca"
  178. IsEditable="False"
  179. ItemsSource="{Binding DataContext.PlcTypes, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  180. SelectedIndex="0"
  181. Style="{StaticResource ComboBoxStyle}"
  182. Text="{Binding CommDevice.PlcType}" />
  183. <Button
  184. Grid.Column="7"
  185. Height="30"
  186. Margin="0,0,10,0"
  187. Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  188. CommandParameter="{Binding DeviceName}"
  189. Content="删除"
  190. FontFamily="楷体"
  191. FontSize="20"
  192. Foreground="#FFDE7889"
  193. Template="{StaticResource RemoveButtonTemplate}" />
  194. <TextBlock
  195. Grid.Row="2"
  196. Style="{StaticResource TextBlockStyle}"
  197. Text="机架号:" />
  198. <TextBox
  199. Grid.Row="2"
  200. Grid.Column="1"
  201. Margin="0,0,20,0"
  202. Style="{StaticResource TextBoxStyle}"
  203. Text="{Binding CommDevice.Rack}" />
  204. <TextBlock
  205. Grid.Row="2"
  206. Grid.Column="2"
  207. Style="{StaticResource TextBlockStyle}"
  208. Text="插槽号:" />
  209. <TextBox
  210. Grid.Row="2"
  211. Grid.Column="3"
  212. Margin="0,0,20,0"
  213. Style="{StaticResource TextBoxStyle}"
  214. Text="{Binding CommDevice.Slot}" />
  215. <CheckBox
  216. Grid.Row="2"
  217. Grid.Column="7"
  218. Width="100"
  219. Height="20"
  220. Margin="10"
  221. HorizontalAlignment="Right"
  222. VerticalAlignment="Center"
  223. Background="#FF2AB2E7"
  224. Content="IsActive"
  225. FontSize="16"
  226. Foreground="#ddd"
  227. IsChecked="{Binding IsActive}"
  228. Template="{StaticResource CbTemplate}" />
  229. </Grid>
  230. </Grid>
  231. <!--#endregion-->
  232. <!--#region Modbus Tcp 设备-->
  233. <Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusTcp}">
  234. <Grid>
  235. <Grid.ColumnDefinitions>
  236. <ColumnDefinition Width="0.5*" />
  237. <ColumnDefinition />
  238. <ColumnDefinition Width="0.5*" />
  239. <ColumnDefinition />
  240. <ColumnDefinition Width="0.5*" />
  241. <ColumnDefinition />
  242. <ColumnDefinition Width="0.5*" />
  243. <ColumnDefinition Width="0.2*" />
  244. </Grid.ColumnDefinitions>
  245. <Grid.RowDefinitions>
  246. <RowDefinition />
  247. <RowDefinition Height="20" />
  248. <RowDefinition />
  249. </Grid.RowDefinitions>
  250. <TextBlock
  251. Grid.Column="0"
  252. Style="{StaticResource TextBlockStyle}"
  253. Text="IP地址:" />
  254. <TextBox
  255. Grid.Column="1"
  256. Margin="0,0,20,0"
  257. Style="{StaticResource TextBoxStyle}"
  258. Text="{Binding CommDevice.IP}" />
  259. <TextBlock
  260. Grid.Column="2"
  261. Style="{StaticResource TextBlockStyle}"
  262. Text="端口号:" />
  263. <TextBox
  264. Grid.Column="3"
  265. Margin="0,0,20,0"
  266. Style="{StaticResource TextBoxStyle}"
  267. Text="{Binding CommDevice.PortNum}" />
  268. <TextBlock
  269. Grid.Column="4"
  270. Style="{StaticResource TextBlockStyle}"
  271. Text="站号:" />
  272. <TextBox
  273. Grid.Column="5"
  274. Margin="0,0,20,0"
  275. Style="{StaticResource TextBoxStyle}"
  276. Text="{Binding CommDevice.StationNo}" />
  277. <Button
  278. Grid.Column="7"
  279. Height="30"
  280. Margin="0,0,10,0"
  281. Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  282. CommandParameter="{Binding DeviceName}"
  283. Content="删除"
  284. FontFamily="楷体"
  285. FontSize="20"
  286. Foreground="#FFDE7889"
  287. Template="{StaticResource RemoveButtonTemplate}" />
  288. <CheckBox
  289. Grid.Row="2"
  290. Grid.Column="7"
  291. Width="100"
  292. Height="20"
  293. Margin="10"
  294. HorizontalAlignment="Right"
  295. VerticalAlignment="Center"
  296. Background="#FF2AB2E7"
  297. Content="IsActive"
  298. FontSize="16"
  299. Foreground="#ddd"
  300. IsChecked="{Binding IsActive}"
  301. Template="{StaticResource CbTemplate}" />
  302. </Grid>
  303. </Grid>
  304. <!--#endregion-->
  305. <!--#region Modbus RTU 设备-->
  306. <Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusRtu}">
  307. <Grid>
  308. <Grid.ColumnDefinitions>
  309. <ColumnDefinition Width="0.5*" />
  310. <ColumnDefinition />
  311. <ColumnDefinition Width="0.5*" />
  312. <ColumnDefinition />
  313. <ColumnDefinition Width="0.5*" />
  314. <ColumnDefinition />
  315. <ColumnDefinition Width="0.5*" />
  316. <ColumnDefinition Width="0.2*" />
  317. </Grid.ColumnDefinitions>
  318. <Grid.RowDefinitions>
  319. <RowDefinition />
  320. <RowDefinition Height="20" />
  321. <RowDefinition />
  322. </Grid.RowDefinitions>
  323. <TextBlock Style="{StaticResource TextBlockStyle}" Text="端口号:" />
  324. <ComboBox
  325. Grid.Column="1"
  326. Margin="0,0,20,0"
  327. VerticalAlignment="Center"
  328. BorderBrush="#FF23CACA"
  329. BorderThickness="1"
  330. FontFamily="楷体"
  331. FontSize="20"
  332. Foreground="#ff23caca"
  333. IsEditable="True"
  334. ItemsSource="{Binding DataContext.Ports, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  335. SelectedIndex="0"
  336. Style="{StaticResource ComboBoxStyle}"
  337. Text="{Binding CommDevice.ComSerialPort}" />
  338. <TextBlock
  339. Grid.Column="2"
  340. Style="{StaticResource TextBlockStyle}"
  341. Text="波特率:" />
  342. <ComboBox
  343. Grid.Column="3"
  344. Margin="0,0,20,0"
  345. VerticalAlignment="Center"
  346. BorderBrush="#FF23CACA"
  347. BorderThickness="1"
  348. FontFamily="楷体"
  349. FontSize="20"
  350. Foreground="#ff23caca"
  351. IsEditable="False"
  352. ItemsSource="{Binding DataContext.BaudRates, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  353. SelectedIndex="6"
  354. Style="{StaticResource ComboBoxStyle}"
  355. Text="{Binding CommDevice.BaudRate}" />
  356. <TextBlock
  357. Grid.Column="4"
  358. Style="{StaticResource TextBlockStyle}"
  359. Text="奇偶:" />
  360. <ComboBox
  361. Grid.Column="5"
  362. Margin="0,0,20,0"
  363. VerticalAlignment="Center"
  364. BorderBrush="#FF23CACA"
  365. BorderThickness="1"
  366. FontFamily="楷体"
  367. FontSize="20"
  368. Foreground="#ff23caca"
  369. IsEditable="False"
  370. ItemsSource="{Binding DataContext.Paritys, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  371. SelectedIndex="0"
  372. Style="{StaticResource ComboBoxStyle}"
  373. Text="{Binding CommDevice.Parity}" />
  374. <TextBlock
  375. Grid.Row="2"
  376. Grid.Column="0"
  377. Style="{StaticResource TextBlockStyle}"
  378. Text="数据位:" />
  379. <TextBox
  380. Grid.Row="2"
  381. Grid.Column="1"
  382. Margin="0,0,20,0"
  383. Style="{StaticResource TextBoxStyle}"
  384. Text="{Binding CommDevice.DataBit}" />
  385. <TextBlock
  386. Grid.Row="2"
  387. Grid.Column="2"
  388. Style="{StaticResource TextBlockStyle}"
  389. Text="停止位:" />
  390. <TextBox
  391. Grid.Row="2"
  392. Grid.Column="3"
  393. Margin="0,0,20,0"
  394. Style="{StaticResource TextBoxStyle}"
  395. Text="{Binding CommDevice.StopBit}" />
  396. <TextBlock
  397. Grid.Row="2"
  398. Grid.Column="4"
  399. Style="{StaticResource TextBlockStyle}"
  400. Text="站号:" />
  401. <TextBox
  402. Grid.Row="2"
  403. Grid.Column="5"
  404. Margin="0,0,20,0"
  405. Style="{StaticResource TextBoxStyle}"
  406. Text="{Binding CommDevice.StationNo}" />
  407. <Button
  408. Grid.Column="7"
  409. Height="30"
  410. Margin="0,0,10,0"
  411. Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  412. CommandParameter="{Binding DeviceName}"
  413. Content="删除"
  414. FontFamily="楷体"
  415. FontSize="20"
  416. Foreground="#FFDE7889"
  417. Template="{StaticResource RemoveButtonTemplate}" />
  418. <CheckBox
  419. Grid.Row="2"
  420. Grid.Column="7"
  421. Width="100"
  422. Height="20"
  423. Margin="10"
  424. HorizontalAlignment="Right"
  425. VerticalAlignment="Center"
  426. Background="#FF2AB2E7"
  427. Content="IsActive"
  428. FontSize="16"
  429. Foreground="#ddd"
  430. IsChecked="{Binding IsActive}"
  431. Template="{StaticResource CbTemplate}" />
  432. </Grid>
  433. </Grid>
  434. <!--#endregion-->
  435. </Grid>
  436. </DataTemplate>
  437. </ItemsControl.ItemTemplate>
  438. </ItemsControl>
  439. </ScrollViewer>
  440. </Grid>
  441. </UserControl>