ShakerView.xaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <UserControl
  2. x:Class="ShakerManger.View.ShakerView"
  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:ShakerManger.View"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:oxy="http://oxyplot.org/wpf"
  10. xmlns:oxyplot="http://oxyplot.org/skiawpf"
  11. xmlns:system="clr-namespace:System;assembly=mscorlib"
  12. xmlns:vm="clr-namespace:ShakerManger.ViewModel"
  13. d:DataContext="{d:DesignInstance {x:Type vm:ShakerControlViewModel}}"
  14. d:DesignHeight="450"
  15. d:DesignWidth="800"
  16. mc:Ignorable="d">
  17. <UserControl.Resources>
  18. <SolidColorBrush x:Key="forecolor" Color="White" />
  19. </UserControl.Resources>
  20. <Border
  21. BorderBrush="Gray"
  22. BorderThickness="1"
  23. CornerRadius="6,6,0,0">
  24. <Grid>
  25. <Grid.RowDefinitions>
  26. <RowDefinition Height="32" />
  27. <RowDefinition Height="*" />
  28. </Grid.RowDefinitions>
  29. <Border
  30. Grid.Row="0"
  31. Margin="-1"
  32. Background="BlueViolet"
  33. CornerRadius="6,6,0,0">
  34. <Grid>
  35. <Grid.Resources>
  36. <system:Double x:Key="buttonwidth">32</system:Double>
  37. <system:Double x:Key="buttonheight">32</system:Double>
  38. </Grid.Resources>
  39. <Grid.ColumnDefinitions>
  40. <ColumnDefinition Width="auto" />
  41. <ColumnDefinition Width="*" />
  42. <ColumnDefinition Width="auto" />
  43. <ColumnDefinition Width="auto" />
  44. <ColumnDefinition Width="auto" />
  45. <ColumnDefinition Width="auto" />
  46. <ColumnDefinition Width="auto" />
  47. <ColumnDefinition Width="auto" />
  48. </Grid.ColumnDefinitions>
  49. <StackPanel Grid.Row="0" Orientation="Horizontal">
  50. <Viewbox Height="18" Margin="4,0,0,0">
  51. <Path>
  52. <Path.Style>
  53. <Style TargetType="Path">
  54. <Style.Triggers>
  55. <DataTrigger Binding="{Binding Path=IsOnline}" Value="True">
  56. <Setter Property="Data" Value="{StaticResource OnlineGeometry}" />
  57. <Setter Property="Fill" Value="Green" />
  58. <Setter Property="ToolTip" Value="控制终端在线" />
  59. </DataTrigger>
  60. <DataTrigger Binding="{Binding Path=IsOnline}" Value="False">
  61. <Setter Property="Data" Value="{StaticResource OfflineGeometry}" />
  62. <Setter Property="Fill" Value="Red" />
  63. <Setter Property="ToolTip" Value="控制终端已离线" />
  64. </DataTrigger>
  65. </Style.Triggers>
  66. </Style>
  67. </Path.Style>
  68. </Path>
  69. </Viewbox>
  70. <Viewbox
  71. Height="18"
  72. Margin="4,0,0,0"
  73. Visibility="{Binding IsOnline, Converter={StaticResource Boolean2VisibilityConverter}}">
  74. <Path Fill="White">
  75. <Path.Style>
  76. <Style TargetType="Path">
  77. <Style.Triggers>
  78. <DataTrigger Binding="{Binding Path=IsRemoteControl}" Value="True">
  79. <Setter Property="Data" Value="{StaticResource RemoteControl}" />
  80. <Setter Property="ToolTip" Value="远程控制" />
  81. </DataTrigger>
  82. <DataTrigger Binding="{Binding Path=IsRemoteControl}" Value="False">
  83. <Setter Property="Data" Value="{StaticResource LocalControl}" />
  84. <Setter Property="ToolTip" Value="本地控制" />
  85. </DataTrigger>
  86. </Style.Triggers>
  87. </Style>
  88. </Path.Style>
  89. </Path>
  90. </Viewbox>
  91. <TextBlock
  92. Margin="4,0,0,0"
  93. HorizontalAlignment="Center"
  94. VerticalAlignment="Center"
  95. FontSize="16"
  96. Foreground="White"
  97. Text="{Binding Title}" />
  98. </StackPanel>
  99. <TextBlock
  100. Grid.Column="1"
  101. Margin="10,0,0,6"
  102. VerticalAlignment="Bottom"
  103. FontSize="12"
  104. Foreground="White"
  105. Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
  106. <Run Text="{Binding CurrentData.Gain, Mode=OneWay, StringFormat=输出功率:{0}%}" />
  107. <Run Text="{Binding CurrentData.OutputCurrent, Mode=OneWay, StringFormat=输出电流:{0}A}" />
  108. <Run Text="{Binding CurrentData.OutputVoltage, Mode=OneWay, StringFormat=输出电压:{0}V}" />
  109. <Run Text="{Binding CurrentData.ExcitationCurrent, Mode=OneWay, StringFormat=励磁电流:{0}A}" />
  110. <Run Text="{Binding CurrentData.ExcitationCurrent, Mode=OneWay, StringFormat=励磁电压:{0}V}" />
  111. <Run Text="{Binding CurrentData.OperatingStatus, Converter={StaticResource EnumToDescription}, Mode=OneWay, StringFormat=运行状态:{0}}" />
  112. </TextBlock>
  113. <Button
  114. Grid.Column="2"
  115. Width="{StaticResource buttonwidth}"
  116. hc:IconElement.Geometry="{StaticResource RequestPermissions}"
  117. hc:IconElement.Width="{StaticResource buttonwidth}"
  118. Command="{Binding RequestPermissionsCommand}"
  119. Cursor="Hand"
  120. RenderTransformOrigin="0.5,0.5"
  121. ToolTip="申请控制权限"
  122. Visibility="{Binding IsRemoteControl, Converter={StaticResource Boolean2VisibilityReConverter}}">
  123. <Button.Style>
  124. <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
  125. <Setter Property="IsEnabled">
  126. <Setter.Value>
  127. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  128. <Binding Path="IsOnline" />
  129. <Binding
  130. Converter="{StaticResource Boolean2BooleanReConverter}"
  131. Path="Data.Login.IsAnonymous"
  132. Source="{StaticResource MainViewModel}" />
  133. </MultiBinding>
  134. </Setter.Value>
  135. </Setter>
  136. </Style>
  137. </Button.Style>
  138. </Button>
  139. <Button
  140. Grid.Column="3"
  141. Width="{StaticResource buttonwidth}"
  142. Margin="20,0,0,0"
  143. hc:IconElement.Geometry="M672 192v64h-512A96 96 0 0 0 64 352v129.6c0 52.992 43.008 96 96.32 96l511.552-1.728 0.256 64-512.128 1.728a160 160 0 0 1-160-160V352A160 160 0 0 1 160 192h512zM640 448V384h480A160 160 0 0 1 1280 544v128a160 160 0 0 1-160 160H640v-64h480a96 96 0 0 0 96-96v-128A96 96 0 0 0 1120 448H640z m128-448h64v192h-64V0zM448 832h64v192H448v-192z m-160-77.248l45.248 45.248L160 973.248l-45.248-45.248L288 754.752z m768-704l45.248 45.248L928 269.248l-45.248-45.248L1056 50.752z"
  144. hc:IconElement.Width="{StaticResource buttonwidth}"
  145. Command="{Binding DisConnectCommand}"
  146. Cursor="Hand"
  147. RenderTransformOrigin="0.5,0.5"
  148. ToolTip="断开连接"
  149. Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
  150. <Button.Style>
  151. <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
  152. <Setter Property="IsEnabled">
  153. <Setter.Value>
  154. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  155. <Binding Path="IsRemoteControl" />
  156. <Binding
  157. Converter="{StaticResource Boolean2BooleanReConverter}"
  158. Path="Data.Login.IsAnonymous"
  159. Source="{StaticResource MainViewModel}" />
  160. </MultiBinding>
  161. </Setter.Value>
  162. </Setter>
  163. </Style>
  164. </Button.Style>
  165. </Button>
  166. <Button
  167. Grid.Column="4"
  168. Width="{StaticResource buttonwidth}"
  169. Margin="20,0,0,0"
  170. hc:IconElement.Geometry="m0,93.09092a93.09091,93.09091 0 0 1 93.09091,-93.09091l744.72728,0a93.09091,93.09091 0 0 1 93.0909,93.09091l0,558.54546a93.09091,93.09091 0 0 1 -93.0909,93.09091l-744.72728,0a93.09091,93.09091 0 0 1 -93.09091,-93.09091l0,-558.54546zm46.54546,302.54546l0,256q0,19.26982 13.63782,32.90763t32.90763,13.63782l744.72728,0q19.26981,0 32.90763,-13.63782t13.63782,-32.90763l0,-256l-115.29309,0l-102.86546,114.31563l-80.384,-223.18545l-59.67127,99.51418l-154.06545,171.19418l-76.38109,-233.33236l-76.33455,190.74327l-80.43054,-119.24945l-92.39273,0zm0,-46.54546l117.10836,0l45.14909,66.93237l91.27564,-228.16582l91.22909,278.66763l97.28,-108.07854l107.79927,-179.75855l87.22619,242.26909l64.69818,-71.86618l136.05236,0l0,-256q0,-19.26982 -13.63782,-32.90763t-32.90763,-13.63782l-744.72728,0q-19.26981,0 -32.90763,13.63782t-13.63782,32.90763l0,256z"
  171. hc:IconElement.Width="{StaticResource buttonwidth}"
  172. Cursor="Hand"
  173. Style="{StaticResource ImageButton}"
  174. Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
  175. <hc:Interaction.Triggers>
  176. <hc:EventTrigger EventName="Click">
  177. <hc:SetPropertyAction
  178. PropertyName="SetPlotConfigIsOpen"
  179. PropertyValue="True"
  180. TargetObject="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  181. </hc:EventTrigger>
  182. </hc:Interaction.Triggers>
  183. </Button>
  184. <Button
  185. x:Name="shakerselct"
  186. Grid.Column="5"
  187. Width="{StaticResource buttonwidth}"
  188. Margin="20,0,0,0"
  189. hc:IconElement.Geometry="m840.336,401.168c-12.736,-12.736 -33.408,-12.736 -46.144,0l-346.176,346.176l-346.176,-346.176c-12.736,-12.736 -33.408,-12.736 -46.144,0l-46.144,46.144c-12.736,12.736 -12.736,33.408 0,46.144l415.36,415.36c12.736,12.736 33.408,12.736 46.144,0l415.36,-415.36c12.736,-12.736 12.736,-33.408 0,-46.144l-46.08,-46.144zm-415.424,116.096c12.736,12.736 33.408,12.736 46.144,0l415.36,-415.36c12.736,-12.736 12.736,-33.408 0,-46.144l-46.08,-46.208c-12.736,-12.736 -33.408,-12.736 -46.144,0l-346.176,346.176l-346.176,-346.176c-12.736,-12.736 -33.408,-12.736 -46.144,0l-46.144,46.144c-12.736,12.736 -12.736,33.408 0,46.144l415.36,415.424z"
  190. hc:IconElement.Width="{StaticResource buttonwidth}"
  191. Cursor="Hand"
  192. RenderTransformOrigin="0.5,0.5"
  193. Style="{StaticResource ImageButton}">
  194. <hc:Interaction.Triggers>
  195. <hc:EventTrigger EventName="Click">
  196. <hc:ExInvokeCommandAction Command="{Binding Source={StaticResource MainViewModel}, Path=Data.Shakers.SelectShakerCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  197. </hc:EventTrigger>
  198. </hc:Interaction.Triggers>
  199. </Button>
  200. <Button
  201. x:Name="control"
  202. Grid.Column="6"
  203. Width="{StaticResource buttonwidth}"
  204. Margin="20,0,0,0"
  205. hc:IconElement.Geometry="m512,469.33333l0,-42.66666l170.66667,0l0,42.66666l85.33333,0l0,42.66667l-85.33333,0l0,42.66667l-170.66667,0l0,-42.66667l-512,0l0,-42.66667l512,0zm-213.33333,-213.33333l0,-42.66667l170.66666,0l0,42.66667l298.66667,0l0,42.66667l-298.66667,0l0,42.66666l-170.66666,0l0,-42.66666l-298.66667,0l0,-42.66667l298.66667,0zm-213.33334,-213.33333l0,-42.66667l170.66667,0l0,42.66667l512,0l0,42.66666l-512,0l0,42.66667l-170.66667,0l0,-42.66667l-85.33333,0l0,-42.66666l85.33333,0zm128,0l-85.33333,0l0,42.66666l85.33333,0l0,-42.66666zm213.33334,213.33333l-85.33334,0l0,42.66667l85.33334,0l0,-42.66667zm213.33333,213.33333l-85.33333,0l0,42.66667l85.33333,0l0,-42.66667z"
  206. hc:IconElement.Width="{StaticResource buttonwidth}"
  207. Cursor="Hand">
  208. <Button.Style>
  209. <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
  210. <Setter Property="IsEnabled">
  211. <Setter.Value>
  212. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  213. <Binding Path="IsConnected" />
  214. <Binding Path="IsRemoteControl" />
  215. <Binding
  216. Converter="{StaticResource Boolean2BooleanReConverter}"
  217. Path="Data.Login.IsAnonymous"
  218. Source="{StaticResource MainViewModel}" />
  219. </MultiBinding>
  220. </Setter.Value>
  221. </Setter>
  222. </Style>
  223. </Button.Style>
  224. <hc:Interaction.Triggers>
  225. <hc:EventTrigger EventName="Click">
  226. <hc:SetPropertyAction
  227. PropertyName="ShakerControlIsOpen"
  228. PropertyValue="{x:Static system:Boolean.TrueString}"
  229. TargetObject="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  230. </hc:EventTrigger>
  231. </hc:Interaction.Triggers>
  232. </Button>
  233. <Popup
  234. AllowsTransparency="True"
  235. IsOpen="{Binding ShakerControlIsOpen}"
  236. Placement="Bottom"
  237. PlacementTarget="{Binding ElementName=control}"
  238. PopupAnimation="Slide"
  239. StaysOpen="False">
  240. <local:ShakerControlView />
  241. </Popup>
  242. <Button
  243. Grid.Column="7"
  244. Width="{StaticResource buttonwidth}"
  245. Margin="20,0,20,0"
  246. hc:IconElement.Width="{StaticResource buttonwidth}"
  247. Cursor="Hand">
  248. <Button.Style>
  249. <Style TargetType="Button" BasedOn="{StaticResource ImageButton}">
  250. <Setter Property="hc:IconElement.Geometry" Value="{StaticResource WindowMaxGeometry}" />
  251. <Setter Property="ToolTip" Value="最大化" />
  252. <Style.Triggers>
  253. <DataTrigger Binding="{Binding Path=IsMax}" Value="True">
  254. <Setter Property="hc:IconElement.Geometry" Value="{StaticResource WindowRestoreGeometry}" />
  255. <Setter Property="ToolTip" Value="还原" />
  256. </DataTrigger>
  257. </Style.Triggers>
  258. </Style>
  259. </Button.Style>
  260. <hc:Interaction.Triggers>
  261. <hc:EventTrigger EventName="Click">
  262. <hc:ExInvokeCommandAction Command="{Binding Source={StaticResource MainViewModel}, Path=Data.Shakers.MaxOrMinCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  263. </hc:EventTrigger>
  264. </hc:Interaction.Triggers>
  265. </Button>
  266. </Grid>
  267. </Border>
  268. <oxyplot:PlotView
  269. Grid.Row="1"
  270. Background="Transparent"
  271. Model="{Binding PlotModel}"
  272. Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
  273. <oxyplot:PlotView.DefaultTrackerTemplate>
  274. <ControlTemplate>
  275. <oxy:TrackerControl
  276. Background="#6F999999"
  277. BorderBrush="Gray"
  278. BorderEdgeMode="Unspecified"
  279. BorderThickness="1"
  280. CornerRadius="6"
  281. LineStroke="White"
  282. Position="{Binding Position}"
  283. ShowPointer="False">
  284. <oxy:TrackerControl.Content>
  285. <TextBlock Margin="6" Text="{Binding}" />
  286. </oxy:TrackerControl.Content>
  287. </oxy:TrackerControl>
  288. </ControlTemplate>
  289. </oxyplot:PlotView.DefaultTrackerTemplate>
  290. </oxyplot:PlotView>
  291. <Grid Grid.Row="1" Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityReConverter}}">
  292. <StackPanel
  293. HorizontalAlignment="Center"
  294. VerticalAlignment="Center"
  295. Orientation="Vertical">
  296. <TextBlock
  297. HorizontalAlignment="Center"
  298. VerticalAlignment="Center"
  299. FontSize="22"
  300. Foreground="Red"
  301. Text="当前控制台未上线" />
  302. <Button
  303. Width="126"
  304. Height="46"
  305. Margin="0,10,0,0"
  306. Command="{Binding ConnectCommand}"
  307. Content="连接功放"
  308. FontSize="14">
  309. <Button.Style>
  310. <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
  311. <Setter Property="IsEnabled">
  312. <Setter.Value>
  313. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  314. <Binding Path="IsOnline" />
  315. <Binding
  316. Converter="{StaticResource Boolean2BooleanReConverter}"
  317. Path="Data.Login.IsAnonymous"
  318. Source="{StaticResource MainViewModel}" />
  319. </MultiBinding>
  320. </Setter.Value>
  321. </Setter>
  322. </Style>
  323. </Button.Style>
  324. </Button>
  325. </StackPanel>
  326. </Grid>
  327. <Popup
  328. AllowsTransparency="True"
  329. IsOpen="{Binding SetPlotConfigIsOpen}"
  330. Placement="Center"
  331. PopupAnimation="Scroll"
  332. StaysOpen="True">
  333. <local:SetPlotConfigView />
  334. </Popup>
  335. </Grid>
  336. </Border>
  337. </UserControl>