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.
 
 

546 lines
29 KiB

  1. <UserControl
  2. x:Class="HBLConsole.View.AlarmView"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:convert="clr-namespace:HBLConsole.Converter"
  6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7. xmlns:local="clr-namespace:HBLConsole.View"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:pry="clr-namespace:HBLConsole.PryUserControl;assembly=HBLConsole.PryUserControl"
  10. xmlns:vm="clr-namespace:HBLConsole.ViewModel"
  11. d:DesignHeight="450"
  12. d:DesignWidth="1000"
  13. mc:Ignorable="d">
  14. <UserControl.DataContext>
  15. <vm:AlarmViewModel />
  16. </UserControl.DataContext>
  17. <UserControl.Resources>
  18. <ResourceDictionary>
  19. <ResourceDictionary.MergedDictionaries>
  20. <ResourceDictionary Source="../Resources/ResourceDictionarys/BasicStyle.xaml" />
  21. <!--<ResourceDictionary Source="../Resources/ResourceDictionarys/DatePickeerDictionary.xaml"/>-->
  22. <ResourceDictionary>
  23. <convert:TextDisplayConvert x:Key="textDisplayConvert" />
  24. <convert:IsEnableConvert x:Key="isEnableConvert" />
  25. <convert:AnalogAlarmConvert x:Key="analogAlarmConvert" />
  26. <convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" />
  27. <convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />
  28. <SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
  29. <SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
  30. <SolidColorBrush x:Key="TitleFontColor" Color="#ddd" />
  31. <SolidColorBrush x:Key="CursorColor" Color="Aqua" />
  32. <SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
  33. <Style x:Key="TextBlockStyle" TargetType="TextBlock">
  34. <Setter Property="FontFamily" Value="楷体" />
  35. <Setter Property="FontSize" Value="18" />
  36. <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
  37. <Setter Property="VerticalAlignment" Value="Center" />
  38. <Setter Property="HorizontalAlignment" Value="Center" />
  39. </Style>
  40. <Style x:Key="TextBoxStyle" TargetType="TextBox">
  41. <Setter Property="FontFamily" Value="楷体" />
  42. <Setter Property="FontSize" Value="22" />
  43. <Setter Property="Background" Value="Transparent" />
  44. <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
  45. <Setter Property="BorderBrush" Value="#FF23CACA" />
  46. <Setter Property="CaretBrush" Value="Aqua" />
  47. <Setter Property="VerticalAlignment" Value="Center" />
  48. </Style>
  49. <ControlTemplate x:Key="ButTemplate" TargetType="Button">
  50. <Border
  51. x:Name="br"
  52. Background="Transparent"
  53. BorderBrush="#FF19B7EC"
  54. BorderThickness="2">
  55. <StackPanel
  56. HorizontalAlignment="Center"
  57. VerticalAlignment="Center"
  58. Orientation="Horizontal">
  59. <ContentControl
  60. HorizontalAlignment="Center"
  61. VerticalAlignment="Center"
  62. Content="{TemplateBinding Content}"
  63. Foreground="{TemplateBinding Foreground}" />
  64. </StackPanel>
  65. </Border>
  66. <ControlTemplate.Triggers>
  67. <Trigger Property="IsMouseOver" Value="True">
  68. <Setter TargetName="br" Property="Background" Value="#2219B7EC" />
  69. </Trigger>
  70. <Trigger Property="IsPressed" Value="true">
  71. <Setter TargetName="br" Property="Background" Value="#2219B7EC" />
  72. </Trigger>
  73. </ControlTemplate.Triggers>
  74. </ControlTemplate>
  75. </ResourceDictionary>
  76. </ResourceDictionary.MergedDictionaries>
  77. </ResourceDictionary>
  78. </UserControl.Resources>
  79. <Grid Margin="10">
  80. <Grid.RowDefinitions>
  81. <RowDefinition Height="30" />
  82. <RowDefinition Height="30" />
  83. <RowDefinition />
  84. </Grid.RowDefinitions>
  85. <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
  86. <!--<DatePicker
  87. Background="Transparent"
  88. BorderBrush="#aa3aa7f3"
  89. BorderThickness="2"
  90. SelectedDate="{Binding StartDateTime}"
  91. Style="{StaticResource PickerStyle}"
  92. Text="请输入开始时间"
  93. Visibility="{Binding IsVisibilityDatePicker}" />-->
  94. <!--<DatePicker
  95. Margin="20,0,0,0"
  96. Background="Transparent"
  97. BorderBrush="#aa3aa7f3"
  98. BorderThickness="2"
  99. SelectedDate="{Binding EndDateTime}"
  100. Style="{StaticResource PickerStyle}"
  101. Text="请输入结束时间"
  102. Visibility="{Binding IsVisibilityDatePicker}" />-->
  103. <Button
  104. Width="140"
  105. Background="#FF19B7EC"
  106. Command="{Binding SwitchCommand}"
  107. Content="开始查询"
  108. FontFamily="楷体"
  109. FontSize="18"
  110. Template="{StaticResource ButTemplate}">
  111. <Button.Foreground>
  112. <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
  113. <GradientStop Color="#FFBB662A" />
  114. <GradientStop Offset="1" Color="White" />
  115. </LinearGradientBrush>
  116. </Button.Foreground>
  117. </Button>
  118. <Button
  119. Width="140"
  120. Background="#FF19B7EC"
  121. Command="{Binding SwitchCommand}"
  122. Content="{Binding ButContent}"
  123. FontFamily="楷体"
  124. FontSize="18"
  125. Template="{StaticResource ButTemplate}">
  126. <Button.Foreground>
  127. <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
  128. <GradientStop Color="#FFBB662A" />
  129. <GradientStop Offset="1" Color="White" />
  130. </LinearGradientBrush>
  131. </Button.Foreground>
  132. </Button>
  133. </StackPanel>
  134. <!--#region 表格标题栏设置-->
  135. <Grid Grid.Row="1" Background="#dd2AB2E7">
  136. <Grid.ColumnDefinitions>
  137. <ColumnDefinition Width="0.3*" />
  138. <ColumnDefinition Width="0.7*" />
  139. <ColumnDefinition Width="0.7*" />
  140. <ColumnDefinition />
  141. <ColumnDefinition Width="0.7*" />
  142. <ColumnDefinition Width="0.5*" />
  143. </Grid.ColumnDefinitions>
  144. <TextBlock
  145. Grid.Column="0"
  146. HorizontalAlignment="Center"
  147. VerticalAlignment="Center"
  148. FontSize="16"
  149. Foreground="{StaticResource TitleFontColor}"
  150. Text="ID" />
  151. <Grid Grid.Column="1">
  152. <TextBlock
  153. HorizontalAlignment="Center"
  154. VerticalAlignment="Center"
  155. FontSize="16"
  156. Foreground="{StaticResource TitleFontColor}"
  157. Text="报警日期" />
  158. <Border
  159. BorderBrush="{StaticResource TitleBorderColor}"
  160. BorderThickness="1,0,1,0"
  161. Cursor="SizeWE" />
  162. </Grid>
  163. <TextBlock
  164. Grid.Column="2"
  165. HorizontalAlignment="Center"
  166. VerticalAlignment="Center"
  167. FontSize="16"
  168. Foreground="{StaticResource TitleFontColor}"
  169. Text="报警时间" />
  170. <Grid Grid.Column="3">
  171. <TextBlock
  172. HorizontalAlignment="Center"
  173. VerticalAlignment="Center"
  174. FontSize="16"
  175. Foreground="{StaticResource TitleFontColor}"
  176. Text="报警信息" />
  177. <Border
  178. BorderBrush="{StaticResource TitleBorderColor}"
  179. BorderThickness="1,0,1,0"
  180. Cursor="SizeWE" />
  181. </Grid>
  182. <TextBlock
  183. Grid.Column="4"
  184. HorizontalAlignment="Center"
  185. VerticalAlignment="Center"
  186. FontSize="16"
  187. Foreground="{StaticResource TitleFontColor}"
  188. Text="报警值" />
  189. <Grid Grid.Column="5">
  190. <TextBlock
  191. HorizontalAlignment="Center"
  192. VerticalAlignment="Center"
  193. FontSize="16"
  194. Foreground="{StaticResource TitleFontColor}"
  195. Text="报警等级" />
  196. <Border
  197. BorderBrush="{StaticResource TitleBorderColor}"
  198. BorderThickness="1,0,1,0"
  199. Cursor="SizeWE" />
  200. </Grid>
  201. </Grid>
  202. <!--#endregion-->
  203. <!--#region 表格数据显示-->
  204. <ScrollViewer
  205. Grid.Row="2"
  206. HorizontalScrollBarVisibility="Hidden"
  207. VerticalScrollBarVisibility="Hidden">
  208. <ItemsControl ItemsSource="{Binding varialeInfos}">
  209. <ItemsControl.ItemTemplate>
  210. <DataTemplate>
  211. <Grid x:Name="gr">
  212. <Grid.ColumnDefinitions>
  213. <!--<ColumnDefinition Width="40" />
  214. <ColumnDefinition />
  215. <ColumnDefinition />
  216. <ColumnDefinition Width="100" />
  217. <ColumnDefinition Width="0" />
  218. <ColumnDefinition Width="120" />
  219. <ColumnDefinition Width="100" />-->
  220. <ColumnDefinition Width="0.3*" />
  221. <ColumnDefinition />
  222. <ColumnDefinition />
  223. <ColumnDefinition Width="0.7*" />
  224. <ColumnDefinition Width="0" />
  225. <ColumnDefinition Width="0.7*" />
  226. <ColumnDefinition Width="0.5*" />
  227. </Grid.ColumnDefinitions>
  228. <TextBlock
  229. Grid.Column="0"
  230. HorizontalAlignment="Center"
  231. VerticalAlignment="Center"
  232. Background="Transparent"
  233. FontSize="14"
  234. Foreground="{StaticResource FontColor}"
  235. Text="{Binding ID}" />
  236. <Grid Grid.Column="1">
  237. <TextBox
  238. Background="Transparent"
  239. CaretBrush="{StaticResource CursorColor}"
  240. Foreground="{StaticResource FontColor}"
  241. Style="{StaticResource InputTextboxStyle}"
  242. TabIndex="{Binding ID}"
  243. Text="{Binding VarName}" />
  244. <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
  245. </Grid>
  246. <TextBox
  247. Grid.Column="2"
  248. Background="Transparent"
  249. CaretBrush="{StaticResource CursorColor}"
  250. Foreground="{StaticResource FontColor}"
  251. Style="{StaticResource InputTextboxStyle}"
  252. TabIndex="{Binding ID}"
  253. Text="{Binding Address}" />
  254. <Grid Grid.Column="3">
  255. <ComboBox
  256. VerticalAlignment="Center"
  257. BorderBrush="Transparent"
  258. BorderThickness="1"
  259. FontFamily="楷体"
  260. FontSize="20"
  261. Foreground="{StaticResource FontColor}"
  262. IsEditable="False"
  263. ItemsSource="{Binding dataType}"
  264. SelectedValue="{Binding DataType}"
  265. Style="{StaticResource ComboBoxStyle}"
  266. Text="{Binding DataType}" />
  267. <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
  268. </Grid>
  269. <Grid Grid.Column="5">
  270. <CheckBox
  271. HorizontalAlignment="Center"
  272. VerticalAlignment="Center"
  273. Background="#ff23CACA"
  274. Content="{Binding IsEnableAlarm, Converter={StaticResource textDisplayConvert}}"
  275. FontSize="16"
  276. Foreground="{StaticResource FontColor}"
  277. IsChecked="{Binding IsEnableAlarm}"
  278. Template="{StaticResource CbTemplate}" />
  279. <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="0,0,1,0" />
  280. </Grid>
  281. <Grid Grid.Column="6">
  282. <Grid>
  283. <ToggleButton
  284. Name="tb"
  285. Width="{Binding RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=1}, Path=ActualWidth}"
  286. Height="{Binding RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=1}, Path=ActualHeight}"
  287. Background="Transparent"
  288. BorderThickness="0"
  289. Content="编辑"
  290. FontSize="14"
  291. IsChecked="{Binding IsOpen}"
  292. IsEnabled="{Binding IsEnableAlarm}"
  293. Style="{StaticResource EditToggleButtonStyle}" />
  294. </Grid>
  295. <!-- 当 StaysOpen 设置为 True 时 popup失去焦点的时候不会自动关闭 -->
  296. <Popup
  297. AllowsTransparency="True"
  298. Focusable="False"
  299. IsOpen="{Binding IsOpen}"
  300. Placement="Left"
  301. PlacementTarget="{Binding ElementName=tb}"
  302. StaysOpen="False">
  303. <Border Background="#081424" ClipToBounds="True">
  304. <Grid Margin="0">
  305. <Grid.Background>
  306. <ImageBrush ImageSource="../Resources/Images/边框1.png" />
  307. </Grid.Background>
  308. <Grid.RowDefinitions>
  309. <RowDefinition />
  310. <RowDefinition />
  311. <RowDefinition />
  312. </Grid.RowDefinitions>
  313. <!--#region 离散量报警设置-->
  314. <StackPanel
  315. Grid.Row="0"
  316. Margin="10"
  317. Orientation="Vertical"
  318. Visibility="{Binding DataType, Converter={StaticResource discreteAlarmConvert}}">
  319. <Grid Margin="5">
  320. <pry:TitleTextBlock />
  321. <TextBlock
  322. Margin="10,5,30,5"
  323. Background="Transparent"
  324. FontSize="16"
  325. Foreground="#dd01FFFF"
  326. Text="离散量报警设置" />
  327. </Grid>
  328. <Grid>
  329. <Grid.ColumnDefinitions>
  330. <ColumnDefinition />
  331. <ColumnDefinition />
  332. </Grid.ColumnDefinitions>
  333. <TextBlock
  334. Margin="5"
  335. Style="{StaticResource TextBlockStyle}"
  336. Text="选择触发条件:" />
  337. <ComboBox
  338. Grid.Column="1"
  339. Width="180"
  340. Margin="5"
  341. VerticalAlignment="Center"
  342. BorderBrush="#FF23CACA"
  343. BorderThickness="1"
  344. FontFamily="楷体"
  345. FontSize="20"
  346. Foreground="#ff23caca"
  347. IsEditable="False"
  348. ItemsSource="{Binding PopupDiscreteAlarmType}"
  349. SelectedIndex="1"
  350. Style="{StaticResource ComboBoxStyle}"
  351. Text="{Binding AlarmSetProp.DiscreteAlarmInfoSet.TrigAlarm}" />
  352. </Grid>
  353. <Grid>
  354. <Grid.ColumnDefinitions>
  355. <ColumnDefinition />
  356. <ColumnDefinition />
  357. <ColumnDefinition />
  358. </Grid.ColumnDefinitions>
  359. <TextBlock
  360. Grid.Column="0"
  361. Margin="5"
  362. Style="{StaticResource TextBlockStyle}"
  363. Text="输入报警信息:" />
  364. <TextBox
  365. Grid.Column="1"
  366. Grid.ColumnSpan="2"
  367. Margin="5"
  368. Style="{StaticResource TextBoxStyle}"
  369. Text="{Binding AlarmSetProp.DiscreteAlarmInfoSet.AlarmInfo}" />
  370. </Grid>
  371. </StackPanel>
  372. <!--#endregion-->
  373. <!--#region 模拟量报警设置-->
  374. <StackPanel
  375. Grid.Row="1"
  376. Margin="10"
  377. Visibility="{Binding DataType, Converter={StaticResource analogAlarmConvert}}">
  378. <Grid Margin="5">
  379. <pry:TitleTextBlock />
  380. <TextBlock
  381. Margin="10,5,30,5"
  382. Background="Transparent"
  383. FontSize="16"
  384. Foreground="#dd01FFFF"
  385. Text="模拟量报警设置" />
  386. </Grid>
  387. <ItemsControl ItemsSource="{Binding AlarmSetProp.AnalogAlarmModels}">
  388. <ItemsControl.ItemTemplate>
  389. <DataTemplate>
  390. <Grid>
  391. <Grid.ColumnDefinitions>
  392. <ColumnDefinition />
  393. <ColumnDefinition />
  394. <ColumnDefinition />
  395. </Grid.ColumnDefinitions>
  396. <Grid.RowDefinitions>
  397. <RowDefinition />
  398. <RowDefinition />
  399. </Grid.RowDefinitions>
  400. <CheckBox
  401. Margin="5,5,0,0"
  402. HorizontalAlignment="Left"
  403. VerticalAlignment="Center"
  404. Background="#ff23CACA"
  405. Content="{Binding AlarmTag}"
  406. FontSize="14"
  407. Foreground="#ff23CACA"
  408. IsChecked="{Binding IsEnable}"
  409. Template="{StaticResource CbTemplate}" />
  410. <TextBlock
  411. Grid.Column="1"
  412. Margin="0,5,5,0"
  413. Style="{StaticResource TextBlockStyle}"
  414. Text="请输入报警值:" />
  415. <TextBox
  416. Grid.Column="2"
  417. Width="100"
  418. Margin="0,5,5,0"
  419. IsEnabled="{Binding IsEnable}"
  420. Style="{StaticResource TextBoxStyle}"
  421. Text="{Binding AlarmValue}" />
  422. <TextBlock
  423. Grid.Row="1"
  424. Grid.Column="0"
  425. Margin="5"
  426. Style="{StaticResource TextBlockStyle}"
  427. Text="输入报警信息:" />
  428. <TextBox
  429. Grid.Row="1"
  430. Grid.Column="1"
  431. Grid.ColumnSpan="2"
  432. Margin="5"
  433. IsEnabled="{Binding IsEnable}"
  434. Style="{StaticResource TextBoxStyle}"
  435. Text="{Binding AlarmInfo}" />
  436. </Grid>
  437. </DataTemplate>
  438. </ItemsControl.ItemTemplate>
  439. </ItemsControl>
  440. </StackPanel>
  441. <!--#endregion-->
  442. <!--#region 按钮控制-->
  443. <Grid Grid.Row="2" Margin="10">
  444. <Grid.ColumnDefinitions>
  445. <ColumnDefinition />
  446. <ColumnDefinition />
  447. </Grid.ColumnDefinitions>
  448. <Button
  449. Margin="10,5,10,10"
  450. Command="{Binding CancelCommand}"
  451. Content="取消"
  452. FontFamily="楷体"
  453. FontSize="20"
  454. Foreground="#aa01FFFF"
  455. Template="{StaticResource CancelButtonTemp}" />
  456. <Button
  457. Grid.Column="1"
  458. Margin="10,5,10,10"
  459. Command="{Binding ConfirmCommand}"
  460. Content="确认"
  461. FontFamily="楷体"
  462. FontSize="20"
  463. Foreground="#aa01FFFF"
  464. Template="{StaticResource ConfirmButtonTemp}" />
  465. </Grid>
  466. <!--#endregion-->
  467. </Grid>
  468. </Border>
  469. </Popup>
  470. </Grid>
  471. <Border
  472. Grid.ColumnSpan="8"
  473. BorderBrush="{StaticResource BorderSolid}"
  474. BorderThickness="1" />
  475. </Grid>
  476. <DataTemplate.Triggers>
  477. <Trigger Property="IsMouseOver" Value="true">
  478. <Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
  479. </Trigger>
  480. </DataTemplate.Triggers>
  481. </DataTemplate>
  482. </ItemsControl.ItemTemplate>
  483. </ItemsControl>
  484. </ScrollViewer>
  485. <!--#endregion-->
  486. </Grid>
  487. </UserControl>