Application.xaml 39 KB

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