No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

308 líneas
19 KiB

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:bpa="clr-namespace:BPA.UIControl">
  4. <ResourceDictionary.MergedDictionaries>
  5. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/ScrollViewer.xaml" />
  6. </ResourceDictionary.MergedDictionaries>
  7. <Style x:Key="MenuScrollViewer"
  8. BasedOn="{StaticResource OnlyArrowScrollViewer}"
  9. TargetType="{x:Type ScrollViewer}">
  10. <Setter Property="HorizontalScrollBarVisibility" Value="Hidden" />
  11. <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
  12. </Style>
  13. <!-- Separator -->
  14. <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
  15. <Setter Property="Margin" Value="{Binding Path=(bpa:ItemsControlHelper.ItemPadding), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  16. <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
  17. <Setter Property="BorderThickness" Value="1 1 0 0" />
  18. <Setter Property="Template">
  19. <Setter.Value>
  20. <ControlTemplate TargetType="{x:Type Separator}">
  21. <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
  22. </ControlTemplate>
  23. </Setter.Value>
  24. </Setter>
  25. </Style>
  26. <!-- TopLevelHeader -->
  27. <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
  28. <Border Background="{Binding Path=(bpa:HeaderHelper.Background), RelativeSource={RelativeSource AncestorType=MenuBase}}"
  29. BorderBrush="{TemplateBinding BorderBrush}"
  30. BorderThickness="{TemplateBinding BorderThickness}"
  31. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}">
  32. <Grid>
  33. <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  34. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  35. IsActive="{TemplateBinding IsHighlighted}"
  36. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  37. <ContentPresenter Margin="{TemplateBinding Padding}"
  38. ContentSource="Header"
  39. RecognizesAccessKey="True"
  40. TextBlock.Foreground="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  41. <Popup x:Name="Popup"
  42. AllowsTransparency="True"
  43. Focusable="False"
  44. HorizontalOffset="-5"
  45. IsOpen="{TemplateBinding IsSubmenuOpen}"
  46. Placement="Bottom"
  47. PopupAnimation="Fade">
  48. <Grid>
  49. <Border Margin="5"
  50. Padding="0 5"
  51. Background="{DynamicResource FloatBackground}"
  52. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  53. Effect="{DynamicResource AllDirectionEffect}" />
  54. <Border x:Name="SubmenuBorder"
  55. Margin="5"
  56. Padding="0 5"
  57. Background="{DynamicResource FloatBackground}"
  58. BorderBrush="{TemplateBinding BorderBrush}"
  59. BorderThickness="{TemplateBinding BorderThickness}"
  60. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  61. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  62. <ScrollViewer Style="{StaticResource MenuScrollViewer}" CanContentScroll="True">
  63. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
  64. </ScrollViewer>
  65. </Border>
  66. </Grid>
  67. </Popup>
  68. </Grid>
  69. </Border>
  70. <ControlTemplate.Triggers>
  71. <Trigger Property="IsSuspendingPopupAnimation" Value="True">
  72. <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
  73. </Trigger>
  74. <Trigger Property="IsEnabled" Value="False">
  75. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  76. </Trigger>
  77. </ControlTemplate.Triggers>
  78. </ControlTemplate>
  79. <!-- TopLevelItem -->
  80. <ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type MenuItem}">
  81. <Border Background="{Binding Path=(bpa:HeaderHelper.Background), RelativeSource={RelativeSource AncestorType=MenuBase}}"
  82. BorderBrush="{TemplateBinding BorderBrush}"
  83. BorderThickness="{TemplateBinding BorderThickness}"
  84. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}">
  85. <Grid>
  86. <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  87. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  88. IsActive="{TemplateBinding IsHighlighted}"
  89. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  90. <ContentPresenter Margin="{TemplateBinding Padding}"
  91. ContentSource="Header"
  92. RecognizesAccessKey="True"
  93. TextBlock.Foreground="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  94. </Grid>
  95. </Border>
  96. <ControlTemplate.Triggers>
  97. <Trigger Property="IsEnabled" Value="False">
  98. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  99. </Trigger>
  100. </ControlTemplate.Triggers>
  101. </ControlTemplate>
  102. <!-- SubmenuHeade -->
  103. <ControlTemplate x:Key="{x:Static MenuItem.SubmenuHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
  104. <Grid Background="Transparent">
  105. <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  106. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  107. IsActive="{TemplateBinding IsHighlighted}"
  108. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  109. <Border Padding="{TemplateBinding Padding}">
  110. <Grid>
  111. <Grid.ColumnDefinitions>
  112. <ColumnDefinition Width="{Binding Path=(bpa:MenuHelper.IconWidth), RelativeSource={RelativeSource Mode=TemplatedParent}}" SharedSizeGroup="Icon" />
  113. <ColumnDefinition Width="*" />
  114. <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
  115. <ColumnDefinition Width="Auto" />
  116. </Grid.ColumnDefinitions>
  117. <ContentPresenter x:Name="Icon"
  118. HorizontalAlignment="Left"
  119. VerticalAlignment="Center"
  120. ContentSource="Icon" />
  121. <ContentPresenter x:Name="HeaderHost"
  122. Grid.Column="1"
  123. VerticalAlignment="Center"
  124. ContentSource="Header"
  125. RecognizesAccessKey="True" />
  126. <TextBlock x:Name="InputGestureText"
  127. Grid.Column="2"
  128. Margin="5 0 0 0"
  129. HorizontalAlignment="Right"
  130. VerticalAlignment="Center"
  131. Text="{TemplateBinding InputGestureText}" />
  132. <bpa:Icon Grid.Column="3"
  133. Margin="20 0 0 0"
  134. HorizontalAlignment="Center"
  135. VerticalAlignment="Center"
  136. Type="ArrowRightSLine" />
  137. <Popup x:Name="Popup"
  138. AllowsTransparency="True"
  139. Focusable="False"
  140. HorizontalOffset="5"
  141. IsOpen="{TemplateBinding IsSubmenuOpen}"
  142. Placement="Right"
  143. PopupAnimation="Fade">
  144. <Grid>
  145. <Border Margin="5"
  146. Padding="0 5"
  147. Background="{DynamicResource FloatBackground}"
  148. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  149. Effect="{DynamicResource AllDirectionEffect}" />
  150. <Border x:Name="SubmenuBorder"
  151. Margin="5"
  152. Padding="0 5"
  153. Background="{DynamicResource FloatBackground}"
  154. BorderBrush="{TemplateBinding BorderBrush}"
  155. BorderThickness="{TemplateBinding BorderThickness}"
  156. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  157. Effect="{DynamicResource AllDirectionEffect}"
  158. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
  159. <ScrollViewer Style="{StaticResource MenuScrollViewer}" CanContentScroll="True">
  160. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
  161. </ScrollViewer>
  162. </Border>
  163. </Grid>
  164. </Popup>
  165. </Grid>
  166. </Border>
  167. </Grid>
  168. <ControlTemplate.Triggers>
  169. <Trigger Property="Icon" Value="{x:Null}">
  170. <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
  171. </Trigger>
  172. <Trigger Property="IsEnabled" Value="False">
  173. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  174. </Trigger>
  175. </ControlTemplate.Triggers>
  176. </ControlTemplate>
  177. <!-- SubmenuItem -->
  178. <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}">
  179. <Grid Background="Transparent">
  180. <bpa:ControlMask Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  181. CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
  182. IsActive="{TemplateBinding IsHighlighted}"
  183. MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  184. <Border Padding="{TemplateBinding Padding}">
  185. <Grid>
  186. <Grid.ColumnDefinitions>
  187. <ColumnDefinition Width="{Binding Path=(bpa:MenuHelper.IconWidth), RelativeSource={RelativeSource Mode=TemplatedParent}}" SharedSizeGroup="Icon" />
  188. <ColumnDefinition Width="*" />
  189. <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
  190. <ColumnDefinition Width="{Binding Path=(bpa:MenuHelper.IconWidth), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
  191. </Grid.ColumnDefinitions>
  192. <ContentPresenter x:Name="Icon"
  193. HorizontalAlignment="Left"
  194. VerticalAlignment="Center"
  195. ContentSource="Icon" />
  196. <bpa:Icon x:Name="Check"
  197. HorizontalAlignment="Left"
  198. VerticalAlignment="Center"
  199. Type="CheckFill"
  200. Visibility="Hidden" />
  201. <ContentPresenter x:Name="HeaderHost"
  202. Grid.Column="1"
  203. HorizontalAlignment="Left"
  204. VerticalAlignment="Center"
  205. ContentSource="Header"
  206. RecognizesAccessKey="True" />
  207. <TextBlock x:Name="InputGestureText"
  208. Grid.Column="2"
  209. Margin="5 0 0 0"
  210. DockPanel.Dock="Right"
  211. Text="{TemplateBinding InputGestureText}" />
  212. </Grid>
  213. </Border>
  214. </Grid>
  215. <ControlTemplate.Triggers>
  216. <Trigger Property="Icon" Value="{x:Null}">
  217. <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
  218. </Trigger>
  219. <Trigger Property="IsChecked" Value="True">
  220. <Setter TargetName="Check" Property="Visibility" Value="Visible" />
  221. </Trigger>
  222. <Trigger Property="IsCheckable" Value="True">
  223. <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
  224. </Trigger>
  225. <Trigger Property="IsEnabled" Value="False">
  226. <Setter Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
  227. </Trigger>
  228. </ControlTemplate.Triggers>
  229. </ControlTemplate>
  230. <!-- MenuItem Style -->
  231. <Style x:Key="RubyerMenuItem" TargetType="{x:Type MenuItem}">
  232. <Setter Property="OverridesDefaultStyle" Value="True" />
  233. <Setter Property="Background" Value="{Binding Background, RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  234. <Setter Property="BorderBrush" Value="{Binding BorderBrush, RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  235. <Setter Property="BorderThickness" Value="{Binding BorderThickness, RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  236. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  237. <Setter Property="bpa:ControlHelper.MaskOpacity" Value="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  238. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  239. <Setter Property="Padding" Value="{Binding Path=(bpa:ItemsControlHelper.ItemPadding), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  240. <Setter Property="Margin" Value="{Binding Path=(bpa:ItemsControlHelper.ItemMargin), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  241. <Setter Property="bpa:MenuHelper.IconWidth" Value="{Binding Path=(bpa:MenuHelper.IconWidth), RelativeSource={RelativeSource AncestorType=MenuBase}}" />
  242. <Style.Triggers>
  243. <Trigger Property="Role" Value="TopLevelHeader">
  244. <Setter Property="Grid.IsSharedSizeScope" Value="True" />
  245. <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelHeaderTemplateKey}}" />
  246. <Setter Property="Margin" Value="0" />
  247. </Trigger>
  248. <Trigger Property="Role" Value="TopLevelItem">
  249. <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelItemTemplateKey}}" />
  250. <Setter Property="Margin" Value="0" />
  251. </Trigger>
  252. <Trigger Property="Role" Value="SubmenuHeader">
  253. <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuHeaderTemplateKey}}" />
  254. </Trigger>
  255. <Trigger Property="Role" Value="SubmenuItem">
  256. <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuItemTemplateKey}}" />
  257. </Trigger>
  258. </Style.Triggers>
  259. </Style>
  260. <Style x:Key="RubyerMenu" TargetType="{x:Type Menu}">
  261. <Setter Property="Background" Value="{DynamicResource DefaultBackground}" />
  262. <Setter Property="BorderThickness" Value="0" />
  263. <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
  264. <Setter Property="OverridesDefaultStyle" Value="True" />
  265. <Setter Property="SnapsToDevicePixels" Value="True" />
  266. <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
  267. <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Mask}" />
  268. <Setter Property="bpa:ItemsControlHelper.ItemMargin" Value="5 1" />
  269. <Setter Property="bpa:ItemsControlHelper.ItemPadding" Value="10 5" />
  270. <Setter Property="bpa:HeaderHelper.Background" Value="Transparent" />
  271. <Setter Property="bpa:HeaderHelper.Foreground" Value="{DynamicResource DefaultForeground}" />
  272. <Setter Property="bpa:MenuHelper.IconWidth" Value="24" />
  273. <Setter Property="Template">
  274. <Setter.Value>
  275. <ControlTemplate TargetType="{x:Type Menu}">
  276. <Border Background="Transparent" CornerRadius="{DynamicResource AllControlCornerRadius}">
  277. <StackPanel ClipToBounds="True"
  278. IsItemsHost="True"
  279. Orientation="Horizontal" />
  280. </Border>
  281. </ControlTemplate>
  282. </Setter.Value>
  283. </Setter>
  284. </Style>
  285. </ResourceDictionary>