Application.xaml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <Application x:Class="Application"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:local="clr-namespace:PCL"
  5. xmlns:sys="clr-namespace:System;assembly=mscorlib"
  6. xmlns:behaviors="clr-namespace:PCL.Controls.Behaviors"
  7. StartupUri="FormMain.xaml"
  8. ShutdownMode="OnExplicitShutdown">
  9. <Application.Resources>
  10. <ResourceDictionary>
  11. <!-- Converter -->
  12. <local:AdditionConverter x:Key="AdditionConverter"/>
  13. <local:MultiplicationConverter x:Key="MultiplicationConverter"/>
  14. <local:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
  15. <local:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
  16. <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
  17. <!-- 颜色表 -->
  18. <SolidColorBrush x:Key="ColorBrush1">#343d4a</SolidColorBrush>
  19. <SolidColorBrush x:Key="ColorBrush2">#0b5bcb</SolidColorBrush>
  20. <SolidColorBrush x:Key="ColorBrush3">#1370f3</SolidColorBrush>
  21. <SolidColorBrush x:Key="ColorBrush4">#4890f5</SolidColorBrush>
  22. <SolidColorBrush x:Key="ColorBrush5">#96c0f9</SolidColorBrush>
  23. <SolidColorBrush x:Key="ColorBrush6">#d5e6fd</SolidColorBrush>
  24. <SolidColorBrush x:Key="ColorBrush7">#e0eafd</SolidColorBrush>
  25. <SolidColorBrush x:Key="ColorBrush8">#eaf2fe</SolidColorBrush>
  26. <SolidColorBrush x:Key="ColorBrushBg0">#96c0f9</SolidColorBrush>
  27. <SolidColorBrush x:Key="ColorBrushBg1">#bee0eafd</SolidColorBrush>
  28. <Color x:Key="ColorObject1">#343d4a</Color>
  29. <Color x:Key="ColorObject2">#0b5bcb</Color>
  30. <Color x:Key="ColorObject3">#1370f3</Color>
  31. <Color x:Key="ColorObject4">#4890f5</Color>
  32. <Color x:Key="ColorObject5">#96c0f9</Color>
  33. <Color x:Key="ColorObject6">#d5e6fd</Color>
  34. <Color x:Key="ColorObject7">#e0eafd</Color>
  35. <Color x:Key="ColorObject8">#eaf2fe</Color>
  36. <Color x:Key="ColorObjectBg0">#96c0f9</Color>
  37. <Color x:Key="ColorObjectBg1">#bee0eafd</Color>
  38. <SolidColorBrush x:Key="ColorBrushGray1">#404040</SolidColorBrush>
  39. <SolidColorBrush x:Key="ColorBrushGray2">#737373</SolidColorBrush>
  40. <SolidColorBrush x:Key="ColorBrushGray3">#8c8c8c</SolidColorBrush>
  41. <SolidColorBrush x:Key="ColorBrushGray4">#a6a6a6</SolidColorBrush>
  42. <SolidColorBrush x:Key="ColorBrushGray5">#cccccc</SolidColorBrush>
  43. <SolidColorBrush x:Key="ColorBrushGray6">#ebebeb</SolidColorBrush>
  44. <SolidColorBrush x:Key="ColorBrushGray7">#f0f0f0</SolidColorBrush>
  45. <SolidColorBrush x:Key="ColorBrushGray8">#f5f5f5</SolidColorBrush>
  46. <Color x:Key="ColorObjectGray1">#404040</Color>
  47. <Color x:Key="ColorObjectGray2">#737373</Color>
  48. <Color x:Key="ColorObjectGray3">#8c8c8c</Color>
  49. <Color x:Key="ColorObjectGray4">#a6a6a6</Color>
  50. <Color x:Key="ColorObjectGray5">#cccccc</Color>
  51. <Color x:Key="ColorObjectGray6">#ebebeb</Color>
  52. <Color x:Key="ColorObjectGray7">#f0f0f0</Color>
  53. <Color x:Key="ColorObjectGray8">#f5f5f5</Color>
  54. <SolidColorBrush x:Key="ColorBrushRedBack">#80fbdddd</SolidColorBrush>
  55. <SolidColorBrush x:Key="ColorBrushRedLight">#ff4c4c</SolidColorBrush>
  56. <SolidColorBrush x:Key="ColorBrushRedDark">#ce2111</SolidColorBrush>
  57. <SolidColorBrush x:Key="ColorBrushHalfWhite" Color="#55ffffff" />
  58. <SolidColorBrush x:Key="ColorBrushSemiWhite" Color="#bbffffff" />
  59. <SolidColorBrush x:Key="ColorBrushWhite" Color="#ffffff" />
  60. <SolidColorBrush x:Key="ColorBrushTransparent" Color="Transparent" />
  61. <SolidColorBrush x:Key="ColorBrushSemiTransparent">#01eaf2fe</SolidColorBrush>
  62. <SolidColorBrush x:Key="ColorBrushBackgroundTransparentSidebar" Color="#F1FFFFFF" />
  63. <!-- Window -->
  64. <Style TargetType="{x:Type Window}" x:Key="MyWindow">
  65. <Setter Property="OverridesDefaultStyle" Value="True"/>
  66. <Setter Property="Template">
  67. <Setter.Value>
  68. <ControlTemplate TargetType="{x:Type Window}">
  69. <ContentPresenter />
  70. </ControlTemplate>
  71. </Setter.Value>
  72. </Setter>
  73. </Style>
  74. <!-- Label -->
  75. <Style TargetType="Label">
  76. <Setter Property="OverridesDefaultStyle" Value="True"/>
  77. <Setter Property="Padding" Value="0"/>
  78. <Setter Property="Template">
  79. <Setter.Value>
  80. <ControlTemplate TargetType="Label">
  81. <Border Background="{TemplateBinding Background}">
  82. <ContentPresenter
  83. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  84. Margin="{TemplateBinding Padding}"
  85. RecognizesAccessKey="False"
  86. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  87. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  88. </Border>
  89. </ControlTemplate>
  90. </Setter.Value>
  91. </Setter>
  92. </Style>
  93. <Style TargetType="local:MyTextButton">
  94. <Setter Property="OverridesDefaultStyle" Value="True"/>
  95. <Setter Property="Padding" Value="0"/>
  96. <Setter Property="Template">
  97. <Setter.Value>
  98. <ControlTemplate TargetType="Label">
  99. <Border Background="{TemplateBinding Background}">
  100. <TextBlock
  101. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  102. Margin="{TemplateBinding Padding}"
  103. Foreground="{TemplateBinding Foreground}"
  104. Text="{TemplateBinding Content}"
  105. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  106. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  107. </Border>
  108. </ControlTemplate>
  109. </Setter.Value>
  110. </Setter>
  111. </Style>
  112. <!-- TextBlock -->
  113. <Style TargetType="TextBlock">
  114. <Setter Property="OverridesDefaultStyle" Value="True" />
  115. <Setter Property="FontSize" Value="13" />
  116. <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
  117. <Setter Property="TextTrimming" Value="CharacterEllipsis" />
  118. <Setter Property="FontFamily" Value="Resources/#PCL English, Microsoft YaHei UI" />
  119. </Style>
  120. <Style TargetType="TextBlock" x:Key="BasedOnTextBlock">
  121. <Setter Property="OverridesDefaultStyle" Value="True" />
  122. <Setter Property="FontSize" Value="13" />
  123. <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
  124. <Setter Property="TextTrimming" Value="CharacterEllipsis" />
  125. <Setter Property="FontFamily" Value="Resources/#PCL English, Microsoft YaHei UI" />
  126. </Style>
  127. <!-- ToolTip -->
  128. <Style TargetType="ToolTip">
  129. <Setter Property="Template">
  130. <Setter.Value>
  131. <ControlTemplate>
  132. <Border Loaded="TooltipLoaded" Unloaded="TooltipUnloaded" BorderBrush="{DynamicResource ColorBrush1}" BorderThickness="1.5" CornerRadius="4" MaxWidth="500" Background="#E5FFFFFF" Margin="0,0,4,4" SnapsToDevicePixels="True">
  133. <Border.Effect>
  134. <DropShadowEffect Opacity="0.3" BlurRadius="4" ShadowDepth="2" Color="{DynamicResource ColorObject1}" />
  135. </Border.Effect>
  136. <TextBlock Text="{TemplateBinding ContentControl.Content}" TextWrapping="Wrap" Foreground="{DynamicResource ColorBrush1}" Margin="7,5" FontSize="12"/>
  137. </Border>
  138. </ControlTemplate>
  139. </Setter.Value>
  140. </Setter>
  141. </Style>
  142. <Style x:Key="ExtendTextToolTip" TargetType="ToolTip">
  143. <Setter Property="Template">
  144. <Setter.Value>
  145. <ControlTemplate>
  146. <Border Loaded="TooltipLoaded" Unloaded="TooltipUnloaded" BorderBrush="{DynamicResource ColorBrush1}" BorderThickness="1" CornerRadius="3" Background="White" Margin="0,0,4,4" SnapsToDevicePixels="True">
  147. <TextBlock Text="{TemplateBinding ContentControl.Content}" TextWrapping="Wrap" Foreground="{DynamicResource ColorBrush1}" Margin="7,5" FontSize="12"/>
  148. </Border>
  149. </ControlTemplate>
  150. </Setter.Value>
  151. </Setter>
  152. </Style>
  153. <!-- ScrollViewer -->
  154. <Style x:Key="MyThumb" TargetType="Thumb">
  155. <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
  156. <Setter Property="Template">
  157. <Setter.Value>
  158. <ControlTemplate TargetType="Thumb">
  159. <Border Background="{StaticResource ColorBrushSemiTransparent}" SnapsToDevicePixels="True">
  160. <Border Background="{TemplateBinding Foreground}" CornerRadius="3" Margin="2" />
  161. </Border>
  162. </ControlTemplate>
  163. </Setter.Value>
  164. </Setter>
  165. </Style>
  166. <Style TargetType="local:MyScrollBar">
  167. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  168. <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False"/>
  169. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  170. <Setter Property="OverridesDefaultStyle" Value="True" />
  171. <Setter Property="SnapsToDevicePixels" Value="True" />
  172. <Setter Property="UseLayoutRounding" Value="True" />
  173. <Setter Property="MinWidth" Value="8"/>
  174. <Setter Property="Width" Value="8"/>
  175. <Setter Property="Template">
  176. <Setter.Value>
  177. <ControlTemplate TargetType="ScrollBar">
  178. <Border CornerRadius="2">
  179. <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}">
  180. <Track.Resources>
  181. <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">
  182. 100
  183. </sys:Double>
  184. </Track.Resources>
  185. <Track.DecreaseRepeatButton>
  186. <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Opacity="0" />
  187. </Track.DecreaseRepeatButton>
  188. <Track.IncreaseRepeatButton>
  189. <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Opacity="0" />
  190. </Track.IncreaseRepeatButton> <!-- 不能删,删了点击 Thumb 以外的部分就不能翻页了 -->
  191. <Track.Thumb>
  192. <Thumb Style="{StaticResource MyThumb}" Foreground="{TemplateBinding Foreground}" />
  193. </Track.Thumb>
  194. </Track>
  195. </Border>
  196. </ControlTemplate>
  197. </Setter.Value>
  198. </Setter>
  199. </Style>
  200. <Style TargetType="local:MyScrollViewer" x:Name="StyleMyScrollViewer">
  201. <Setter Property="OverridesDefaultStyle" Value="True" />
  202. <Setter Property="CanContentScroll" Value="False" />
  203. <Setter Property="PanningMode" Value="VerticalOnly" />
  204. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  205. <Setter Property="Template">
  206. <Setter.Value>
  207. <ControlTemplate TargetType="ScrollViewer">
  208. <Grid>
  209. <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
  210. <local:MyScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" HorizontalAlignment="Right" />
  211. </Grid>
  212. </ControlTemplate>
  213. </Setter.Value>
  214. </Setter>
  215. </Style>
  216. <Style TargetType="local:PageComp" BasedOn="{StaticResource {x:Type local:MyScrollViewer}}" />
  217. <Style TargetType="ScrollViewer" x:Key="ScrollViewerFullMargin">
  218. <Setter Property="OverridesDefaultStyle" Value="True" />
  219. <Setter Property="CanContentScroll" Value="False" />
  220. <Setter Property="PanningMode" Value="VerticalOnly" />
  221. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  222. <Setter Property="Template">
  223. <Setter.Value>
  224. <ControlTemplate TargetType="ScrollViewer">
  225. <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}">
  226. <Grid.ColumnDefinitions>
  227. <ColumnDefinition Width="*"/>
  228. <ColumnDefinition Width="Auto"/>
  229. </Grid.ColumnDefinitions>
  230. <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"/>
  231. <local:MyScrollBar Margin="2,1,1,1" x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" />
  232. </Grid>
  233. </ControlTemplate>
  234. </Setter.Value>
  235. </Setter>
  236. </Style>
  237. <Style TargetType="ScrollViewer" x:Key="ScrollViewerNoMargin">
  238. <Setter Property="OverridesDefaultStyle" Value="True" />
  239. <Setter Property="CanContentScroll" Value="False" />
  240. <Setter Property="PanningMode" Value="VerticalOnly" />
  241. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  242. <Setter Property="Template">
  243. <Setter.Value>
  244. <ControlTemplate TargetType="ScrollViewer">
  245. <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Cursor="Arrow">
  246. <Grid.ColumnDefinitions>
  247. <ColumnDefinition Width="*"/>
  248. <ColumnDefinition Width="Auto"/>
  249. </Grid.ColumnDefinitions>
  250. <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Cursor="{TemplateBinding Cursor}" />
  251. <local:MyScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" />
  252. </Grid>
  253. </ControlTemplate>
  254. </Setter.Value>
  255. </Setter>
  256. </Style>
  257. <!-- TextBox -->
  258. <Style TargetType="local:MyTextBox">
  259. <Setter Property="BorderThickness" Value="1" />
  260. <Setter Property="Background" Value="{StaticResource ColorBrushHalfWhite}" />
  261. <Setter Property="FontSize" Value="13" />
  262. <Setter Property="SelectionBrush" Value="{DynamicResource ColorBrush3}" />
  263. <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
  264. <Setter Property="FontFamily" Value="Resources/#PCL English, Microsoft YaHei UI" />
  265. <Setter Property="VerticalContentAlignment" Value="Center" />
  266. <Setter Property="SnapsToDevicePixels" Value="True" />
  267. <Setter Property="IsUndoEnabled" Value="True" />
  268. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  269. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  270. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  271. <Setter Property="AllowDrop" Value="True"/>
  272. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  273. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  274. <Setter Property="UndoLimit" Value="15" />
  275. <Setter Property="MaxLength" Value="1000" />
  276. <Setter Property="BorderBrush" Value="{DynamicResource ColorBrushBg0}" />
  277. <Setter Property="Template">
  278. <Setter.Value>
  279. <ControlTemplate TargetType="local:MyTextBox">
  280. <Grid SnapsToDevicePixels="True" ToolTip="{TemplateBinding ToolTip}">
  281. <Grid.RowDefinitions>
  282. <RowDefinition MinHeight="28" />
  283. <RowDefinition Height="Auto" />
  284. </Grid.RowDefinitions>
  285. <Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding CornerRadius}">
  286. <ScrollViewer x:Name="PART_ContentHost" Style="{StaticResource ScrollViewerNoMargin}" RenderOptions.ClearTypeHint="Enabled" BorderThickness="0"
  287. Margin="5,0,0,0" Cursor="IBeam" />
  288. <!-- 由于未知原因,TextView 会有 2,0 的 Margin -->
  289. </Border>
  290. <Border Margin="{TemplateBinding Padding}" IsHitTestVisible="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" BorderThickness="0">
  291. <TextBlock x:Name="labHint" Foreground="{StaticResource ColorBrushGray4}" Margin="7,0,0,0" Padding="{TemplateBinding BorderThickness}" FontSize="{TemplateBinding FontSize}" FontFamily="Resources/#PCL English, Microsoft YaHei UI" />
  292. </Border>
  293. <TextBlock Grid.Row="1" x:Name="labWrong" Height="0" Foreground="{TemplateBinding BorderBrush}" Padding="0,4,0,0" Margin="0,0,0,-3" />
  294. </Grid>
  295. </ControlTemplate>
  296. </Setter.Value>
  297. </Setter>
  298. <Setter Property="behaviors:ClipboardInterceptor.EnableSafeClipboard" Value="True" />
  299. </Style>
  300. <Style TargetType="PasswordBox">
  301. <Setter Property="FontSize" Value="13" />
  302. <Setter Property="VerticalContentAlignment" Value="Top" />
  303. <Setter Property="SelectionBrush" Value="{DynamicResource ColorBrush3}" />
  304. <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
  305. <Setter Property="Background" Value="{StaticResource ColorBrushHalfWhite}" />
  306. <Setter Property="BorderBrush" Value="{DynamicResource ColorBrushBg0}" />
  307. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  308. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  309. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  310. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  311. <Setter Property="Template">
  312. <Setter.Value>
  313. <ControlTemplate TargetType="PasswordBox">
  314. <Border x:Name="border" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="True" CornerRadius="3">
  315. <local:MyScrollViewer x:Name="PART_ContentHost" Margin="4.5,4.5,0,4.5" HorizontalScrollBarVisibility="Hidden" RenderOptions.ClearTypeHint="Enabled" SnapsToDevicePixels="True"/>
  316. </Border>
  317. <ControlTemplate.Triggers>
  318. <Trigger Property="IsEnabled" Value="False">
  319. <Trigger.Setters>
  320. <Setter Property="BorderBrush" Value="{StaticResource ColorBrushGray5}" />
  321. <Setter Property="Background" Value="{StaticResource ColorBrushGray6}" />
  322. </Trigger.Setters>
  323. </Trigger>
  324. <Trigger Property="IsMouseOver" Value="True">
  325. <Trigger.Setters>
  326. <Setter Property="BorderBrush" Value="{DynamicResource ColorBrush4}" />
  327. <Setter Property="Background" Value="{DynamicResource ColorBrush7}" />
  328. </Trigger.Setters>
  329. </Trigger>
  330. <Trigger Property="IsFocused" Value="True">
  331. <Trigger.Setters>
  332. <Setter Property="BorderBrush" Value="{DynamicResource ColorBrush3}" />
  333. <Setter Property="Background" Value="{DynamicResource ColorBrush7}" />
  334. </Trigger.Setters>
  335. </Trigger>
  336. </ControlTemplate.Triggers>
  337. </ControlTemplate>
  338. </Setter.Value>
  339. </Setter>
  340. </Style>
  341. <!-- ComboBox -->
  342. <DataTemplate x:Key="ComboBoxItemTemplateWithDelete">
  343. <local:MyListItem Title="{Binding}" FontSize="13" MaxHeight="26" IsScaleAnimationEnabled="False" Margin="-3,0,0,0">
  344. <local:MyListItem.Buttons>
  345. <x:Array Type="local:MyIconButton">
  346. <local:MyIconButton Grid.Column="1" Height="20" Width="20" VerticalAlignment="Center" Tag="{Binding}" Click="MyIconButton_Click" Logo="F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z" />
  347. </x:Array>
  348. </local:MyListItem.Buttons>
  349. </local:MyListItem>
  350. </DataTemplate>
  351. <Style TargetType="local:MyComboBox">
  352. <Setter Property="OverridesDefaultStyle" Value="True" />
  353. <Setter Property="SnapsToDevicePixels" Value="True" />
  354. <Setter Property="Foreground" Value="{DynamicResource ColorBrushBg0}" />
  355. <Setter Property="Background" Value="{StaticResource ColorBrushHalfWhite}" />
  356. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  357. <Setter Property="FontSize" Value="13" />
  358. <Setter Property="MaxDropDownHeight" Value="160" />
  359. <Setter Property="Template">
  360. <Setter.Value>
  361. <ControlTemplate TargetType="ComboBox">
  362. <Grid>
  363. <Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="3" BorderThickness="1" BorderBrush="{TemplateBinding Foreground}" />
  364. <ToggleButton Margin="0,0,1.5,0" Foreground="{TemplateBinding Foreground}" IsTabStop="False" SnapsToDevicePixels="False" Focusable="False" IsChecked="{Binding IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" />
  365. <ContentPresenter x:Name="PART_Content" Margin="8.5,0,21.5,0" IsHitTestVisible="False" VerticalAlignment="Center"
  366. Content="{TemplateBinding SelectionBoxItem}"
  367. ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
  368. ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" />
  369. <Popup x:Name="PART_Popup" SnapsToDevicePixels="True" VerticalOffset="-1.5" AllowsTransparency="True" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="Fade">
  370. <Grid x:Name="PanPopup">
  371. <Border Background="White" CornerRadius="3" />
  372. <Border x:Name="dropDownBorder" CornerRadius="3" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1" Width="{TemplateBinding Width}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
  373. <local:MyScrollViewer x:Name="DropDownScrollViewer" PanningMode="VerticalOnly" SnapsToDevicePixels="False" Style="{StaticResource ScrollViewerFullMargin}" ScrollViewer.CanContentScroll="False" VerticalScrollBarVisibility="Auto">
  374. <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" />
  375. </local:MyScrollViewer>
  376. </Border>
  377. </Grid>
  378. </Popup>
  379. </Grid>
  380. <ControlTemplate.Triggers>
  381. <Trigger Property="HasItems" Value="false">
  382. <Setter Property="Height" TargetName="dropDownBorder" Value="26"/>
  383. </Trigger>
  384. </ControlTemplate.Triggers>
  385. </ControlTemplate>
  386. </Setter.Value>
  387. </Setter>
  388. <Style.Triggers>
  389. <Trigger Property="IsEditable" Value="True">
  390. <Setter Property="IsTabStop" Value="False"/>
  391. <Setter Property="ItemTemplate" Value="{StaticResource ComboBoxItemTemplateWithDelete}"/>
  392. <Setter Property="Template">
  393. <Setter.Value>
  394. <ControlTemplate TargetType="ComboBox">
  395. <Grid>
  396. <Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="3" BorderThickness="1" BorderBrush="{TemplateBinding Foreground}" />
  397. <ToggleButton Margin="0,0,1.5,0" Foreground="{TemplateBinding Foreground}" IsTabStop="False" SnapsToDevicePixels="False" Focusable="False" IsChecked="{Binding IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" />
  398. <local:MyTextBox x:Name="PART_EditableTextBox" BorderThickness="0" Margin="1.5,0,21.5,0" Padding="0" Background="{x:Null}" />
  399. <Popup x:Name="PART_Popup" SnapsToDevicePixels="True" VerticalOffset="-1.5" AllowsTransparency="True" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="Fade">
  400. <Grid x:Name="PanPopup">
  401. <Border Background="White" CornerRadius="3" />
  402. <Border x:Name="dropDownBorder" SnapsToDevicePixels="False" CornerRadius="3" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1" Width="{TemplateBinding Width}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
  403. <local:MyScrollViewer x:Name="DropDownScrollViewer" Style="{StaticResource ScrollViewerFullMargin}" ScrollViewer.CanContentScroll="False" VerticalScrollBarVisibility="Auto">
  404. <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" />
  405. </local:MyScrollViewer>
  406. </Border>
  407. </Grid>
  408. </Popup>
  409. </Grid>
  410. <ControlTemplate.Triggers>
  411. <Trigger Property="HasItems" Value="false">
  412. <Setter Property="Height" TargetName="dropDownBorder" Value="26"/>
  413. </Trigger>
  414. </ControlTemplate.Triggers>
  415. </ControlTemplate>
  416. </Setter.Value>
  417. </Setter>
  418. </Trigger>
  419. </Style.Triggers>
  420. </Style>
  421. <Style TargetType="ToggleButton">
  422. <Setter Property="Template">
  423. <Setter.Value>
  424. <ControlTemplate TargetType="ToggleButton">
  425. <Border Background="{StaticResource ColorBrushSemiTransparent}">
  426. <Path x:Name="path" Width="15" RenderTransformOrigin="0.3,0.5" HorizontalAlignment="Right" Data="M1,1L4.5,4.5L8,1" StrokeThickness="1.5" Stroke="{TemplateBinding Foreground}" VerticalAlignment="Center">
  427. <Path.RenderTransform>
  428. <RotateTransform />
  429. </Path.RenderTransform>
  430. </Path>
  431. </Border>
  432. <ControlTemplate.Triggers>
  433. <Trigger Property="IsChecked" Value="True">
  434. <Trigger.EnterActions>
  435. <BeginStoryboard>
  436. <Storyboard Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)">
  437. <DoubleAnimation To="180" Duration="0:0:0.2">
  438. <DoubleAnimation.EasingFunction>
  439. <CircleEase EasingMode="EaseOut" />
  440. </DoubleAnimation.EasingFunction>
  441. </DoubleAnimation>
  442. </Storyboard>
  443. </BeginStoryboard>
  444. </Trigger.EnterActions>
  445. <Trigger.ExitActions>
  446. <BeginStoryboard>
  447. <Storyboard Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)">
  448. <DoubleAnimation To="0" Duration="0:0:0.2">
  449. <DoubleAnimation.EasingFunction>
  450. <CircleEase EasingMode="EaseOut" />
  451. </DoubleAnimation.EasingFunction>
  452. </DoubleAnimation>
  453. </Storyboard>
  454. </BeginStoryboard>
  455. </Trigger.ExitActions>
  456. </Trigger>
  457. </ControlTemplate.Triggers>
  458. </ControlTemplate>
  459. </Setter.Value>
  460. </Setter>
  461. </Style>
  462. <Style TargetType="ComboBoxItem" x:Key="MyComboBoxItem">
  463. <Setter Property="OverridesDefaultStyle" Value="True" />
  464. <Setter Property="ToolTipService.Placement" Value="Relative" />
  465. <Setter Property="ToolTipService.VerticalOffset" Value="-2" />
  466. <Setter Property="ToolTipService.HorizontalOffset" Value="200" />
  467. <Setter Property="ToolTipService.InitialShowDelay" Value="150" />
  468. <Setter Property="ToolTipService.BetweenShowDelay" Value="150" />
  469. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  470. <Setter Property="Background" Value="{StaticResource ColorBrushTransparent}" />
  471. <Setter Property="Template">
  472. <Setter.Value>
  473. <ControlTemplate TargetType="ComboBoxItem">
  474. <Border x:Name="ItemBorder" Padding="6,4" SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
  475. <ContentPresenter />
  476. </Border>
  477. </ControlTemplate>
  478. </Setter.Value>
  479. </Setter>
  480. </Style>
  481. <Style TargetType="ComboBoxItem">
  482. <Setter Property="OverridesDefaultStyle" Value="True" />
  483. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  484. <Setter Property="Template">
  485. <Setter.Value>
  486. <ControlTemplate TargetType="ComboBoxItem">
  487. <Border x:Name="ItemBorder" SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
  488. <ContentPresenter />
  489. </Border>
  490. </ControlTemplate>
  491. </Setter.Value>
  492. </Setter>
  493. </Style>
  494. <!-- ContextMenu -->
  495. <Style TargetType="ContextMenu">
  496. <Setter Property="SnapsToDevicePixels" Value="True"/>
  497. <Setter Property="OverridesDefaultStyle" Value="True"/>
  498. <Setter Property="Grid.IsSharedSizeScope" Value="True"/>
  499. <Setter Property="Focusable" Value="False"/>
  500. <Setter Property="HasDropShadow" Value="False"/>
  501. <Setter Property="Template">
  502. <Setter.Value>
  503. <ControlTemplate TargetType="ContextMenu">
  504. <Border BorderBrush="{DynamicResource ColorBrush1}" BorderThickness="1" CornerRadius="3" Background="White" Margin="0,0,4,4" SnapsToDevicePixels="True">
  505. <Border.Effect>
  506. <DropShadowEffect Opacity="0.4" BlurRadius="4" ShadowDepth="2" />
  507. </Border.Effect>
  508. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" Margin="0.5"/>
  509. </Border>
  510. </ControlTemplate>
  511. </Setter.Value>
  512. </Setter>
  513. </Style>
  514. <!-- MenuItem -->
  515. <Style TargetType="local:MyMenuItem">
  516. <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
  517. <Setter Property="Template">
  518. <Setter.Value>
  519. <ControlTemplate TargetType="MenuItem">
  520. <Border Name="PanBack" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" Height="26">
  521. <Grid SnapsToDevicePixels="False" UseLayoutRounding="False">
  522. <Grid.ColumnDefinitions>
  523. <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
  524. <ColumnDefinition />
  525. <!-- <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
  526. <ColumnDefinition Width="13"/> -->
  527. </Grid.ColumnDefinitions>
  528. <Path Name="Icon" VerticalAlignment="Center" Stretch="Uniform" Margin="8,0" Fill="{TemplateBinding Foreground}" Height="12" Width="15" />
  529. <TextBlock Name="HeaderHost" Grid.Column="1" Text="{TemplateBinding Header}" Foreground="{TemplateBinding Foreground}" Margin="0,0,40,0" VerticalAlignment="Center" Height="16" />
  530. <!-- <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,2,0,2" DockPanel.Dock="Right" /> -->
  531. </Grid>
  532. </Border>
  533. <ControlTemplate.Triggers>
  534. <Trigger Property="Icon" Value="{x:Null}">
  535. <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
  536. </Trigger>
  537. </ControlTemplate.Triggers>
  538. </ControlTemplate>
  539. </Setter.Value>
  540. </Setter>
  541. </Style>
  542. </ResourceDictionary>
  543. </Application.Resources>
  544. </Application>