CoolWaterView.xaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <UserControl
  2. x:Class="ShakerControl.View.CoolWaterView"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:hc="https://handyorg.github.io/handycontrol"
  7. xmlns:local="clr-namespace:ShakerControl.View"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:vm="clr-namespace:ShakerControl.ViewModel.MainPage"
  10. d:DataContext="{d:DesignInstance {x:Type vm:MainPageViewModel}}"
  11. d:DesignHeight="450"
  12. d:DesignWidth="800"
  13. DataContext="{Binding Source={StaticResource MainViewModel}, Path=Data.MainPage}"
  14. mc:Ignorable="d">
  15. <Grid IsEnabled="{Binding ShakerControl.AllowCoolingWater}">
  16. <Grid.RowDefinitions>
  17. <RowDefinition Height="1*" />
  18. <RowDefinition Height="1*" />
  19. <RowDefinition Height="1*" />
  20. </Grid.RowDefinitions>
  21. <Grid>
  22. <Grid.RowDefinitions>
  23. <RowDefinition Height="66" />
  24. <RowDefinition />
  25. </Grid.RowDefinitions>
  26. <TextBlock
  27. VerticalAlignment="Center"
  28. FontSize="{StaticResource ContentTitleFontSize}"
  29. FontWeight="Bold"
  30. Foreground="{StaticResource ContentTextBrush}"
  31. Text="显示数据" />
  32. <Line
  33. VerticalAlignment="Bottom"
  34. Stroke="{StaticResource ContentSplitLineBrush}"
  35. StrokeThickness="2"
  36. X1="0"
  37. X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
  38. Y1="0"
  39. Y2="0" />
  40. <ListView
  41. Grid.Row="1"
  42. VerticalAlignment="Center"
  43. Background="Transparent"
  44. FontSize="{StaticResource TextFontSize}"
  45. Foreground="{StaticResource ContentTextBrush}"
  46. ItemsSource="{Binding ShakerControl.CoolingWaters}">
  47. <ListView.Style>
  48. <Style TargetType="ListView">
  49. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  50. <Setter Property="Padding" Value="0" />
  51. <Setter Property="Template">
  52. <Setter.Value>
  53. <ControlTemplate TargetType="{x:Type ListView}">
  54. <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  55. </ControlTemplate>
  56. </Setter.Value>
  57. </Setter>
  58. <Setter Property="ItemTemplate">
  59. <Setter.Value>
  60. <DataTemplate>
  61. <Grid>
  62. <Grid.ColumnDefinitions>
  63. <ColumnDefinition Width="120" />
  64. <ColumnDefinition />
  65. </Grid.ColumnDefinitions>
  66. <TextBlock
  67. HorizontalAlignment="Right"
  68. VerticalAlignment="Center"
  69. Text="{Binding Name, Mode=OneWay, StringFormat={}{0}:}"
  70. TextWrapping="Wrap" />
  71. <TextBlock
  72. Grid.Column="1"
  73. Margin="10,0,0,0"
  74. HorizontalAlignment="Left"
  75. VerticalAlignment="Center">
  76. <Run Text="{Binding Value, Mode=OneWay}" />
  77. <Run Text="{Binding Unit, Mode=OneWay}" />
  78. </TextBlock>
  79. </Grid>
  80. </DataTemplate>
  81. </Setter.Value>
  82. </Setter>
  83. <Setter Property="ItemContainerStyle">
  84. <Setter.Value>
  85. <Style TargetType="ListViewItem">
  86. <Setter Property="Height" Value="42" />
  87. <Setter Property="BorderBrush" Value="Transparent" />
  88. <Setter Property="BorderThickness" Value="0" />
  89. <Setter Property="SnapsToDevicePixels" Value="True" />
  90. <Setter Property="OverridesDefaultStyle" Value="True" />
  91. <Setter Property="Cursor" Value="Hand" />
  92. <Setter Property="IsEnabled" Value="False" />
  93. <Setter Property="Padding" Value="0" />
  94. <Setter Property="Template">
  95. <Setter.Value>
  96. <ControlTemplate TargetType="ListViewItem">
  97. <ContentPresenter
  98. Content="{TemplateBinding Content}"
  99. ContentStringFormat="{TemplateBinding ContentStringFormat}"
  100. ContentTemplate="{TemplateBinding ContentTemplate}"
  101. ContentTemplateSelector="{x:Null}" />
  102. </ControlTemplate>
  103. </Setter.Value>
  104. </Setter>
  105. </Style>
  106. </Setter.Value>
  107. </Setter>
  108. <Setter Property="ItemsPanel">
  109. <Setter.Value>
  110. <ItemsPanelTemplate>
  111. <UniformGrid
  112. Margin="0"
  113. Columns="3"
  114. Style="{x:Null}" />
  115. </ItemsPanelTemplate>
  116. </Setter.Value>
  117. </Setter>
  118. </Style>
  119. </ListView.Style>
  120. </ListView>
  121. </Grid>
  122. <Grid Grid.Row="1" IsEnabled="{Binding ShakerControl.IsConnected}">
  123. <Grid.RowDefinitions>
  124. <RowDefinition Height="66" />
  125. <RowDefinition />
  126. </Grid.RowDefinitions>
  127. <TextBlock
  128. VerticalAlignment="Center"
  129. FontSize="{StaticResource ContentTitleFontSize}"
  130. FontWeight="Bold"
  131. Foreground="{StaticResource ContentTextBrush}"
  132. Text="冷却水状态" />
  133. <Line
  134. VerticalAlignment="Bottom"
  135. Stroke="{StaticResource ContentSplitLineBrush}"
  136. StrokeThickness="2"
  137. X1="0"
  138. X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
  139. Y1="0"
  140. Y2="0" />
  141. <ListView
  142. Grid.Row="1"
  143. VerticalAlignment="Top"
  144. Background="Transparent"
  145. FontSize="{StaticResource TextFontSize}"
  146. Foreground="{StaticResource ContentTextBrush}"
  147. ItemsSource="{Binding ShakerControl.CoolingWaterGroup.Items}">
  148. <ListView.Style>
  149. <Style TargetType="ListView">
  150. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  151. <Setter Property="Padding" Value="0" />
  152. <Setter Property="Template">
  153. <Setter.Value>
  154. <ControlTemplate TargetType="{x:Type ListView}">
  155. <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  156. </ControlTemplate>
  157. </Setter.Value>
  158. </Setter>
  159. <Setter Property="ItemTemplate">
  160. <Setter.Value>
  161. <DataTemplate>
  162. <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
  163. <Grid.ColumnDefinitions>
  164. <ColumnDefinition Width="140" />
  165. <ColumnDefinition />
  166. </Grid.ColumnDefinitions>
  167. <TextBlock
  168. Grid.Column="0"
  169. VerticalAlignment="Center"
  170. FontSize="{StaticResource TextFontSize}"
  171. Foreground="{StaticResource ContentTextBrush}"
  172. Text="{Binding Name}"
  173. TextWrapping="Wrap" />
  174. <Ellipse
  175. Grid.Column="1"
  176. Width="36"
  177. Height="36"
  178. HorizontalAlignment="Left"
  179. VerticalAlignment="Center">
  180. <Ellipse.Style>
  181. <Style TargetType="Ellipse">
  182. <Style.Triggers>
  183. <DataTrigger Binding="{Binding Value}" Value="True">
  184. <Setter Property="Fill" Value="Red" />
  185. </DataTrigger>
  186. <DataTrigger Binding="{Binding Value}" Value="False">
  187. <Setter Property="Fill" Value="Green" />
  188. </DataTrigger>
  189. <DataTrigger Binding="{Binding Source={StaticResource MainViewModel}, Path=Data.MainPage.ShakerControl.IsConnected}" Value="False">
  190. <Setter Property="Fill" Value="Gray" />
  191. </DataTrigger>
  192. </Style.Triggers>
  193. </Style>
  194. </Ellipse.Style>
  195. </Ellipse>
  196. </Grid>
  197. </DataTemplate>
  198. </Setter.Value>
  199. </Setter>
  200. <Setter Property="ItemContainerStyle">
  201. <Setter.Value>
  202. <Style TargetType="ListViewItem">
  203. <Setter Property="Height" Value="42" />
  204. <Setter Property="BorderBrush" Value="Transparent" />
  205. <Setter Property="BorderThickness" Value="0" />
  206. <Setter Property="SnapsToDevicePixels" Value="True" />
  207. <Setter Property="OverridesDefaultStyle" Value="True" />
  208. <Setter Property="Cursor" Value="Hand" />
  209. <Setter Property="IsEnabled" Value="False" />
  210. <Setter Property="Padding" Value="0" />
  211. <Setter Property="Template">
  212. <Setter.Value>
  213. <ControlTemplate TargetType="ListViewItem">
  214. <ContentPresenter
  215. Content="{TemplateBinding Content}"
  216. ContentStringFormat="{TemplateBinding ContentStringFormat}"
  217. ContentTemplate="{TemplateBinding ContentTemplate}"
  218. ContentTemplateSelector="{x:Null}" />
  219. </ControlTemplate>
  220. </Setter.Value>
  221. </Setter>
  222. </Style>
  223. </Setter.Value>
  224. </Setter>
  225. <Setter Property="ItemsPanel">
  226. <Setter.Value>
  227. <ItemsPanelTemplate>
  228. <UniformGrid
  229. Margin="0"
  230. Columns="4"
  231. Style="{x:Null}" />
  232. </ItemsPanelTemplate>
  233. </Setter.Value>
  234. </Setter>
  235. </Style>
  236. </ListView.Style>
  237. </ListView>
  238. </Grid>
  239. <Grid Grid.Row="2" IsEnabled="{Binding ShakerControl.IsConnected}">
  240. <Grid.RowDefinitions>
  241. <RowDefinition Height="66" />
  242. <RowDefinition />
  243. </Grid.RowDefinitions>
  244. <TextBlock
  245. VerticalAlignment="Center"
  246. FontSize="{StaticResource ContentTitleFontSize}"
  247. FontWeight="Bold"
  248. Foreground="{StaticResource ContentTextBrush}"
  249. Text="冷却水控制" />
  250. <Line
  251. VerticalAlignment="Bottom"
  252. Stroke="{StaticResource ContentSplitLineBrush}"
  253. StrokeThickness="2"
  254. X1="0"
  255. X2="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
  256. Y1="0"
  257. Y2="0" />
  258. <UniformGrid
  259. Grid.Row="1"
  260. VerticalAlignment="Center"
  261. Columns="3">
  262. <StackPanel>
  263. <TextBlock
  264. HorizontalAlignment="Center"
  265. VerticalAlignment="Center"
  266. FontSize="{StaticResource TextFontSize}"
  267. Foreground="{StaticResource ContentTextBrush}"
  268. Text="启动" />
  269. <Button
  270. Width="{StaticResource PowerAmplifierButtonSize}"
  271. Height="{StaticResource PowerAmplifierButtonSize}"
  272. Margin="0,10,0,0"
  273. Padding="0"
  274. hc:IconElement.Geometry="{StaticResource PowerAmplifierStart}"
  275. Command="{Binding ShakerControl.CoolingWater.StartCommand}"
  276. Cursor="Hand"
  277. IsEnabled="{Binding ShakerControl.CoolingWaterStartEnabled}"
  278. Style="{StaticResource PowerAmplifierButtonStyle}"
  279. ToolTip="启动" />
  280. </StackPanel>
  281. <StackPanel>
  282. <TextBlock
  283. HorizontalAlignment="Center"
  284. VerticalAlignment="Center"
  285. FontSize="{StaticResource TextFontSize}"
  286. Foreground="{StaticResource ContentTextBrush}"
  287. Text="停止" />
  288. <Button
  289. Width="{StaticResource PowerAmplifierButtonSize}"
  290. Height="{StaticResource PowerAmplifierButtonSize}"
  291. Margin="0,10,0,0"
  292. Padding="0"
  293. hc:IconElement.Geometry="{StaticResource PowerAmplifierStop}"
  294. Command="{Binding ShakerControl.CoolingWater.StopCommand}"
  295. Cursor="Hand"
  296. IsEnabled="{Binding ShakerControl.CoolingWaterStopEnabled}"
  297. Style="{StaticResource PowerAmplifierButtonStyle}"
  298. ToolTip="停止" />
  299. </StackPanel>
  300. <StackPanel>
  301. <TextBlock
  302. HorizontalAlignment="Center"
  303. VerticalAlignment="Center"
  304. FontSize="{StaticResource TextFontSize}"
  305. Foreground="{StaticResource ContentTextBrush}"
  306. Text="报警复位" />
  307. <Button
  308. Width="{StaticResource PowerAmplifierButtonSize}"
  309. Height="{StaticResource PowerAmplifierButtonSize}"
  310. Margin="0,10,0,0"
  311. Padding="0"
  312. hc:IconElement.Geometry="{StaticResource PowerAmplifierReset}"
  313. Command="{Binding ShakerControl.CoolingWater.ResetCommand}"
  314. Cursor="Hand"
  315. IsEnabled="{Binding ShakerControl.CoolingWaterResetEnabled}"
  316. Style="{StaticResource PowerAmplifierButtonStyle}"
  317. ToolTip="报警复位" />
  318. </StackPanel>
  319. </UniformGrid>
  320. </Grid>
  321. </Grid>
  322. </UserControl>