ShakerView.xaml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. <Button
  100. Grid.Column="2"
  101. Width="{StaticResource buttonwidth}"
  102. hc:IconElement.Geometry="{StaticResource RequestPermissions}"
  103. hc:IconElement.Width="{StaticResource buttonwidth}"
  104. Command="{Binding RequestPermissionsCommand}"
  105. Cursor="Hand"
  106. RenderTransformOrigin="0.5,0.5"
  107. ToolTip="申请控制权限"
  108. Visibility="{Binding IsRemoteControl, Converter={StaticResource Boolean2VisibilityReConverter}}">
  109. <Button.Style>
  110. <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
  111. <Setter Property="IsEnabled">
  112. <Setter.Value>
  113. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  114. <Binding Path="IsOnline" />
  115. <Binding
  116. Converter="{StaticResource Boolean2BooleanReConverter}"
  117. Path="Data.IsAnonymous"
  118. Source="{StaticResource Login}" />
  119. </MultiBinding>
  120. </Setter.Value>
  121. </Setter>
  122. </Style>
  123. </Button.Style>
  124. </Button>
  125. <Button
  126. Grid.Column="3"
  127. Width="{StaticResource buttonwidth}"
  128. Margin="20,0,0,0"
  129. 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"
  130. hc:IconElement.Width="{StaticResource buttonwidth}"
  131. Command="{Binding DisConnectCommand}"
  132. Cursor="Hand"
  133. RenderTransformOrigin="0.5,0.5"
  134. ToolTip="断开连接"
  135. Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
  136. <Button.Style>
  137. <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
  138. <Setter Property="IsEnabled">
  139. <Setter.Value>
  140. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  141. <Binding Path="IsRemoteControl" />
  142. <Binding
  143. Converter="{StaticResource Boolean2BooleanReConverter}"
  144. Path="Data.IsAnonymous"
  145. Source="{StaticResource Login}" />
  146. </MultiBinding>
  147. </Setter.Value>
  148. </Setter>
  149. </Style>
  150. </Button.Style>
  151. </Button>
  152. <Button
  153. Grid.Column="4"
  154. Width="{StaticResource buttonwidth}"
  155. Margin="20,0,0,0"
  156. 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"
  157. hc:IconElement.Width="{StaticResource buttonwidth}"
  158. Cursor="Hand"
  159. Style="{StaticResource ImageButton}"
  160. Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
  161. <hc:Interaction.Triggers>
  162. <hc:EventTrigger EventName="Click">
  163. <hc:SetPropertyAction
  164. PropertyName="SetPlotConfigIsOpen"
  165. PropertyValue="True"
  166. TargetObject="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  167. </hc:EventTrigger>
  168. </hc:Interaction.Triggers>
  169. </Button>
  170. <Button
  171. x:Name="shakerselct"
  172. Grid.Column="5"
  173. Width="{StaticResource buttonwidth}"
  174. Margin="20,0,0,0"
  175. 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"
  176. hc:IconElement.Width="{StaticResource buttonwidth}"
  177. Cursor="Hand"
  178. RenderTransformOrigin="0.5,0.5"
  179. Style="{StaticResource ImageButton}">
  180. <hc:Interaction.Triggers>
  181. <hc:EventTrigger EventName="Click">
  182. <hc:ExInvokeCommandAction Command="{Binding Source={StaticResource MainViewModel}, Path=Data.Shakers.SelectShakerCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  183. </hc:EventTrigger>
  184. </hc:Interaction.Triggers>
  185. </Button>
  186. <Button
  187. x:Name="control"
  188. Grid.Column="6"
  189. Width="{StaticResource buttonwidth}"
  190. Margin="20,0,0,0"
  191. 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"
  192. hc:IconElement.Width="{StaticResource buttonwidth}"
  193. Cursor="Hand">
  194. <Button.Style>
  195. <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
  196. <Setter Property="IsEnabled">
  197. <Setter.Value>
  198. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  199. <Binding Path="IsConnected" />
  200. <Binding Path="IsRemoteControl" />
  201. <Binding
  202. Converter="{StaticResource Boolean2BooleanReConverter}"
  203. Path="Data.IsAnonymous"
  204. Source="{StaticResource Login}" />
  205. </MultiBinding>
  206. </Setter.Value>
  207. </Setter>
  208. </Style>
  209. </Button.Style>
  210. <hc:Interaction.Triggers>
  211. <hc:EventTrigger EventName="Click">
  212. <hc:SetPropertyAction
  213. PropertyName="ShakerControlIsOpen"
  214. PropertyValue="{x:Static system:Boolean.TrueString}"
  215. TargetObject="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  216. </hc:EventTrigger>
  217. </hc:Interaction.Triggers>
  218. </Button>
  219. <Popup
  220. AllowsTransparency="True"
  221. IsOpen="{Binding ShakerControlIsOpen}"
  222. Placement="Bottom"
  223. PlacementTarget="{Binding ElementName=control}"
  224. PopupAnimation="Slide"
  225. StaysOpen="False">
  226. <local:ShakerControlView />
  227. </Popup>
  228. <Button
  229. Grid.Column="7"
  230. Width="{StaticResource buttonwidth}"
  231. Margin="20,0,20,0"
  232. hc:IconElement.Width="{StaticResource buttonwidth}"
  233. Cursor="Hand">
  234. <Button.Style>
  235. <Style BasedOn="{StaticResource ImageButton}" TargetType="Button">
  236. <Setter Property="hc:IconElement.Geometry" Value="{StaticResource WindowMaxGeometry}" />
  237. <Setter Property="ToolTip" Value="最大化" />
  238. <Style.Triggers>
  239. <DataTrigger Binding="{Binding Path=IsMax}" Value="True">
  240. <Setter Property="hc:IconElement.Geometry" Value="{StaticResource WindowRestoreGeometry}" />
  241. <Setter Property="ToolTip" Value="还原" />
  242. </DataTrigger>
  243. </Style.Triggers>
  244. </Style>
  245. </Button.Style>
  246. <hc:Interaction.Triggers>
  247. <hc:EventTrigger EventName="Click">
  248. <hc:ExInvokeCommandAction Command="{Binding Source={StaticResource MainViewModel}, Path=Data.Shakers.MaxOrMinCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=DataContext}" />
  249. </hc:EventTrigger>
  250. </hc:Interaction.Triggers>
  251. </Button>
  252. </Grid>
  253. </Border>
  254. <local:ShakerInfoView Grid.Row="1" />
  255. <!--<oxyplot:PlotView
  256. Grid.Row="1"
  257. Background="Transparent"
  258. Model="{Binding PlotModel}"
  259. Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityConverter}}">
  260. <oxyplot:PlotView.DefaultTrackerTemplate>
  261. <ControlTemplate>
  262. <oxy:TrackerControl
  263. Background="#6F999999"
  264. BorderBrush="Gray"
  265. BorderEdgeMode="Unspecified"
  266. BorderThickness="1"
  267. CornerRadius="6"
  268. LineStroke="White"
  269. Position="{Binding Position}"
  270. ShowPointer="False">
  271. <oxy:TrackerControl.Content>
  272. <TextBlock Margin="6" Text="{Binding}" />
  273. </oxy:TrackerControl.Content>
  274. </oxy:TrackerControl>
  275. </ControlTemplate>
  276. </oxyplot:PlotView.DefaultTrackerTemplate>
  277. </oxyplot:PlotView>-->
  278. <Grid Grid.Row="1" Visibility="{Binding IsConnected, Converter={StaticResource Boolean2VisibilityReConverter}}">
  279. <StackPanel
  280. HorizontalAlignment="Center"
  281. VerticalAlignment="Center"
  282. Orientation="Vertical">
  283. <TextBlock
  284. HorizontalAlignment="Center"
  285. VerticalAlignment="Center"
  286. FontSize="22"
  287. Foreground="Red"
  288. Text="当前控制台未上线" />
  289. <Button
  290. Width="126"
  291. Height="46"
  292. Margin="0,10,0,0"
  293. Command="{Binding ConnectCommand}"
  294. Content="连接功放"
  295. FontSize="14">
  296. <Button.Style>
  297. <Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
  298. <Setter Property="IsEnabled">
  299. <Setter.Value>
  300. <MultiBinding Converter="{StaticResource MultiBoolConverter}">
  301. <Binding Path="IsOnline" />
  302. <Binding
  303. Converter="{StaticResource Boolean2BooleanReConverter}"
  304. Path="Data.IsAnonymous"
  305. Source="{StaticResource Login}" />
  306. </MultiBinding>
  307. </Setter.Value>
  308. </Setter>
  309. </Style>
  310. </Button.Style>
  311. </Button>
  312. </StackPanel>
  313. </Grid>
  314. <Popup
  315. AllowsTransparency="True"
  316. IsOpen="{Binding SetPlotConfigIsOpen}"
  317. Placement="Center"
  318. PopupAnimation="Scroll"
  319. StaysOpen="True">
  320. <local:SetPlotConfigView />
  321. </Popup>
  322. </Grid>
  323. </Border>
  324. </UserControl>