App.xaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <Application
  2. x:Class="ShakerControl.App"
  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:ShakerControl.Convert"
  6. xmlns:hc="https://handyorg.github.io/handycontrol"
  7. xmlns:local="clr-namespace:ShakerControl"
  8. xmlns:system="clr-namespace:System;assembly=mscorlib"
  9. xmlns:view="clr-namespace:ShakerControl.ViewModel.DataManger"
  10. xmlns:vm="clr-namespace:ShakerControl.ViewModel">
  11. <Application.Resources>
  12. <ResourceDictionary>
  13. <ResourceDictionary.MergedDictionaries>
  14. <ResourceDictionary Source="pack://application:,,,/AppResource;component/Resource.xaml" />
  15. <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
  16. <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
  17. </ResourceDictionary.MergedDictionaries>
  18. <system:Double x:Key="WindowWidth">1024</system:Double>
  19. <system:Double x:Key="WindowHeight">768</system:Double>
  20. <vm:MainViewModelBindingProxy x:Key="MainViewModel" />
  21. <vm:BindingProxy x:Key="Prompt" Data="{x:Static vm:PromptViewModel.Default}" />
  22. <convert:Type2ViewConverter x:Key="Type2ViewConverter" />
  23. <convert:EnumToCollectionConverter x:Key="EnumToCollectionConverter" />
  24. <convert:EnumToDescription x:Key="EnumToDescription" />
  25. <convert:SilderDoubleConverter x:Key="SilderDoubleConverter" />
  26. <convert:GetItemConverter x:Key="GetItemConverter" />
  27. <convert:OxyPlotColorToSolidBrushConverter x:Key="OxyPlotColorToSolidBrushConverter" />
  28. <view:ColorPickerViewModel x:Key="ColorPicker" />
  29. <ControlTemplate x:Key="SliderThumb1" TargetType="{x:Type Thumb}">
  30. <hc:AxleCanvas>
  31. <Border
  32. x:Name="BorderDot"
  33. Canvas.Bottom="0"
  34. Width="{TemplateBinding Width}"
  35. Height="{TemplateBinding Height}"
  36. Margin="0"
  37. Background="{DynamicResource PrimaryBrush}"
  38. BorderBrush="{TemplateBinding BorderBrush}"
  39. CornerRadius="6" />
  40. </hc:AxleCanvas>
  41. <ControlTemplate.Triggers>
  42. <EventTrigger RoutedEvent="UIElement.PreviewMouseLeftButtonDown">
  43. <BeginStoryboard>
  44. <Storyboard>
  45. <ThicknessAnimation
  46. Storyboard.TargetName="BorderDot"
  47. Storyboard.TargetProperty="BorderThickness"
  48. To="2"
  49. Duration="0:0:.1" />
  50. </Storyboard>
  51. </BeginStoryboard>
  52. </EventTrigger>
  53. <EventTrigger RoutedEvent="UIElement.PreviewMouseLeftButtonUp">
  54. <BeginStoryboard>
  55. <Storyboard>
  56. <ThicknessAnimation
  57. Storyboard.TargetName="BorderDot"
  58. Storyboard.TargetProperty="BorderThickness"
  59. To="0"
  60. Duration="0:0:.1" />
  61. </Storyboard>
  62. </BeginStoryboard>
  63. </EventTrigger>
  64. </ControlTemplate.Triggers>
  65. </ControlTemplate>
  66. <Style x:Key="RepeatButtonStyle1" TargetType="{x:Type RepeatButton}">
  67. <Setter Property="OverridesDefaultStyle" Value="true" />
  68. <Setter Property="Background" Value="Transparent" />
  69. <Setter Property="Focusable" Value="false" />
  70. <Setter Property="IsTabStop" Value="false" />
  71. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  72. <Setter Property="Template">
  73. <Setter.Value>
  74. <ControlTemplate TargetType="{x:Type RepeatButton}">
  75. <Border
  76. Width="{TemplateBinding Width}"
  77. Height="{TemplateBinding Height}"
  78. Background="Transparent" />
  79. </ControlTemplate>
  80. </Setter.Value>
  81. </Setter>
  82. </Style>
  83. <Style x:Key="RepeatButtonStyle2" TargetType="{x:Type RepeatButton}">
  84. <Setter Property="OverridesDefaultStyle" Value="true" />
  85. <Setter Property="Background" Value="Transparent" />
  86. <Setter Property="Focusable" Value="false" />
  87. <Setter Property="IsTabStop" Value="false" />
  88. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  89. <Setter Property="Template">
  90. <Setter.Value>
  91. <ControlTemplate TargetType="{x:Type RepeatButton}">
  92. <Border
  93. Width="{TemplateBinding Width}"
  94. Height="{TemplateBinding Height}"
  95. Background="{TemplateBinding Background}"
  96. CornerRadius="6,0,0,6" />
  97. </ControlTemplate>
  98. </Setter.Value>
  99. </Setter>
  100. </Style>
  101. <ControlTemplate x:Key="SliderStyle" TargetType="{x:Type Slider}">
  102. <Border
  103. Background="Transparent"
  104. BorderBrush="{TemplateBinding BorderBrush}"
  105. BorderThickness="{TemplateBinding BorderThickness}"
  106. CornerRadius="6">
  107. <Grid>
  108. <Track x:Name="PART_Track" Margin="0">
  109. <Track.DecreaseRepeatButton>
  110. <RepeatButton
  111. Background="{TemplateBinding Background}"
  112. Command="{x:Static Slider.DecreaseLarge}"
  113. Style="{StaticResource RepeatButtonStyle2}" />
  114. </Track.DecreaseRepeatButton>
  115. <Track.IncreaseRepeatButton>
  116. <RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonStyle1}" />
  117. </Track.IncreaseRepeatButton>
  118. <Track.Thumb>
  119. <Thumb
  120. x:Name="Thumb"
  121. Width="18"
  122. Height="{TemplateBinding Height}"
  123. VerticalAlignment="Center"
  124. ClipToBounds="False"
  125. Focusable="False"
  126. OverridesDefaultStyle="True"
  127. Template="{StaticResource SliderThumb1}" />
  128. </Track.Thumb>
  129. </Track>
  130. <TextBlock
  131. HorizontalAlignment="Center"
  132. VerticalAlignment="Center"
  133. FontFamily="{TemplateBinding FontFamily}"
  134. FontSize="{TemplateBinding FontSize}"
  135. FontStretch="{TemplateBinding FontStretch}"
  136. FontStyle="{TemplateBinding FontStyle}"
  137. FontWeight="{TemplateBinding FontWeight}"
  138. Foreground="{TemplateBinding Foreground}"
  139. IsHitTestVisible="False"
  140. Text="{Binding Value, Converter={StaticResource SilderDoubleConverter}, RelativeSource={RelativeSource TemplatedParent}, StringFormat={}{0}%}" />
  141. </Grid>
  142. </Border>
  143. <ControlTemplate.Triggers>
  144. <MultiTrigger>
  145. <MultiTrigger.Conditions>
  146. <Condition Property="hc:TipElement.Placement" Value="Top" />
  147. <Condition Property="hc:TipElement.Visibility" Value="Visible" />
  148. </MultiTrigger.Conditions>
  149. <Setter TargetName="Thumb" Property="Template" Value="{StaticResource TipSliderThumbHorizontalTop}" />
  150. </MultiTrigger>
  151. <MultiTrigger>
  152. <MultiTrigger.Conditions>
  153. <Condition Property="hc:TipElement.Placement" Value="Bottom" />
  154. <Condition Property="hc:TipElement.Visibility" Value="Visible" />
  155. </MultiTrigger.Conditions>
  156. <Setter TargetName="Thumb" Property="Template" Value="{StaticResource TipSliderThumbHorizontalBottom}" />
  157. </MultiTrigger>
  158. </ControlTemplate.Triggers>
  159. </ControlTemplate>
  160. <ControlTemplate x:Key="ComboBoxTemplate1" TargetType="ComboBox">
  161. <Grid>
  162. <Grid.ColumnDefinitions>
  163. <ColumnDefinition />
  164. <ColumnDefinition Width="Auto" />
  165. </Grid.ColumnDefinitions>
  166. <Border
  167. x:Name="border"
  168. Grid.ColumnSpan="2"
  169. Background="{TemplateBinding Background}"
  170. BorderBrush="{TemplateBinding BorderBrush}"
  171. BorderThickness="{TemplateBinding BorderThickness}"
  172. CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" />
  173. <hc:ToggleBlock
  174. Grid.Column="1"
  175. Padding="1,0"
  176. HorizontalContentAlignment="Stretch"
  177. VerticalContentAlignment="Stretch"
  178. Background="Transparent"
  179. IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
  180. <hc:ToggleBlock.UnCheckedContent>
  181. <Path
  182. Width="14"
  183. Margin="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}"
  184. HorizontalAlignment="Right"
  185. VerticalAlignment="Center"
  186. Data="{StaticResource DownGeometry}"
  187. Fill="{TemplateBinding BorderBrush}"
  188. Stretch="Uniform" />
  189. </hc:ToggleBlock.UnCheckedContent>
  190. <hc:ToggleBlock.CheckedContent>
  191. <Path
  192. Width="14"
  193. Margin="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}"
  194. HorizontalAlignment="Right"
  195. VerticalAlignment="Center"
  196. Data="{StaticResource UpGeometry}"
  197. Fill="{TemplateBinding BorderBrush}"
  198. Stretch="Uniform" />
  199. </hc:ToggleBlock.CheckedContent>
  200. </hc:ToggleBlock>
  201. <hc:ToggleBlock
  202. Grid.Column="0"
  203. Grid.ColumnSpan="2"
  204. HorizontalContentAlignment="Stretch"
  205. VerticalContentAlignment="Stretch"
  206. Background="Transparent"
  207. IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  208. ToggleGesture="LeftClick" />
  209. <ContentPresenter
  210. x:Name="contentPresenter"
  211. Grid.Column="0"
  212. Margin="{TemplateBinding Padding}"
  213. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  214. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  215. Content="{TemplateBinding SelectionBoxItem}"
  216. ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
  217. ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
  218. ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
  219. IsHitTestVisible="false"
  220. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  221. <Popup
  222. x:Name="PART_Popup"
  223. Margin="1"
  224. AllowsTransparency="true"
  225. IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  226. Placement="Bottom"
  227. PlacementTarget="{Binding ElementName=border}"
  228. PopupAnimation="{StaticResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
  229. <Decorator Margin="8,0">
  230. <Border
  231. x:Name="dropDownBorder"
  232. MinWidth="{Binding ActualWidth, ElementName=border}"
  233. MaxHeight="{TemplateBinding MaxDropDownHeight}"
  234. Margin="0,0,0,8"
  235. Background="{StaticResource InfoBrush}"
  236. BorderBrush="{TemplateBinding BorderBrush}"
  237. BorderThickness="0,1,0,0"
  238. CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
  239. Effect="{StaticResource EffectShadow2}">
  240. <hc:ToggleBlock
  241. HorizontalContentAlignment="Stretch"
  242. VerticalContentAlignment="Stretch"
  243. IsChecked="{Binding HasItems, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
  244. <hc:ToggleBlock.CheckedContent>
  245. <ScrollViewer Margin="2">
  246. <ItemsPresenter
  247. x:Name="ItemsPresenter"
  248. KeyboardNavigation.DirectionalNavigation="Contained"
  249. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  250. </ScrollViewer>
  251. </hc:ToggleBlock.CheckedContent>
  252. <hc:ToggleBlock.UnCheckedContent>
  253. <hc:Empty />
  254. </hc:ToggleBlock.UnCheckedContent>
  255. </hc:ToggleBlock>
  256. </Border>
  257. </Decorator>
  258. </Popup>
  259. </Grid>
  260. <ControlTemplate.Triggers>
  261. <Trigger Property="HasItems" Value="false">
  262. <Setter TargetName="dropDownBorder" Property="Height" Value="95" />
  263. </Trigger>
  264. <Trigger Property="hc:DropDownElement.ConsistentWidth" Value="True">
  265. <Setter TargetName="dropDownBorder" Property="MaxWidth" Value="{Binding ActualWidth, ElementName=border}" />
  266. <Setter TargetName="dropDownBorder" Property="MinWidth" Value="{Binding ActualWidth, ElementName=border}" />
  267. </Trigger>
  268. <Trigger Property="hc:DropDownElement.AutoWidth" Value="True">
  269. <Setter TargetName="dropDownBorder" Property="MaxWidth" Value="{x:Static system:Double.MaxValue}" />
  270. <Setter TargetName="dropDownBorder" Property="MinWidth" Value="{Binding ActualHeight, ElementName=border}" />
  271. </Trigger>
  272. <MultiTrigger>
  273. <MultiTrigger.Conditions>
  274. <Condition Property="IsGrouping" Value="true" />
  275. <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
  276. </MultiTrigger.Conditions>
  277. <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
  278. </MultiTrigger>
  279. <MultiTrigger>
  280. <MultiTrigger.Conditions>
  281. <Condition Property="IsMouseOver" Value="true" />
  282. <Condition SourceName="PART_Popup" Property="IsOpen" Value="false" />
  283. </MultiTrigger.Conditions>
  284. <Setter Property="BorderBrush" Value="{DynamicResource SecondaryBorderBrush}" />
  285. </MultiTrigger>
  286. <Trigger SourceName="PART_Popup" Property="IsOpen" Value="True">
  287. <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}" />
  288. </Trigger>
  289. <Trigger Property="IsFocused" Value="True">
  290. <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}" />
  291. </Trigger>
  292. <Trigger Property="IsEnabled" Value="false">
  293. <Setter Property="Opacity" Value="0.4" />
  294. </Trigger>
  295. </ControlTemplate.Triggers>
  296. </ControlTemplate>
  297. <Style x:Key="ComboBoxItemBaseStyle1" TargetType="ComboBoxItem">
  298. <Setter Property="SnapsToDevicePixels" Value="True" />
  299. <Setter Property="Padding" Value="{StaticResource DefaultControlPadding}" />
  300. <Setter Property="Background" Value="Transparent" />
  301. <Setter Property="BorderBrush" Value="Transparent" />
  302. <Setter Property="BorderThickness" Value="0" />
  303. <Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}" />
  304. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  305. <Setter Property="Template">
  306. <Setter.Value>
  307. <ControlTemplate TargetType="ComboBoxItem">
  308. <Border
  309. x:Name="Bd"
  310. Padding="{TemplateBinding Padding}"
  311. Background="{TemplateBinding Background}"
  312. BorderBrush="{TemplateBinding BorderBrush}"
  313. BorderThickness="{TemplateBinding BorderThickness}"
  314. CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
  315. Cursor="Hand">
  316. <ContentPresenter
  317. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  318. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  319. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  320. </Border>
  321. <ControlTemplate.Triggers>
  322. <MultiTrigger>
  323. <MultiTrigger.Conditions>
  324. <Condition Property="IsSelected" Value="False" />
  325. <Condition Property="IsMouseOver" Value="True" />
  326. </MultiTrigger.Conditions>
  327. <Setter TargetName="Bd" Property="Background" Value="Green" />
  328. </MultiTrigger>
  329. <MultiTrigger>
  330. <MultiTrigger.Conditions>
  331. <Condition Property="IsSelected" Value="True" />
  332. </MultiTrigger.Conditions>
  333. <Setter TargetName="Bd" Property="Background" Value="{DynamicResource PrimaryBrush}" />
  334. <Setter Property="Foreground" Value="White" />
  335. </MultiTrigger>
  336. </ControlTemplate.Triggers>
  337. </ControlTemplate>
  338. </Setter.Value>
  339. </Setter>
  340. </Style>
  341. <Style
  342. x:Key="ComboBoxStyle1"
  343. BasedOn="{StaticResource InputElementBaseStyle}"
  344. TargetType="{x:Type ComboBox}">
  345. <Setter Property="ItemContainerStyle" Value="{StaticResource ComboBoxItemBaseStyle1}" />
  346. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
  347. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
  348. <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
  349. <Setter Property="ScrollViewer.PanningMode" Value="Both" />
  350. <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
  351. <Setter Property="Cursor" Value="Hand" />
  352. <Setter Property="Template" Value="{StaticResource ComboBoxTemplate1}" />
  353. <Style.Triggers>
  354. <Trigger Property="IsEditable" Value="true">
  355. <Setter Property="IsTabStop" Value="false" />
  356. <Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}" />
  357. </Trigger>
  358. </Style.Triggers>
  359. </Style>
  360. <Style
  361. x:Key="PowerAmplifierButtonStyle"
  362. BasedOn="{StaticResource ButtonIcon}"
  363. TargetType="Button">
  364. <Style.Triggers>
  365. <Trigger Property="IsMouseOver" Value="True">
  366. <Setter Property="Foreground" Value="CadetBlue" />
  367. </Trigger>
  368. </Style.Triggers>
  369. </Style>
  370. </ResourceDictionary>
  371. </Application.Resources>
  372. </Application>